Use listdir instead of glob when expading directories.
Glob was returning directories and files when the module is expected to
operate in files only.
Change-Id: I6aad774223467bc20e8728cba3b5f0f53b3f65e4
Reviewed-on: https://flutter-review.googlesource.com/c/recipes/+/35181
Reviewed-by: Yusuf Mohsinally <mohsinally@google.com>
Commit-Queue: Godofredo Contreras <godofredoc@google.com>
diff --git a/recipe_modules/archives/api.py b/recipe_modules/archives/api.py
index f3590eb..c3e093d 100644
--- a/recipe_modules/archives/api.py
+++ b/recipe_modules/archives/api.py
@@ -20,6 +20,18 @@
# Used for mock paths
DIRECTORY = 'DIRECTORY'
+# Relative paths used to mock paths for testing.
+MOCK_JAR_PATH = (
+ 'io/flutter/x86_debug/'
+ '1.0.0-0005149dca9b248663adcde4bdd7c6c915a76584/'
+ 'x86_debug-1.0.0-0005149dca9b248663adcde4bdd7c6c915a76584.jar'
+)
+MOCK_POM_PATH = (
+ 'io/flutter/x86_debug/'
+ '1.0.0-0005149dca9b248663adcde4bdd7c6c915a76584/'
+ 'x86_debug-1.0.0-0005149dca9b248663adcde4bdd7c6c915a76584.pom'
+)
+
class ArchivesApi(recipe_api.RecipeApi):
"""Api to handle archives from engine_v2 recipes."""
@@ -46,20 +58,11 @@
full_include_path = self.m.path.abspath(checkout.join(include_path))
if self.m.path.isdir(full_include_path):
test_data = [
- (
- 'io/flutter/x86_debug/'
- '1.0.0-0005149dca9b248663adcde4bdd7c6c915a76584/'
- 'x86_debug-1.0.0-0005149dca9b248663adcde4bdd7c6c915a76584.jar'),
- (
- 'io/flutter/x86_debug/'
- '1.0.0-0005149dca9b248663adcde4bdd7c6c915a76584/'
- 'x86_debug-1.0.0-0005149dca9b248663adcde4bdd7c6c915a76584.pom'),
]
- paths = self.m.file.glob_paths(
+ paths = self.m.file.listdir(
'Expand directory', checkout.join(include_path),
- '**', test_data=test_data
- )
+ recursive=True, test_data=(MOCK_JAR_PATH, MOCK_POM_PATH))
paths = [self.m.path.abspath(p) for p in paths]
results.extend(paths)
else:
diff --git a/recipe_modules/archives/examples/full.expected/basic.json b/recipe_modules/archives/examples/full.expected/basic.json
index 715e413..77b7707 100644
--- a/recipe_modules/archives/examples/full.expected/basic.json
+++ b/recipe_modules/archives/examples/full.expected/basic.json
@@ -6,16 +6,16 @@
"RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
"--json-output",
"/path/to/tmp/json",
- "glob",
+ "listdir",
"[START_DIR]/out/android_profile/zip_archives/download.flutter.io",
- "**"
+ "--recursive"
],
"infra_step": true,
"name": "Expand directory",
"~followup_annotations": [
- "@@@STEP_LOG_LINE@glob@[START_DIR]/out/android_profile/zip_archives/download.flutter.io/io/flutter/x86_debug/1.0.0-0005149dca9b248663adcde4bdd7c6c915a76584/x86_debug-1.0.0-0005149dca9b248663adcde4bdd7c6c915a76584.jar@@@",
- "@@@STEP_LOG_LINE@glob@[START_DIR]/out/android_profile/zip_archives/download.flutter.io/io/flutter/x86_debug/1.0.0-0005149dca9b248663adcde4bdd7c6c915a76584/x86_debug-1.0.0-0005149dca9b248663adcde4bdd7c6c915a76584.pom@@@",
- "@@@STEP_LOG_END@glob@@@"
+ "@@@STEP_LOG_LINE@listdir@[START_DIR]/out/android_profile/zip_archives/download.flutter.io/io/flutter/x86_debug/1.0.0-0005149dca9b248663adcde4bdd7c6c915a76584/x86_debug-1.0.0-0005149dca9b248663adcde4bdd7c6c915a76584.jar@@@",
+ "@@@STEP_LOG_LINE@listdir@[START_DIR]/out/android_profile/zip_archives/download.flutter.io/io/flutter/x86_debug/1.0.0-0005149dca9b248663adcde4bdd7c6c915a76584/x86_debug-1.0.0-0005149dca9b248663adcde4bdd7c6c915a76584.pom@@@",
+ "@@@STEP_LOG_END@listdir@@@"
]
},
{
diff --git a/recipe_modules/archives/examples/full.expected/monorepo_gcs.json b/recipe_modules/archives/examples/full.expected/monorepo_gcs.json
index ca03f20..68407c6 100644
--- a/recipe_modules/archives/examples/full.expected/monorepo_gcs.json
+++ b/recipe_modules/archives/examples/full.expected/monorepo_gcs.json
@@ -6,9 +6,9 @@
"RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
"--json-output",
"/path/to/tmp/json",
- "glob",
+ "listdir",
"[START_DIR]/out/android_profile/zip_archives/download.flutter.io",
- "**"
+ "--recursive"
],
"infra_step": true,
"luci_context": {
@@ -25,9 +25,9 @@
},
"name": "Expand directory",
"~followup_annotations": [
- "@@@STEP_LOG_LINE@glob@[START_DIR]/out/android_profile/zip_archives/download.flutter.io/io/flutter/x86_debug/1.0.0-0005149dca9b248663adcde4bdd7c6c915a76584/x86_debug-1.0.0-0005149dca9b248663adcde4bdd7c6c915a76584.jar@@@",
- "@@@STEP_LOG_LINE@glob@[START_DIR]/out/android_profile/zip_archives/download.flutter.io/io/flutter/x86_debug/1.0.0-0005149dca9b248663adcde4bdd7c6c915a76584/x86_debug-1.0.0-0005149dca9b248663adcde4bdd7c6c915a76584.pom@@@",
- "@@@STEP_LOG_END@glob@@@"
+ "@@@STEP_LOG_LINE@listdir@[START_DIR]/out/android_profile/zip_archives/download.flutter.io/io/flutter/x86_debug/1.0.0-0005149dca9b248663adcde4bdd7c6c915a76584/x86_debug-1.0.0-0005149dca9b248663adcde4bdd7c6c915a76584.jar@@@",
+ "@@@STEP_LOG_LINE@listdir@[START_DIR]/out/android_profile/zip_archives/download.flutter.io/io/flutter/x86_debug/1.0.0-0005149dca9b248663adcde4bdd7c6c915a76584/x86_debug-1.0.0-0005149dca9b248663adcde4bdd7c6c915a76584.pom@@@",
+ "@@@STEP_LOG_END@listdir@@@"
]
},
{