diff --git a/src/main/resources/templates/ocaml/test/run.sh b/src/main/resources/templates/ocaml/test/run.sh index a641fcf98970..3dc4af3ff7cd 100755 --- a/src/main/resources/templates/ocaml/test/run.sh +++ b/src/main/resources/templates/ocaml/test/run.sh @@ -3,6 +3,7 @@ # copy code from the assignment or solution to the appropriate test folder cp_code() { + mv "$2" "$1" cd "$1" || exit rm ./*.ml >/dev/null 2>&1 # shellcheck disable=SC2086 @@ -48,9 +49,9 @@ find ../${studentParentWorkingDirectoryName}/ -type l | grep -q . && echo "Canno # include solution and assignment in the tests # this will only pick up *.ml files in the /src folders if other files are required for the tests this needs to be adjusted -cp_code ${solutionWorkingDirectory} +cp_code ${solutionWorkingDirectory} solution echo 'include Assignment' > ${solutionWorkingDirectory}/solution.ml -cp_code ${studentParentWorkingDirectoryName} +cp_code ${studentParentWorkingDirectoryName} assignment # select if tests are run by generated source code as student toplevel code may run before the tests and be able to spoof a runtime signal echo "let runHidden = $RUN_HIDDEN" > test/runHidden.ml @@ -71,7 +72,7 @@ if ! timeout -s SIGTERM $BUILD_TIMEOUT checker/checker.exe; then fi # build the student submission # don't reference the tests or solution, so that we can show the build output to the student and not leak test / solution code -if ! timeout -s SIGTERM $BUILD_TIMEOUT dune build --force assignment; then +if ! timeout -s SIGTERM $BUILD_TIMEOUT dune build --force ${solutionWorkingDirectory}; then echo "Unable to build submission, please ensure that your code builds and matches the provided interface" >&2 exit 0 fi diff --git a/src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-custom-build-plan.component.ts b/src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-custom-build-plan.component.ts index ef8f0cc14ab2..ca8fecdac875 100644 --- a/src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-custom-build-plan.component.ts +++ b/src/main/webapp/app/exercises/programming/manage/update/update-components/custom-build-plans/programming-exercise-custom-build-plan.component.ts @@ -49,8 +49,11 @@ export class ProgrammingExerciseCustomBuildPlanComponent implements OnChanges { } } if (this.shouldReplacePlaceholders()) { - this.programmingExercise.buildConfig!.buildScript = this.replacePlaceholders(this.originalBuildScript); - this.codeChanged(this.programmingExercise.buildConfig?.buildScript || ''); + const updatedBuildScript = this.replacePlaceholders(this.originalBuildScript); + if (updatedBuildScript) { + this.programmingExercise.buildConfig!.buildScript = updatedBuildScript; + this.codeChanged(this.programmingExercise.buildConfig?.buildScript || ''); + } } } @@ -68,9 +71,10 @@ export class ProgrammingExerciseCustomBuildPlanComponent implements OnChanges { shouldReplacePlaceholders(): boolean { return ( (!!this.programmingExercise.buildConfig?.assignmentCheckoutPath && this.programmingExercise.buildConfig?.assignmentCheckoutPath !== '') || - (!!this.programmingExercise.buildConfig?.testCheckoutPath && this.programmingExercise.buildConfig?.testCheckoutPath !== '') || - !!this.programmingExercise.buildConfig?.buildScript?.includes('${studentParentWorkingDirectoryName}') || - !!this.programmingExercise.buildConfig?.buildScript?.includes('${testWorkingDirectory}') + (!!this.programmingExercise.buildConfig?.testCheckoutPath && + this.programmingExercise.buildConfig?.testCheckoutPath !== '' && + (!!this.programmingExercise.buildConfig?.buildScript?.includes('${studentParentWorkingDirectoryName}') || + !!this.programmingExercise.buildConfig?.buildScript?.includes('${testWorkingDirectory}'))) ); }