Skip to content

Commit

Permalink
Use JUnit timeouts instead of Jagr
Browse files Browse the repository at this point in the history
  • Loading branch information
zentox committed Dec 13, 2023
1 parent 68deedf commit e82457e
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 7 deletions.
29 changes: 22 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,39 @@ jagr {
}
}
graders {
val graderPublic by creating {
graderName.set("H06-Public")
val graderPrivate by creating {
graderName.set("H06-Private")
rubricProviderName.set("h06.H06_RubricProvider")
config.set(
org.sourcegrade.jagr.launcher.env.Config(
executor = org.sourcegrade.jagr.launcher.env.Executor(
jvmArgs = listOf(
"-Djava.awt.headless=true",
"-Dtestfx.robot=glass",
"-Dtestfx.headless=true",
"-Dprism.order=sw",
"-Dprism.lcdtext=false",
"-Dprism.subpixeltext=false",
"-Dglass.win.uiScale=100%",
"-Dprism.text=t2k",
),
),
transformers = org.sourcegrade.jagr.launcher.env.Transformers(
timeout = org.sourcegrade.jagr.launcher.env.Transformers.TimeoutTransformer(enabled = false),
),
),
)
configureDependencies {
implementation(libs.algoutils.tutor)
implementation(libs.bundles.junit)
}
}
val graderPrivate by creating {
parent(graderPublic)
graderName.set("H06-Private")
}
}
}

dependencies {
implementation(libs.annotations)
implementation(libs.algoutils.student)
testImplementation(libs.bundles.junit)
testImplementation(libs.junit.core)
implementation(libs.fopbot)
}
Expand Down
2 changes: 2 additions & 0 deletions src/graderPrivate/java/h06/H1_DirectionVectorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.junitpioneer.jupiter.json.JsonClasspathSource;
import org.junitpioneer.jupiter.json.Property;
import org.sourcegrade.jagr.api.rubric.TestForSubmission;
import org.tudalgo.algoutils.tutor.general.annotation.SkipAfterFirstFailedTest;
import org.tudalgo.algoutils.tutor.general.assertions.Context;
import org.tudalgo.algoutils.tutor.general.reflections.BasicMethodLink;
import org.tudalgo.algoutils.tutor.general.reflections.MethodLink;
Expand Down Expand Up @@ -43,6 +44,7 @@
unit = TimeUnit.SECONDS,
threadMode = Timeout.ThreadMode.SEPARATE_THREAD
)
@SkipAfterFirstFailedTest(TestConstants.SKIP_AFTER_FIRST_FAILED_TEST)
public class H1_DirectionVectorTest {

/**
Expand Down
2 changes: 2 additions & 0 deletions src/graderPrivate/java/h06/H2_WorldTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.junitpioneer.jupiter.json.JsonClasspathSource;
import org.junitpioneer.jupiter.json.Property;
import org.sourcegrade.jagr.api.rubric.TestForSubmission;
import org.tudalgo.algoutils.tutor.general.annotation.SkipAfterFirstFailedTest;
import org.tudalgo.algoutils.tutor.general.assertions.Context;
import org.tudalgo.algoutils.tutor.general.match.BasicReflectionMatchers;
import org.tudalgo.algoutils.tutor.general.reflections.BasicTypeLink;
Expand All @@ -36,6 +37,7 @@
unit = TimeUnit.SECONDS,
threadMode = Timeout.ThreadMode.SEPARATE_THREAD
)
@SkipAfterFirstFailedTest(TestConstants.SKIP_AFTER_FIRST_FAILED_TEST)
public class H2_WorldTest {

/**
Expand Down
2 changes: 2 additions & 0 deletions src/graderPrivate/java/h06/H3_MazeSolverRecursiveTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.junitpioneer.jupiter.json.Property;
import org.opentest4j.AssertionFailedError;
import org.sourcegrade.jagr.api.rubric.TestForSubmission;
import org.tudalgo.algoutils.tutor.general.annotation.SkipAfterFirstFailedTest;
import org.tudalgo.algoutils.tutor.general.assertions.Context;
import org.tudalgo.algoutils.tutor.general.reflections.BasicMethodLink;
import org.tudalgo.algoutils.tutor.general.reflections.MethodLink;
Expand Down Expand Up @@ -59,6 +60,7 @@
unit = TimeUnit.SECONDS,
threadMode = Timeout.ThreadMode.SEPARATE_THREAD
)
@SkipAfterFirstFailedTest(TestConstants.SKIP_AFTER_FIRST_FAILED_TEST)
public class H3_MazeSolverRecursiveTest {

/**
Expand Down
2 changes: 2 additions & 0 deletions src/graderPrivate/java/h06/H4_MazeSolverIterativeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.junitpioneer.jupiter.json.JsonClasspathSource;
import org.junitpioneer.jupiter.json.Property;
import org.sourcegrade.jagr.api.rubric.TestForSubmission;
import org.tudalgo.algoutils.tutor.general.annotation.SkipAfterFirstFailedTest;
import org.tudalgo.algoutils.tutor.general.assertions.Context;
import org.tudalgo.algoutils.tutor.general.reflections.BasicMethodLink;
import org.tudalgo.algoutils.tutor.general.reflections.MethodLink;
Expand Down Expand Up @@ -49,6 +50,7 @@
unit = TimeUnit.SECONDS,
threadMode = Timeout.ThreadMode.SEPARATE_THREAD
)
@SkipAfterFirstFailedTest(TestConstants.SKIP_AFTER_FIRST_FAILED_TEST)
public class H4_MazeSolverIterativeTest {

/**
Expand Down
5 changes: 5 additions & 0 deletions src/graderPrivate/java/h06/TestConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ public class TestConstants {
* The timeout for each test in seconds.
*/
public static final int TEST_TIMEOUT_IN_SECONDS = 2;

/**
* Whether to skip the remaining parametrized tests after the first failed test.
*/
public static final boolean SKIP_AFTER_FIRST_FAILED_TEST = true;
}

0 comments on commit e82457e

Please sign in to comment.