Commit 257c0503 authored by mamunozgil's avatar mamunozgil
Browse files

Fix: correct property and rename variable names

No related merge requests found
Pipeline #10778 passed with stage
in 18 seconds
Showing with 15 additions and 15 deletions
+15 -15
......@@ -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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment