14
14
15
15
package com .google .firebase .firestore .spec ;
16
16
17
+ import static com .google .common .base .Strings .emptyToNull ;
17
18
import static com .google .firebase .firestore .TestUtil .waitFor ;
18
19
import static com .google .firebase .firestore .testutil .TestUtil .ARBITRARY_SEQUENCE_NUMBER ;
19
20
import static com .google .firebase .firestore .testutil .TestUtil .deleteMutation ;
@@ -132,6 +133,14 @@ public abstract class SpecTestCase implements RemoteStoreCallback {
132
133
// this tag and they'll all be run (but all others won't).
133
134
private static final String EXCLUSIVE_TAG = "exclusive" ;
134
135
136
+ // The name of a Java system property ({@link System#getProperty(String)}) whose value is the name
137
+ // of the sole spec test to execute. This is an alternative to setting the {@link #EXCLUSIVE_TAG}
138
+ // tag, which requires modifying the JSON file. To use this property, specify
139
+ // -DexclusiveSpecTest=<TestName> to the Java runtime, replacing <TestName> with the name of the
140
+ // test to execute exclusively. The <TestName> value is the result of appending the "itName" of
141
+ // the test to its "describeName", separated by a space character.
142
+ private static final String EXCLUSIVE_PROPERTY = "exclusiveSpecTest" ;
143
+
135
144
// Tags on tests that should be excluded from execution, useful to allow the platforms to
136
145
// temporarily diverge or for features that are designed to be platform specific (such as
137
146
// 'multi-client').
@@ -1097,6 +1106,12 @@ public void testSpecTests() throws Exception {
1097
1106
parsedSpecFiles .add (new Pair <>(f .getName (), fileJSON ));
1098
1107
}
1099
1108
1109
+ String exclusiveTestNameFromSystemProperty =
1110
+ emptyToNull (System .getProperty (EXCLUSIVE_PROPERTY ));
1111
+ if (exclusiveTestNameFromSystemProperty != null ) {
1112
+ exclusiveMode = true ;
1113
+ }
1114
+
1100
1115
for (Pair <String , JSONObject > parsedSpecFile : parsedSpecFiles ) {
1101
1116
String fileName = parsedSpecFile .first ;
1102
1117
JSONObject fileJSON = parsedSpecFile .second ;
@@ -1115,7 +1130,17 @@ public void testSpecTests() throws Exception {
1115
1130
JSONArray steps = testJSON .getJSONArray ("steps" );
1116
1131
Set <String > tags = getTestTags (testJSON );
1117
1132
1118
- boolean runTest = shouldRunTest (tags ) && (!exclusiveMode || tags .contains (EXCLUSIVE_TAG ));
1133
+ boolean runTest ;
1134
+ if (!shouldRunTest (tags )) {
1135
+ runTest = false ;
1136
+ } else if (!exclusiveMode ) {
1137
+ runTest = true ;
1138
+ } else if (tags .contains (EXCLUSIVE_TAG )) {
1139
+ runTest = true ;
1140
+ } else {
1141
+ runTest = name .equals (exclusiveTestNameFromSystemProperty );
1142
+ }
1143
+
1119
1144
boolean measureRuntime = tags .contains (BENCHMARK_TAG );
1120
1145
if (runTest ) {
1121
1146
long start = System .currentTimeMillis ();
0 commit comments