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

Fix: correct property and rename variable names

parent 92f938c9
Pipeline #10778 passed with stage
in 18 seconds
Showing with 15 additions and 15 deletions
+15 -15
...@@ -34,8 +34,8 @@ public class ExecuteTestUtil { ...@@ -34,8 +34,8 @@ public class ExecuteTestUtil {
private static final Logger LOG = LogManager.getLogger(ExecuteTestUtil.class); private static final Logger LOG = LogManager.getLogger(ExecuteTestUtil.class);
private final DockerUtil dockerUtil; private final DockerUtil dockerUtil;
private final String basePath; private final String basePathProfessorUnitTests;
private final String containerBasePath; private final String basePathStudentsSubmissionCode;
public ExecuteTestUtil(Environment env, DockerUtil dockerUtil) { public ExecuteTestUtil(Environment env, DockerUtil dockerUtil) {
this.dockerUtil = dockerUtil; this.dockerUtil = dockerUtil;
...@@ -44,16 +44,16 @@ public class ExecuteTestUtil { ...@@ -44,16 +44,16 @@ public class ExecuteTestUtil {
Path p = Paths.get( Path p = Paths.get(
env.getProperty("data.dir"), ///data env.getProperty("data.dir"), ///data
env.getProperty("data.dir.test.folder.name")); //UnitTests env.getProperty("data.dir.test.folder.name")); //UnitTests
this.basePath = p.toAbsolutePath().toString(); this.basePathProfessorUnitTests = p.toAbsolutePath().toString();
this.containerBasePath = env.getProperty( "data.dir"); this.basePathStudentsSubmissionCode = env.getProperty( "tests.tmp.dir");// /dta-test-assignments
} }
public ResultSummary runTests(String assignmentId, Path workDirectory) throws IOException, InterruptedException { public ResultSummary runTests(String assignmentId, Path workDirectory) throws IOException, InterruptedException {
// Define paths for the submission-specific directories // Define paths for the submission-specific directories
String containerTestDir = this.containerBasePath + workDirectory.getFileName(); // /dta-test-assignments/dta-submissionID String submissionDirectory = this.basePathStudentsSubmissionCode + workDirectory.getFileName(); // /dta-test-assignments/dta-submissionID
Path testPath = Paths.get(containerTestDir, "test"); Path testPath = Paths.get(submissionDirectory, "test");
Path srcPath = Paths.get(containerTestDir, "src"); Path srcPath = Paths.get(submissionDirectory, "src");
Path resultPath = Paths.get(containerTestDir, "result"); Path resultPath = Paths.get(submissionDirectory, "result");
// Ensure directories exist // Ensure directories exist
Files.createDirectories(testPath); Files.createDirectories(testPath);
...@@ -62,29 +62,29 @@ public class ExecuteTestUtil { ...@@ -62,29 +62,29 @@ public class ExecuteTestUtil {
// Clone stored test to testPath // Clone stored test to testPath
LOG.debug("Copying pre-downloaded unit test repo"); 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"); LOG.debug("Copying exercise manifest");
Files.copy( 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) testPath.resolve(CompetencyAssessmentUtil.EXERCISE_COMPETENCY_MANIFEST_FILE_NAME)
); );
LOG.debug("Copying test config"); LOG.debug("Copying test config");
Files.copy( Files.copy(
Paths.get(basePath, assignmentId + ".txt"), Paths.get(basePathProfessorUnitTests, assignmentId + ".txt"),
Paths.get(containerTestDir, "config.txt") Paths.get(submissionDirectory, "config.txt")
); );
LOG.info("Reading test config"); LOG.info("Reading test config");
Matcher config = RegexUtil.extractConfig( 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) Pattern.compile(RegexUtil.DTA_TESTCONFIGREGEX)
); );
String image; String image;
if (config == null) { if (config == null) {
config = RegexUtil.extractConfig( config = RegexUtil.extractConfig(
new FileInputStream(Paths.get(containerTestDir, "config.txt").toFile()), new FileInputStream(Paths.get(submissionDirectory, "config.txt").toFile()),
Pattern.compile(RegexUtil.TESTCONFIGREGEX) Pattern.compile(RegexUtil.TESTCONFIGREGEX)
); );
if (config == null) { if (config == null) {
...@@ -157,7 +157,7 @@ public class ExecuteTestUtil { ...@@ -157,7 +157,7 @@ public class ExecuteTestUtil {
throws FileNotFoundException { throws FileNotFoundException {
// fetch repo url from original test upload // fetch repo url from original test upload
Pattern pattern = Pattern.compile(RegexUtil.DTA_TESTCONFIGREGEX); 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); Matcher config = RegexUtil.extractConfig(new FileInputStream(configFile), pattern);
String testRepoURL = config.group(1); 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