Merge pull request #3456 from ethereum/testgen-fork-filter

Add `--fork-list` arg to testgen
This commit is contained in:
Danny Ryan 2023-07-18 08:01:25 -06:00 committed by GitHub
commit 79bfdad4d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -171,7 +171,6 @@ def run_generator(generator_name, test_providers: Iterable[TestProvider]):
help="if set re-generate and overwrite test files if they already exist",
)
parser.add_argument(
"-l",
"--preset-list",
dest="preset_list",
nargs='*',
@ -179,6 +178,14 @@ def run_generator(generator_name, test_providers: Iterable[TestProvider]):
required=False,
help="specify presets to run with. Allows all if no preset names are specified.",
)
parser.add_argument(
"--fork-list",
dest="fork_list",
nargs='*',
type=str,
required=False,
help="specify forks to run with. Allows all if no fork names are specified.",
)
parser.add_argument(
"-c",
"--collect-only",
@ -199,6 +206,7 @@ def run_generator(generator_name, test_providers: Iterable[TestProvider]):
print(f"Generating tests into {output_dir}")
print(f'Error log file: {log_file}')
# preset_list arg
presets = args.preset_list
if presets is None:
presets = []
@ -206,6 +214,14 @@ def run_generator(generator_name, test_providers: Iterable[TestProvider]):
if len(presets) != 0:
print(f"Filtering test-generator runs to only include presets: {', '.join(presets)}")
# fork_list arg
forks = args.fork_list
if forks is None:
forks = []
if len(presets) != 0:
print(f"Filtering test-generator runs to only include forks: {', '.join(forks)}")
collect_only = args.collect_only
diagnostics_obj = Diagnostics()
@ -224,6 +240,10 @@ def run_generator(generator_name, test_providers: Iterable[TestProvider]):
if len(presets) != 0 and test_case.preset_name not in presets:
continue
# If fork list is assigned, filter by forks.
if len(forks) != 0 and test_case.fork_name not in forks:
continue
case_dir = get_test_case_dir(test_case, output_dir)
print(f"Collected test at: {case_dir}")
diagnostics_obj.collected_test_count += 1