summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Massey <aaronmassey@google.com>2022-10-04 14:14:44 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-10-04 23:25:15 +0000
commit8d9485e5413fe68690a1e91821dd15ad24d20eb3 (patch)
tree94ef85d50499f5180e95064d302bb709a79fbca6
parentfae4f102c3f74b14cebb579a79180ea78d5eb605 (diff)
downloadchrome-ec-8d9485e5413fe68690a1e91821dd15ad24d20eb3.tar.gz
twister_tags.py: Fix err if deleted yamls
When a testcase.yaml file gets deleted, twister_tags.py is invoked with the --validate-files option with no argument. This causes a crash due to a missing argument argparse exception. Also when twister_tags.py is invoked with moved testcase.yaml files, it attempts to parse yamls that no longer exist. Make --validate-files with no arguments a noop and check if a testcase.yaml exists before attempting to validate its tags. BRANCH=none BUG=none TEST=repo upload TEST=./util/twister_tags.py --validate-files Signed-off-by: Aaron Massey <aaronmassey@google.com> Change-Id: Idc4f9c44717826d59e59c6ca0627374c1c7eb0e5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3935030 Commit-Queue: Yuval Peress <peress@google.com> Reviewed-by: Yuval Peress <peress@google.com>
-rwxr-xr-xutil/twister_tags.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/util/twister_tags.py b/util/twister_tags.py
index c90ee80d25..692fdc1e99 100755
--- a/util/twister_tags.py
+++ b/util/twister_tags.py
@@ -19,6 +19,7 @@ testcase.yaml files to see if they only used predefined tags.
import argparse
import logging
import os
+import pathlib
import sys
import yaml # pylint: disable=import-error
@@ -37,7 +38,7 @@ def main(args):
"""List and/or validate testcase.yaml tags."""
parser = argparse.ArgumentParser()
parser.add_argument("-l", "--list-tags", action="store_true")
- parser.add_argument("--validate-files", nargs="+", type=str)
+ parser.add_argument("--validate-files", nargs="*", type=pathlib.Path)
args = parser.parse_args()
list_tags = args.list_tags
@@ -58,7 +59,8 @@ def main(args):
for validated_file in validate_files:
if os.path.basename(validated_file) == "testcase.yaml":
- testcase_yamls.append(validated_file)
+ if validated_file.exists():
+ testcase_yamls.append(validated_file)
def test_tags_generator(root):
"""Returns space separated tags denoted by a tags key"""