Fix issue finding the configuration file name ends with ".config"
The original regular expression ".*.config" will matches
"-config" b/c "." stands for matching any single character.
Bug: 117477582
Test: presubmit pass.
Change-Id: Ibb485db009ea53c393d1e1a7c6e5a2e12c2f1612
diff --git a/prod-tests/src/com/android/tradefed/presubmit/DeviceTestsConfigValidation.java b/prod-tests/src/com/android/tradefed/presubmit/DeviceTestsConfigValidation.java
index cf1dfb8..aa94674 100644
--- a/prod-tests/src/com/android/tradefed/presubmit/DeviceTestsConfigValidation.java
+++ b/prod-tests/src/com/android/tradefed/presubmit/DeviceTestsConfigValidation.java
@@ -67,7 +67,7 @@
// Only load the .config as .xml might be data in device-tests.zip case.
configs.addAll(
ConfigurationUtil.getConfigNamesFileFromDirs(
- null, extraTestCasesDirs, Arrays.asList(".*.config")));
+ null, extraTestCasesDirs, Arrays.asList(".*\\.config$")));
for (File config : configs) {
try {
IConfiguration c =
diff --git a/res/config/suite/apct.xml b/res/config/suite/apct.xml
index a43bcd1..761e90f 100644
--- a/res/config/suite/apct.xml
+++ b/res/config/suite/apct.xml
@@ -6,6 +6,6 @@
<!-- Do not load from the Jar's resources, only from the tests dir -->
<option name="skip-loading-config-jar" value="true" />
<!-- Explicitly requests only AndroidTest modules -->
- <option name="config-patterns" value=".*.config" />
+ <option name="config-patterns" value=".*\.config$" />
</test>
</configuration>
diff --git a/src/com/android/tradefed/config/ConfigurationUtil.java b/src/com/android/tradefed/config/ConfigurationUtil.java
index 63f1181..75b0bc1 100644
--- a/src/com/android/tradefed/config/ConfigurationUtil.java
+++ b/src/com/android/tradefed/config/ConfigurationUtil.java
@@ -175,8 +175,8 @@
*/
public static Set<File> getConfigNamesFileFromDirs(String subPath, List<File> dirs) {
List<String> patterns = new ArrayList<>();
- patterns.add(".*.config");
- patterns.add(".*.xml");
+ patterns.add(".*\\.config$");
+ patterns.add(".*\\.xml$");
return getConfigNamesFileFromDirs(subPath, dirs, patterns);
}
diff --git a/src/com/android/tradefed/testtype/suite/BaseTestSuite.java b/src/com/android/tradefed/testtype/suite/BaseTestSuite.java
index 14577ba..cc5abe2 100644
--- a/src/com/android/tradefed/testtype/suite/BaseTestSuite.java
+++ b/src/com/android/tradefed/testtype/suite/BaseTestSuite.java
@@ -226,8 +226,8 @@
// Load the configs that are part of the tests dir
if (mConfigPatterns.isEmpty()) {
// If no special pattern was configured, use the default configuration patterns we know
- mConfigPatterns.add(".*\\.config");
- mConfigPatterns.add(".*\\.xml");
+ mConfigPatterns.add(".*\\.config$");
+ mConfigPatterns.add(".*\\.xml$");
}
loadedConfigs.putAll(