forked from SERG-Delft/andy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into docker-more-assignments
- Loading branch information
Showing
19 changed files
with
722 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
andy/src/main/java/nl/tudelft/cse1110/andy/execution/step/RunPenaltyMetaTestsStep.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package nl.tudelft.cse1110.andy.execution.step; | ||
|
||
import nl.tudelft.cse1110.andy.config.DirectoryConfiguration; | ||
import nl.tudelft.cse1110.andy.config.MetaTest; | ||
import nl.tudelft.cse1110.andy.config.RunConfiguration; | ||
import nl.tudelft.cse1110.andy.execution.Context.Context; | ||
import nl.tudelft.cse1110.andy.execution.ExecutionStep; | ||
import nl.tudelft.cse1110.andy.result.MetaTestResult; | ||
import nl.tudelft.cse1110.andy.result.ResultBuilder; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class RunPenaltyMetaTestsStep implements ExecutionStep { | ||
|
||
@Override | ||
public void execute(Context ctx, ResultBuilder result) { | ||
DirectoryConfiguration dirCfg = ctx.getDirectoryConfiguration(); | ||
RunConfiguration runCfg = ctx.getRunConfiguration(); | ||
|
||
int score = 0; | ||
int totalWeight = 0; | ||
|
||
ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader(); | ||
|
||
try { | ||
|
||
List<MetaTest> metaTests = runCfg.penaltyMetaTests(); | ||
List<MetaTestResult> metaTestResults = new ArrayList<>(); | ||
|
||
for (MetaTest metaTest : metaTests) { | ||
|
||
boolean passesTheMetaTest = metaTest.execute(ctx, dirCfg, runCfg); | ||
|
||
if (passesTheMetaTest) { | ||
score += metaTest.getWeight(); | ||
} | ||
|
||
metaTestResults.add(new MetaTestResult(metaTest.getName(), metaTest.getWeight(), passesTheMetaTest)); | ||
|
||
totalWeight += metaTest.getWeight(); | ||
} | ||
|
||
result.logPenaltyMetaTests(score, totalWeight, metaTestResults); | ||
} catch (Exception ex) { | ||
result.genericFailure(this, ex); | ||
} finally { | ||
/* restore the class loader to the one before meta tests */ | ||
Thread.currentThread().setContextClassLoader(currentClassLoader); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
return other instanceof RunPenaltyMetaTestsStep; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return super.hashCode(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.