@@ -127,8 +127,10 @@ protected StudentFilePolicy getStudentFilePolicy(Path projectPath) {
127
127
128
128
@ Override
129
129
public RunResult runTests (Path path ) {
130
+ Path shadowDir = makeShadowBuildDir (path );
131
+
130
132
try {
131
- ProcessResult qmakeBuild = buildWithQmake (path );
133
+ ProcessResult qmakeBuild = buildWithQmake (shadowDir );
132
134
if (qmakeBuild .statusCode != 0 ) {
133
135
log .error ("Building project with qmake failed: {}" , qmakeBuild .errorOutput );
134
136
return filledFailure (qmakeBuild .errorOutput );
@@ -139,7 +141,7 @@ public RunResult runTests(Path path) {
139
141
}
140
142
141
143
try {
142
- ProcessResult makeBuild = buildWithMake (path );
144
+ ProcessResult makeBuild = buildWithMake (shadowDir );
143
145
if (makeBuild .statusCode != 0 ) {
144
146
log .error ("Building project with make failed: {}" , makeBuild .errorOutput );
145
147
return filledFailure (makeBuild .errorOutput );
@@ -158,7 +160,7 @@ public RunResult runTests(Path path) {
158
160
log .info ("Testing project with command {}" , Arrays .toString (makeCommand ));
159
161
160
162
try {
161
- ProcessResult testRun = run (makeCommand , path );
163
+ ProcessResult testRun = run (makeCommand , shadowDir );
162
164
163
165
if (!Files .exists (testResults )) {
164
166
log .error ("Failed to get test output at {}" , testResults );
@@ -189,9 +191,21 @@ public Map<File, List<ValidationError>> getValidationErrors() {
189
191
};
190
192
}
191
193
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
+
192
206
private ProcessResult buildWithQmake (Path dir ) throws Exception {
193
207
String qmakeArguments = "CONFIG+=test" ;
194
- Path pro = getProFile (dir );
208
+ Path pro = getProFile (dir . getParent () );
195
209
String [] qmakeCommand = {"qmake" , qmakeArguments , pro .toString ()};
196
210
197
211
log .info ("Building project with command {}" , Arrays .deepToString (qmakeCommand ));
0 commit comments