aboutsummaryrefslogtreecommitdiff
path: root/run_tests_for.py
diff options
context:
space:
mode:
authorGeorge Burgess IV <gbiv@google.com>2019-09-05 19:48:41 -0700
committerGeorge Burgess <gbiv@chromium.org>2019-09-06 03:39:40 +0000
commit367e8a932d78a4037bf0acdbc62fae8f3f46be99 (patch)
tree1133f77f1f3445e679f0c266ab05a1f4bcf91e92 /run_tests_for.py
parent93ca49fd74124884305c70636f7e71c662cb5b08 (diff)
downloadtoolchain-utils-367e8a932d78a4037bf0acdbc62fae8f3f46be99.tar.gz
run_tests_for: unbreak it on _unittest.py files
I forgot to do `base +`, so files ending in _unittest.py weren't being properly detected + run. While I'm in the area, unittests should probably count as their own unittests. Quote style fixes are enforced by `cros lint`, so this fixes those, too. BUG=None TEST=Ran on a _unittest file and a file with a _unittest Change-Id: I7ef984afef2f66203f9d2236c3f5021aac5d9acf Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1788666 Commit-Queue: George Burgess <gbiv@chromium.org> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Manoj Gupta <manojgupta@chromium.org> Tested-by: George Burgess <gbiv@chromium.org>
Diffstat (limited to 'run_tests_for.py')
-rwxr-xr-xrun_tests_for.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/run_tests_for.py b/run_tests_for.py
index 444020ce..6f77b12c 100755
--- a/run_tests_for.py
+++ b/run_tests_for.py
@@ -95,10 +95,15 @@ def _autodetect_python_tests_for(test_file):
if not test_file.endswith('.py'):
return []
- base = test_file[:-3]
- candidates = [base + '_test.py', '_unittest.py']
- tests_to_run = (c for c in candidates if os.path.exists(c))
- return [_python_test_to_spec(test_file) for test_file in tests_to_run]
+ test_suffixes = ['_test.py', '_unittest.py']
+ if any(test_file.endswith(x) for x in test_suffixes):
+ test_files = [test_file]
+ else:
+ base = test_file[:-3]
+ candidates = (base + x for x in test_suffixes)
+ test_files = (x for x in candidates if os.path.exists(x))
+
+ return [_python_test_to_spec(test_file) for test_file in test_files]
def _run_test_scripts(all_tests, show_successful_output=False):
@@ -198,8 +203,8 @@ def _find_go_tests(test_paths):
assert all(os.path.isabs(path) for path in test_paths)
dirs_with_gofiles = set(
- os.path.dirname(p) for p in test_paths if p.endswith(".go"))
- command = ["go", "test", "-vet=all"]
+ os.path.dirname(p) for p in test_paths if p.endswith('.go'))
+ command = ['go', 'test', '-vet=all']
# Note: We sort the directories to be deterministic.
return [
TestSpec(directory=d, command=command) for d in sorted(dirs_with_gofiles)