Skip to content

Commit 5397743

Browse files
Kimmo Linnavuod471061c
authored andcommitted
Build exercises in to a shadow build directory
1 parent 7d95904 commit 5397743

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

tmc-langs-qmake/src/main/java/fi/helsinki/cs/tmc/langs/qmake/QmakePlugin.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,10 @@ protected StudentFilePolicy getStudentFilePolicy(Path projectPath) {
127127

128128
@Override
129129
public RunResult runTests(Path path) {
130+
Path shadowDir = makeShadowBuildDir(path);
131+
130132
try {
131-
ProcessResult qmakeBuild = buildWithQmake(path);
133+
ProcessResult qmakeBuild = buildWithQmake(shadowDir);
132134
if (qmakeBuild.statusCode != 0) {
133135
log.error("Building project with qmake failed: {}", qmakeBuild.errorOutput);
134136
return filledFailure(qmakeBuild.errorOutput);
@@ -139,7 +141,7 @@ public RunResult runTests(Path path) {
139141
}
140142

141143
try {
142-
ProcessResult makeBuild = buildWithMake(path);
144+
ProcessResult makeBuild = buildWithMake(shadowDir);
143145
if (makeBuild.statusCode != 0) {
144146
log.error("Building project with make failed: {}", makeBuild.errorOutput);
145147
return filledFailure(makeBuild.errorOutput);
@@ -158,7 +160,7 @@ public RunResult runTests(Path path) {
158160
log.info("Testing project with command {}", Arrays.toString(makeCommand));
159161

160162
try {
161-
ProcessResult testRun = run(makeCommand, path);
163+
ProcessResult testRun = run(makeCommand, shadowDir);
162164

163165
if (!Files.exists(testResults)) {
164166
log.error("Failed to get test output at {}", testResults);
@@ -189,9 +191,21 @@ public Map<File, List<ValidationError>> getValidationErrors() {
189191
};
190192
}
191193

194+
private Path makeShadowBuildDir(Path dir) {
195+
File buildDir = dir.resolve("build").toFile();
196+
log.info("Making shadow build dir to {}", buildDir.toPath());
197+
if (!buildDir.mkdirs()) {
198+
throw new RuntimeException(
199+
"Unable to create shadow build directory: "
200+
+ buildDir.toPath());
201+
}
202+
203+
return buildDir.toPath();
204+
}
205+
192206
private ProcessResult buildWithQmake(Path dir) throws Exception {
193207
String qmakeArguments = "CONFIG+=test";
194-
Path pro = getProFile(dir);
208+
Path pro = getProFile(dir.getParent());
195209
String[] qmakeCommand = {"qmake", qmakeArguments, pro.toString()};
196210

197211
log.info("Building project with command {}", Arrays.deepToString(qmakeCommand));

0 commit comments

Comments
 (0)