Skip to content

Make sure TestDef is created and used only when there is enough data to do that #1578

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

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -117,6 +117,7 @@ public abstract class UnifiedTest {
private UnifiedTestContext rootContext;
private boolean ignoreExtraEvents;
private BsonDocument startingClusterTime;
@Nullable
private TestDef testDef;

private class UnifiedTestContext {
@@ -215,11 +216,13 @@ public void setUp(
rootContext = new UnifiedTestContext();
rootContext.getAssertionContext().push(ContextElement.ofTest(definition));
ignoreExtraEvents = false;
testDef = testDef(directoryName, fileDescription, testDescription, isReactive());
UnifiedTestModifications.doSkips(testDef);
if (directoryName != null && fileDescription != null && testDescription != null) {
testDef = testDef(directoryName, fileDescription, testDescription, isReactive());
UnifiedTestModifications.doSkips(testDef);

boolean skip = testDef.wasAssignedModifier(UnifiedTestModifications.Modifier.SKIP);
assumeFalse(skip, "Skipping test");
boolean skip = testDef.wasAssignedModifier(UnifiedTestModifications.Modifier.SKIP);
assumeFalse(skip, "Skipping test");
}
skips(fileDescription, testDescription);

assertTrue(
@@ -268,8 +271,9 @@ public void setUp(
this::createMongoClient,
this::createGridFSBucket,
this::createClientEncryption);

postSetUp(testDef);
if (testDef != null) {
postSetUp(testDef);
}
}

protected void postSetUp(final TestDef def) {
@@ -281,7 +285,9 @@ public void cleanUp() {
failPoint.disableFailPoint();
}
entities.close();
postCleanUp(testDef);
if (testDef != null) {
postCleanUp(testDef);
}
}

protected void postCleanUp(final TestDef testDef) {
Original file line number Diff line number Diff line change
@@ -281,9 +281,9 @@ public static final class TestDef {
private final List<Modifier> modifiers = new ArrayList<>();

private TestDef(final String dir, final String file, final String test, final boolean reactive) {
this.dir = dir;
this.file = file;
this.test = test;
this.dir = assertNotNull(dir);
this.file = assertNotNull(file);
this.test = assertNotNull(test);
this.reactive = reactive;
}