2021-07-09 06:15:32 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
# The purpose of this script is to compare a list of file names that were accessed during testing
|
2021-09-25 05:58:35 +00:00
|
|
|
# against all the file names in the consensus-spec-tests repository. It then checks to see which files
|
2021-07-09 06:15:32 +00:00
|
|
|
# were not accessed and returns an error if any non-intentionally-ignored files are detected.
|
|
|
|
#
|
|
|
|
# The ultimate goal is to detect any accidentally-missed spec tests.
|
|
|
|
|
|
|
|
import os
|
2021-09-24 04:55:21 +00:00
|
|
|
import re
|
2021-07-09 06:15:32 +00:00
|
|
|
import sys
|
|
|
|
|
|
|
|
# First argument should the path to a file which contains a list of accessed file names.
|
|
|
|
accessed_files_filename = sys.argv[1]
|
|
|
|
|
2021-09-25 05:58:35 +00:00
|
|
|
# Second argument should be the path to the consensus-spec-tests directory.
|
2021-07-09 06:15:32 +00:00
|
|
|
tests_dir_filename = sys.argv[2]
|
|
|
|
|
2021-09-25 05:58:35 +00:00
|
|
|
# If any of the file names found in the consensus-spec-tests directory *starts with* one of the
|
2021-09-24 04:55:21 +00:00
|
|
|
# following regular expressions, we will assume they are to be ignored (i.e., we are purposefully
|
|
|
|
# *not* running the spec tests).
|
2021-07-09 06:15:32 +00:00
|
|
|
excluded_paths = [
|
2021-09-28 04:20:06 +00:00
|
|
|
# Eth1Block and PowBlock
|
2021-07-09 06:15:32 +00:00
|
|
|
#
|
|
|
|
# Intentionally omitted, as per https://github.com/sigp/lighthouse/issues/1835
|
2021-09-24 04:55:21 +00:00
|
|
|
"tests/.*/.*/ssz_static/Eth1Block/",
|
2021-09-28 04:20:06 +00:00
|
|
|
"tests/.*/.*/ssz_static/PowBlock/",
|
2021-07-09 06:15:32 +00:00
|
|
|
# LightClientStore
|
2021-09-24 04:55:21 +00:00
|
|
|
"tests/.*/.*/ssz_static/LightClientStore",
|
2021-07-09 06:15:32 +00:00
|
|
|
# LightClientUpdate
|
2021-09-24 04:55:21 +00:00
|
|
|
"tests/.*/.*/ssz_static/LightClientUpdate",
|
2021-07-09 06:15:32 +00:00
|
|
|
# LightClientSnapshot
|
|
|
|
"tests/minimal/altair/ssz_static/LightClientSnapshot",
|
|
|
|
"tests/mainnet/altair/ssz_static/LightClientSnapshot",
|
2021-11-15 00:26:42 +00:00
|
|
|
"tests/minimal/merge/ssz_static/LightClientSnapshot",
|
|
|
|
"tests/mainnet/merge/ssz_static/LightClientSnapshot",
|
2021-10-16 05:07:21 +00:00
|
|
|
# Merkle-proof tests for light clients
|
2021-11-15 00:26:42 +00:00
|
|
|
"tests/mainnet/altair/merkle/single_proof",
|
|
|
|
"tests/minimal/altair/merkle/single_proof",
|
|
|
|
"tests/mainnet/merge/merkle/single_proof",
|
|
|
|
"tests/minimal/merge/merkle/single_proof",
|
2021-12-13 20:43:22 +00:00
|
|
|
# FIXME(merge): Merge transition tests are now available but not yet passing
|
|
|
|
"tests/mainnet/merge/transition/",
|
|
|
|
"tests/minimal/merge/transition/",
|
2021-07-09 06:15:32 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
def normalize_path(path):
|
2021-09-24 04:55:21 +00:00
|
|
|
return path.split("consensus-spec-tests/")[1]
|
2021-07-09 06:15:32 +00:00
|
|
|
|
|
|
|
# Determine the list of filenames which were accessed during tests.
|
|
|
|
passed = set()
|
|
|
|
for line in open(accessed_files_filename, 'r').readlines():
|
|
|
|
file = normalize_path(line.strip().strip('"'))
|
|
|
|
passed.add(file)
|
|
|
|
|
|
|
|
missed = set()
|
|
|
|
accessed_files = 0
|
|
|
|
excluded_files = 0
|
|
|
|
|
|
|
|
# Iterate all files in the tests directory, ensure that all files were either accessed
|
|
|
|
# or intentionally missed.
|
|
|
|
for root, dirs, files in os.walk(tests_dir_filename):
|
2021-09-24 04:55:21 +00:00
|
|
|
for name in files:
|
|
|
|
name = normalize_path(os.path.join(root, name))
|
|
|
|
if name not in passed:
|
|
|
|
excluded = False
|
|
|
|
for excluded_path_regex in excluded_paths:
|
|
|
|
if re.match(excluded_path_regex, name):
|
|
|
|
excluded = True
|
|
|
|
break
|
|
|
|
if excluded:
|
|
|
|
excluded_files += 1
|
|
|
|
else:
|
|
|
|
print(name)
|
|
|
|
missed.add(name)
|
|
|
|
else:
|
|
|
|
accessed_files += 1
|
2021-07-09 06:15:32 +00:00
|
|
|
|
|
|
|
# Exit with an error if there were any files missed.
|
|
|
|
assert len(missed) == 0, "{} missed files".format(len(missed))
|
|
|
|
|
|
|
|
print("Accessed {} files ({} intentionally excluded)".format(accessed_files, excluded_files))
|