@@ -50,6 +50,12 @@ public final class MakePlugin extends AbstractLanguagePlugin {
5050 private static final String CANT_PARSE_EXERCISE_DESCRIPTION =
5151 "Couldn't parse exercise description." ;
5252 private static final String COMPILE_FAILED_MESSAGE = "Failed to compile project." ;
53+ private static final String PERMISSION_MITIGATION_MESSAGE =
54+ "Permission problems, cleaning and trying again." ;
55+ private static final String PERMISSIONS_FIX_FAILED_MESSAGE = "Fixing permission issues failed." ;
56+ private static final String RUNNING_WITHOUT_VALGRIND_MESSAGE =
57+ "Trying to run tests without Valgrind." ;
58+ private static final String PERMISSION_PROBLEM_INDICATOR = "Permission denied" ;
5359
5460 private static final Logger log = LoggerFactory .getLogger (MakePlugin .class );
5561
@@ -166,13 +172,28 @@ public RunResult runTests(Path path) {
166172 try {
167173 runTests (path , withValgrind );
168174 } catch (Exception e ) {
169- withValgrind = false ;
170-
171- try {
172- runTests (path , withValgrind );
173- } catch (Exception e1 ) {
174- log .error (e1 .toString ());
175- throw new RuntimeException (TEST_FAIL_MESSAGE );
175+ // In case the folder has a test binary without the executable bit
176+ if (e .getMessage ().contains (PERMISSION_PROBLEM_INDICATOR )) {
177+ log .info (PERMISSION_MITIGATION_MESSAGE );
178+ clean (path );
179+ try {
180+ runTests (path , withValgrind );
181+ } catch (Exception e1 ) {
182+ log .info (PERMISSIONS_FIX_FAILED_MESSAGE );
183+ withValgrind = false ;
184+ }
185+ } else {
186+ withValgrind = false ;
187+ }
188+ if (!withValgrind ) {
189+ // The system probably doesn't have Valgrind properly installed
190+ log .info (RUNNING_WITHOUT_VALGRIND_MESSAGE );
191+ try {
192+ runTests (path , withValgrind );
193+ } catch (Exception e1 ) {
194+ log .error (e1 .toString ());
195+ throw new RuntimeException (TEST_FAIL_MESSAGE );
196+ }
176197 }
177198 }
178199
0 commit comments