-
Notifications
You must be signed in to change notification settings - Fork 624
Add support for -DexclusiveSpecTest=<TestName> to SpecTestCase. #1367
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
Conversation
Binary Size ReportAffected SDKs
Test Logs |
Codecov Report
Continue to review full report at Codecov.
|
// -DexclusiveSpecTest=<TestName> to the Java runtime, replacing <TestName> with the name of the | ||
// test to execute exclusively. The <TestName> value is the result of appending the "itName" of | ||
// the test to its "describeName", separated by a space character. | ||
private static final String EXCLUSIVE_PROPERTY = "exclusiveSpecTest"; |
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.
What do you think of making this a filter and allowing Regular Expressions? It should maybe add one or two lines to this PR, but make this feature much easier to use (we don't have to specify the full test name) and more flexible (we could run a group of tests).
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.
SGTM. I'll make this change.
@@ -1097,6 +1106,12 @@ public void testSpecTests() throws Exception { | |||
parsedSpecFiles.add(new Pair<>(f.getName(), fileJSON)); | |||
} | |||
|
|||
String exclusiveTestNameFromSystemProperty = | |||
emptyToNull(System.getProperty(EXCLUSIVE_PROPERTY)); |
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.
If you go with regular expression approach, this could be System.getProperty(EXCLUSIVE_PROPERTY, ".*")
, in which case you can always apply the filter.
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 won't work though because I need to be able to distinguish between the property being set or not being set. The reason is that if it is set then exclusiveMode
must be set to true
and if it is not then it must be left alone. By using a default value I cannot know if .* was specified explicitly or was the default value.
@@ -14,6 +14,7 @@ | |||
|
|||
package com.google.firebase.firestore.spec; | |||
|
|||
import static com.google.common.base.Strings.emptyToNull; |
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.
We should try not to import more Guava dependencies, unless we want to make an exception for tests (cc @wu-hui).
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.
In my opinion, and exception for tests makes a lot of sense since there are no downstream dependencies on the test artifacts that could result in dependency mismatch conflicts. Moreover, this class already imports com.google.common.collect.Sets
from guava, so this is not a net new dependency on guava.
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.
I am OK to import Guava in tests.
And thanks for adding this, will be really handy to try to debug a specific test.
@dconeybe: The following test failed, say
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
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.
LGTM. If you feel like it, I think we
} else if (tags.contains(EXCLUSIVE_TAG)) { | ||
runTest = true; | ||
} else if (testNameFilter != null) { | ||
runTest = testNameFilter.matcher(name).find(); |
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.
Optional: This could just be
} else {
runTest = testNameMatcher.matches(find);
}
@@ -1097,6 +1109,16 @@ public void testSpecTests() throws Exception { | |||
parsedSpecFiles.add(new Pair<>(f.getName(), fileJSON)); | |||
} | |||
|
|||
String testNameFilterFromSystemProperty = | |||
emptyToNull(System.getProperty(TEST_FILTER_PROPERTY)); | |||
Pattern testNameFilter; |
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 should turn this into a Matcher right away, like such:
if (testNameFilterFromSystemProperty == null) {
testNameFilterFromSystemProperty = ".*";
} else {
exclusiveMode = true;
}
Matcher testNameMatcher = Pattern.compile(testNameFilterFromSystemProperty).matcher();
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.
A Matcher object must be created with a string against which to match. So we must create a new Matcher object for each test name.
https://developer.android.com/reference/java/util/regex/Pattern#matcher(java.lang.CharSequence)
Thank you for the review, @schmidt-sebastian! |
No description provided.