|
94 | 94 | import java.util.Map;
|
95 | 95 | import java.util.Set;
|
96 | 96 | import java.util.logging.Logger;
|
| 97 | +import java.util.regex.Pattern; |
97 | 98 | import java.util.stream.Stream;
|
98 | 99 | import javax.annotation.Nullable;
|
99 | 100 | import org.json.JSONArray;
|
@@ -133,13 +134,15 @@ public abstract class SpecTestCase implements RemoteStoreCallback {
|
133 | 134 | // this tag and they'll all be run (but all others won't).
|
134 | 135 | private static final String EXCLUSIVE_TAG = "exclusive";
|
135 | 136 |
|
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"; |
| 137 | + // The name of a Java system property ({@link System#getProperty(String)}) whose value is a filter |
| 138 | + // that specifies which tests to execute. The value of this property is a regular expression that |
| 139 | + // is matched against the name of each test. Using this property is an alternative to setting the |
| 140 | + // {@link #EXCLUSIVE_TAG} tag, which requires modifying the JSON file. To use this property, |
| 141 | + // specify -DspecTestFilter=<Regex> to the Java runtime, replacing <Regex> with a regular |
| 142 | + // expression; a test will be executed if and only if its name matches this regular expression. |
| 143 | + // In this context, a test's "name" is the result of appending its "itName" to its "describeName", |
| 144 | + // separated by a space character. |
| 145 | + private static final String TEST_FILTER_PROPERTY = "specTestFilter"; |
143 | 146 |
|
144 | 147 | // Tags on tests that should be excluded from execution, useful to allow the platforms to
|
145 | 148 | // temporarily diverge or for features that are designed to be platform specific (such as
|
@@ -1106,10 +1109,14 @@ public void testSpecTests() throws Exception {
|
1106 | 1109 | parsedSpecFiles.add(new Pair<>(f.getName(), fileJSON));
|
1107 | 1110 | }
|
1108 | 1111 |
|
1109 |
| - String exclusiveTestNameFromSystemProperty = |
1110 |
| - emptyToNull(System.getProperty(EXCLUSIVE_PROPERTY)); |
1111 |
| - if (exclusiveTestNameFromSystemProperty != null) { |
| 1112 | + String testNameFilterFromSystemProperty = |
| 1113 | + emptyToNull(System.getProperty(TEST_FILTER_PROPERTY)); |
| 1114 | + Pattern testNameFilter; |
| 1115 | + if (testNameFilterFromSystemProperty == null) { |
| 1116 | + testNameFilter = null; |
| 1117 | + } else { |
1112 | 1118 | exclusiveMode = true;
|
| 1119 | + testNameFilter = Pattern.compile(testNameFilterFromSystemProperty); |
1113 | 1120 | }
|
1114 | 1121 |
|
1115 | 1122 | for (Pair<String, JSONObject> parsedSpecFile : parsedSpecFiles) {
|
@@ -1137,8 +1144,10 @@ public void testSpecTests() throws Exception {
|
1137 | 1144 | runTest = true;
|
1138 | 1145 | } else if (tags.contains(EXCLUSIVE_TAG)) {
|
1139 | 1146 | runTest = true;
|
| 1147 | + } else if (testNameFilter != null) { |
| 1148 | + runTest = testNameFilter.matcher(name).find(); |
1140 | 1149 | } else {
|
1141 |
| - runTest = name.equals(exclusiveTestNameFromSystemProperty); |
| 1150 | + runTest = false; |
1142 | 1151 | }
|
1143 | 1152 |
|
1144 | 1153 | boolean measureRuntime = tags.contains(BENCHMARK_TAG);
|
|
0 commit comments