diff --git a/src/main/java/de/hftstuttgart/dtabackend/utils/ExecuteTestUtil.java b/src/main/java/de/hftstuttgart/dtabackend/utils/ExecuteTestUtil.java index 90973dad94671ec8d2cd99fb4630f0d9fb3c02d6..9a40aa9a15bc5b27b65e9b8e83eaf7d04668fba9 100644 --- a/src/main/java/de/hftstuttgart/dtabackend/utils/ExecuteTestUtil.java +++ b/src/main/java/de/hftstuttgart/dtabackend/utils/ExecuteTestUtil.java @@ -34,8 +34,8 @@ public class ExecuteTestUtil { private static final Logger LOG = LogManager.getLogger(ExecuteTestUtil.class); private final DockerUtil dockerUtil; - private final String basePath; - private final String containerBasePath; + private final String basePathProfessorUnitTests; + private final String basePathStudentsSubmissionCode; public ExecuteTestUtil(Environment env, DockerUtil dockerUtil) { this.dockerUtil = dockerUtil; @@ -44,16 +44,16 @@ public class ExecuteTestUtil { Path p = Paths.get( env.getProperty("data.dir"), ///data env.getProperty("data.dir.test.folder.name")); //UnitTests - this.basePath = p.toAbsolutePath().toString(); - this.containerBasePath = env.getProperty( "data.dir"); + this.basePathProfessorUnitTests = p.toAbsolutePath().toString(); + this.basePathStudentsSubmissionCode = env.getProperty( "tests.tmp.dir");// /dta-test-assignments } public ResultSummary runTests(String assignmentId, Path workDirectory) throws IOException, InterruptedException { // Define paths for the submission-specific directories - String containerTestDir = this.containerBasePath + workDirectory.getFileName(); // /dta-test-assignments/dta-submissionID - Path testPath = Paths.get(containerTestDir, "test"); - Path srcPath = Paths.get(containerTestDir, "src"); - Path resultPath = Paths.get(containerTestDir, "result"); + String submissionDirectory = this.basePathStudentsSubmissionCode + workDirectory.getFileName(); // /dta-test-assignments/dta-submissionID + Path testPath = Paths.get(submissionDirectory, "test"); + Path srcPath = Paths.get(submissionDirectory, "src"); + Path resultPath = Paths.get(submissionDirectory, "result"); // Ensure directories exist Files.createDirectories(testPath); @@ -62,29 +62,29 @@ public class ExecuteTestUtil { // Clone stored test to testPath LOG.debug("Copying pre-downloaded unit test repo"); - FileUtil.copyFolder(Paths.get(basePath, assignmentId), testPath); + FileUtil.copyFolder(Paths.get(basePathProfessorUnitTests, assignmentId), testPath); LOG.debug("Copying exercise manifest"); Files.copy( - Paths.get(basePath, assignmentId + "_checkout", CompetencyAssessmentUtil.EXERCISE_COMPETENCY_MANIFEST_FILE_NAME), + Paths.get(basePathProfessorUnitTests, assignmentId + "_checkout", CompetencyAssessmentUtil.EXERCISE_COMPETENCY_MANIFEST_FILE_NAME), testPath.resolve(CompetencyAssessmentUtil.EXERCISE_COMPETENCY_MANIFEST_FILE_NAME) ); LOG.debug("Copying test config"); Files.copy( - Paths.get(basePath, assignmentId + ".txt"), - Paths.get(containerTestDir, "config.txt") + Paths.get(basePathProfessorUnitTests, assignmentId + ".txt"), + Paths.get(submissionDirectory, "config.txt") ); LOG.info("Reading test config"); Matcher config = RegexUtil.extractConfig( - new FileInputStream(Paths.get(containerTestDir, "config.txt").toFile()), + new FileInputStream(Paths.get(submissionDirectory, "config.txt").toFile()), Pattern.compile(RegexUtil.DTA_TESTCONFIGREGEX) ); String image; if (config == null) { config = RegexUtil.extractConfig( - new FileInputStream(Paths.get(containerTestDir, "config.txt").toFile()), + new FileInputStream(Paths.get(submissionDirectory, "config.txt").toFile()), Pattern.compile(RegexUtil.TESTCONFIGREGEX) ); if (config == null) { @@ -157,7 +157,7 @@ public class ExecuteTestUtil { throws FileNotFoundException { // fetch repo url from original test upload Pattern pattern = Pattern.compile(RegexUtil.DTA_TESTCONFIGREGEX); - File configFile = Paths.get(basePath, assignmentId + ".txt").toFile(); + File configFile = Paths.get(basePathProfessorUnitTests, assignmentId + ".txt").toFile(); Matcher config = RegexUtil.extractConfig(new FileInputStream(configFile), pattern); String testRepoURL = config.group(1);