Skip to content

Commit

Permalink
Add zap test inputs into convert_all script. Also add dry run for tes…
Browse files Browse the repository at this point in the history
…ting (#24526)
  • Loading branch information
andy31415 authored and pull[bot] committed Nov 7, 2023
1 parent a2234e4 commit 5917732
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions scripts/tools/zap_convert_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,30 @@ def checkPythonVersion():
exit(1)


zapFilesToSkip = [
zapFilesToSkip = {
# examples/chef/sample_app_util/test_files/sample_zap_file.zap is
# not a real .zap file; it's input to generating .zap files. So
# the path to zcl.json in it is just wrong, and we should skip it.
"examples/chef/sample_app_util/test_files/sample_zap_file.zap",
]
}


def getTargets():
ROOTS_TO_SEARCH = [
'./examples',
'./src/darwin',
'./src/controller/data_model',
'./scripts/tools/zap/tests/inputs',
]

targets = []
targets.extend([[str(filepath)]
for filepath in Path('./examples').rglob('*.zap')
if str(filepath) not in zapFilesToSkip])
targets.extend([[str(filepath)]
for filepath in Path('./src/darwin').rglob('*.zap')
if str(filepath) not in zapFilesToSkip])
targets.extend([[str(filepath)] for filepath in Path(
'./src/controller/data_model').rglob('*.zap')
if str(filepath) not in zapFilesToSkip])
for root in ROOTS_TO_SEARCH:
for filepath in Path(root).rglob('*.zap'):
path = str(filepath)
if path in zapFilesToSkip:
continue
targets.append(path)

return targets


Expand All @@ -62,7 +67,9 @@ def runArgumentsParser():
help='Automatically run ZAP bootstrap. By default the bootstrap is not triggered')
parser.add_argument('--parallel', action='store_true')
parser.add_argument('--no-parallel', action='store_false', dest='parallel')
parser.add_argument('--dry-run', action='store_true', dest='dry_run')
parser.set_defaults(parallel=True)
parser.set_defaults(dry_run=False)

return parser.parse_args()

Expand All @@ -85,6 +92,11 @@ def main():

targets = getTargets()

if args.dry_run:
for target in targets:
print(f"Should convert {target}")
sys.exit(0)

if args.parallel:
# Ensure each zap run is independent
os.environ['ZAP_TEMPSTATE'] = '1'
Expand Down

0 comments on commit 5917732

Please sign in to comment.