-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle class setup failures preventing previously failed methods from retrying #177
Conversation
d904726
to
7ea416d
Compare
if (Files.exists(marker)) { | ||
int counter = Integer.parseInt(new String(Files.readAllBytes(marker))); | ||
++counter; | ||
Files.write(marker, Integer.toString(counter).getBytes()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Files.write(marker, Integer.toString(counter).getBytes()); | |
marker.text = counter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❗ This is a Java class that we create in the build workspace to simplify creation of test classes, so this won't work.
Path marker = Paths.get("build/marker.file." + id); | ||
try { | ||
if (Files.exists(marker)) { | ||
int counter = Integer.parseInt(new String(Files.readAllBytes(marker))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably need the groovy-nio
as test dependency for the nice Path
extension methods.
int counter = Integer.parseInt(new String(Files.readAllBytes(marker))); | |
int counter = Integer.parseInt(marker.text)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, it is a plain Java class written alongside test classes.
throw new RuntimeException("fail me!"); | ||
} | ||
} else { | ||
Files.write(marker, "0".getBytes()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Files.write(marker, "0".getBytes()); | |
marker.text = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
@@ -78,6 +78,24 @@ abstract class AbstractPluginFuncTest extends Specification { | |||
throw new java.io.UncheckedIOException(e); | |||
} | |||
} | |||
|
|||
public static void flakyAssertPassFailPass(String id) { | |||
Path marker = Paths.get("build/marker.file." + id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Path marker = Paths.get("build/marker.file." + id); | |
Path marker = Paths.get("build/marker.file.$id"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
@@ -132,6 +150,10 @@ abstract class AbstractPluginFuncTest extends Specification { | |||
return "acme.FlakyAssert.flakyAssert(\"${StringEscapeUtils.escapeJava(id)}\", $failures);" | |||
} | |||
|
|||
static String flakyAssertPassFailPass(String id = "id") { | |||
return "acme.FlakyAssert.flakyAssertPassFailPass(\"${StringEscapeUtils.escapeJava(id)}\");" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 you could use """
or as string delimiters to avoid having to use escapes for \"
4ef7870
to
df2e94a
Compare
Signed-off-by: Pavlo Shevchenko <pshevchenko@gradle.com>
Signed-off-by: Pavlo Shevchenko <pshevchenko@gradle.com>
Signed-off-by: Pavlo Shevchenko <pshevchenko@gradle.com>
Signed-off-by: Pavlo Shevchenko <pshevchenko@gradle.com>
Signed-off-by: Pavlo Shevchenko <pshevchenko@gradle.com>
Signed-off-by: Pavlo Shevchenko <pshevchenko@gradle.com>
df2e94a
to
0ce11ad
Compare
Summary
If class setup fails, then test methods that failed in the previous execution won't be retried. In this case, we used to throw an error since we did not retry things that should be retried. This PR solves the issue by clearing the list of to-be-retried methods if class-level failure occurs. In this case, the entire class will be retried anyways, so it is safe to just clear that list. If previous run had other lifecycle errors, we track those to ensure we report successful execution of those.