unit-test: allow non-shell scripts for extensions
The unit-test script currently allows extension scripts of the
name 'run-ci.sh', but there are examples within openbmc where
the extensions are not actually shell (at least one is Python).
Remove the extension requirement on the script by looking both
for 'run-ci.sh' and 'run-ci'.
Tested the 'find_file' script with:
> find_file('run-ci', '.../openbmc-sources')
['.../openbmc-sources/phosphor-dbus-interfaces/run-ci']
> find_file('run-ci.sh', '.../openbmc-sources')
['.../openbmc-sources/phosphor-logging/extensions/openpower-pels/registry/run-ci.sh',
'.../openbmc-sources/phosphor-power/phosphor-regulators/test/run-ci.sh',
'.../openbmc-sources/entity-manager/scripts/run-ci.sh' ]
> find_file(['run-ci', 'run-ci.sh'], '.../openbmc-sources')
['.../openbmc-sources/phosphor-dbus-interfaces/run-ci',
'.../openbmc-sources/phosphor-logging/extensions/openpower-pels/registry/run-ci.sh',
'.../openbmc-sources/phosphor-power/phosphor-regulators/test/run-ci.sh',
'.../openbmc-sources/entity-manager/scripts/run-ci.sh']
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ib420c69e88e88ca0a50863c83ad43fac750d3e7a
diff --git a/scripts/unit-test.py b/scripts/unit-test.py
index e9553b3..79ae521 100755
--- a/scripts/unit-test.py
+++ b/scripts/unit-test.py
@@ -1040,18 +1040,23 @@
def find_file(filename, basedir):
"""
- Finds all occurrences of a file in the base directory
- and passes them back with their relative paths.
+ Finds all occurrences of a file (or list of files) in the base
+ directory and passes them back with their relative paths.
Parameter descriptions:
- filename The name of the file to find
+ filename The name of the file (or list of files) to
+ find
basedir The base directory search in
"""
+ if not isinstance(filename, list):
+ filename = [ filename ]
+
filepaths = []
for root, dirs, files in os.walk(basedir):
- if filename in files:
- filepaths.append(os.path.join(root, filename))
+ for f in filename:
+ if f in files:
+ filepaths.append(os.path.join(root, f))
return filepaths
@@ -1202,8 +1207,9 @@
# Run any custom CI scripts the repo has, of which there can be
# multiple of and anywhere in the repository.
- ci_scripts = find_file('run-ci.sh', os.path.join(WORKSPACE, UNIT_TEST_PKG))
+ ci_scripts = find_file(['run-ci.sh', 'run-ci'],
+ os.path.join(WORKSPACE, UNIT_TEST_PKG))
if ci_scripts:
os.chdir(os.path.join(WORKSPACE, UNIT_TEST_PKG))
for ci_script in ci_scripts:
- check_call_cmd('sh', ci_script)
+ check_call_cmd(ci_script)