From 3bf05291d9bebf08e7afc2013e1e65ea84e7e08e Mon Sep 17 00:00:00 2001 From: danceratopz Date: Wed, 29 May 2024 23:57:38 +0200 Subject: [PATCH 01/13] feat(fw): write test class and function docstrings to the fixture _info --- .../spec/base/base_test.py | 2 ++ src/pytest_plugins/test_filler/test_filler.py | 21 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/ethereum_test_tools/spec/base/base_test.py b/src/ethereum_test_tools/spec/base/base_test.py index 5001508b442..17f03de6521 100644 --- a/src/ethereum_test_tools/spec/base/base_test.py +++ b/src/ethereum_test_tools/spec/base/base_test.py @@ -100,6 +100,7 @@ def json_dict_with_info(self, hash_only: bool = False) -> Dict[str, Any]: def fill_info( self, t8n: TransitionTool, + fixture_description: str, ref_spec: ReferenceSpec | None, ): """ @@ -108,6 +109,7 @@ def fill_info( if "comment" not in self.info: self.info["comment"] = "`execution-spec-tests` generated test" self.info["filling-transition-tool"] = t8n.version() + self.info["description"] = fixture_description if ref_spec is not None: ref_spec.write_info(self.info) diff --git a/src/pytest_plugins/test_filler/test_filler.py b/src/pytest_plugins/test_filler/test_filler.py index e8522b4b1ce..d14259fcdcf 100644 --- a/src/pytest_plugins/test_filler/test_filler.py +++ b/src/pytest_plugins/test_filler/test_filler.py @@ -559,6 +559,24 @@ def node_to_test_info(node) -> TestInfo: ) +@pytest.fixture(scope="function") +def fixture_description(request): + """Fixture to extract and combine docstrings from the test class and the test function.""" + description_unavailable = ( + "No description available - add a docstring to the python test class or function." + ) + test_class_doc = f"Test class documentation:\n{request.cls.__doc__}" if request.cls else "" + test_function_doc = ( + f"Test function documentation:\n{request.function.__doc__}" + if request.function.__doc__ + else "" + ) + if not test_class_doc and not test_function_doc: + return description_unavailable + combined_docstring = f"{test_class_doc}\n\n{test_function_doc}".strip() + return combined_docstring + + def base_test_parametrizer(cls: Type[BaseTest]): """ Generates a pytest.fixture for a given BaseTest subclass. @@ -579,6 +597,7 @@ def base_test_parametrizer_func( eips, dump_dir_parameter_level, fixture_collector, + fixture_description, ): """ Fixture used to instantiate an auto-fillable BaseTest object from within @@ -603,7 +622,7 @@ def __init__(self, *args, **kwargs): fixture_format=fixture_format, eips=eips, ) - fixture.fill_info(t8n, reference_spec) + fixture.fill_info(t8n, fixture_description, ref_spec=reference_spec) fixture_path = fixture_collector.add_fixture( node_to_test_info(request.node), From 826425cf5b1215f285027746d116c72f04bae44c Mon Sep 17 00:00:00 2001 From: danceratopz Date: Thu, 30 May 2024 00:00:02 +0200 Subject: [PATCH 02/13] feat(consume): propagate the test fixture description to the hive test report --- src/pytest_plugins/consume/simulator_common.py | 10 ++++++++++ src/pytest_plugins/pytest_hive/pytest_hive.py | 10 ++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/pytest_plugins/consume/simulator_common.py b/src/pytest_plugins/consume/simulator_common.py index e8f4b7d2f73..6563e5bb9a0 100644 --- a/src/pytest_plugins/consume/simulator_common.py +++ b/src/pytest_plugins/consume/simulator_common.py @@ -36,3 +36,13 @@ def fixture(fixture_source: JsonSource, test_case: TestCase) -> Fixture: fixtures = BlockchainFixtures.from_file(Path(fixture_source) / test_case.json_path) fixture = fixtures[test_case.id] return fixture + + +@pytest.fixture(scope="function") +def fixture_description(fixture: Fixture) -> str: + """ + Return the description of the current test case. + """ + if "description" not in fixture.info: + return "No description field provided in the fixture's 'info' section." + return fixture.info["description"] diff --git a/src/pytest_plugins/pytest_hive/pytest_hive.py b/src/pytest_plugins/pytest_hive/pytest_hive.py index 28537675d51..db01e58094d 100644 --- a/src/pytest_plugins/pytest_hive/pytest_hive.py +++ b/src/pytest_plugins/pytest_hive/pytest_hive.py @@ -107,11 +107,17 @@ def hive_test(request, test_suite: HiveTestSuite): """ Propagate the pytest test case and its result to the hive server. """ + try: + fixture_description = request.getfixturevalue("fixture_description") + except pytest.FixtureLookupError: + pytest.exit( + "Error: The 'fixture_description' fixture has not been defined by the simulator " + "or pytest plugin using this plugin!" + ) test_parameter_string = request.node.nodeid.split("[")[-1].rstrip("]") # test fixture name test: HiveTest = test_suite.start_test( - # TODO: pass test case documentation when available name=test_parameter_string, - description="TODO: This should come from the '_info' field.", + description=fixture_description, ) yield test try: From bbe0c20fc2ba410a26a5aea9a8d213668d40c023 Mon Sep 17 00:00:00 2001 From: danceratopz Date: Thu, 30 May 2024 00:43:01 +0200 Subject: [PATCH 03/13] feat(consume): prepend the test id to the test description --- src/pytest_plugins/consume/simulator_common.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pytest_plugins/consume/simulator_common.py b/src/pytest_plugins/consume/simulator_common.py index 6563e5bb9a0..02278b3f3be 100644 --- a/src/pytest_plugins/consume/simulator_common.py +++ b/src/pytest_plugins/consume/simulator_common.py @@ -39,10 +39,11 @@ def fixture(fixture_source: JsonSource, test_case: TestCase) -> Fixture: @pytest.fixture(scope="function") -def fixture_description(fixture: Fixture) -> str: +def fixture_description(fixture: Fixture, test_case: TestCase) -> str: """ Return the description of the current test case. """ if "description" not in fixture.info: return "No description field provided in the fixture's 'info' section." - return fixture.info["description"] + description = f"Test id: {test_case.id}\n\n{fixture.info['description']}" + return description From 9c3b4f52d183c5f8484a9846f715c860892fc5ac Mon Sep 17 00:00:00 2001 From: danceratopz Date: Thu, 30 May 2024 00:46:18 +0200 Subject: [PATCH 04/13] refactor(docs|fw): move utility functions to ethereum_test_tools.utility --- docs/gen_test_case_reference.py | 43 ++---------------- setup.cfg | 2 +- src/ethereum_test_tools/utility/__init__.py | 3 ++ src/ethereum_test_tools/utility/versioning.py | 45 +++++++++++++++++++ 4 files changed, 53 insertions(+), 40 deletions(-) create mode 100644 src/ethereum_test_tools/utility/__init__.py create mode 100644 src/ethereum_test_tools/utility/versioning.py diff --git a/docs/gen_test_case_reference.py b/docs/gen_test_case_reference.py index d2f4102e095..9db310ba36c 100644 --- a/docs/gen_test_case_reference.py +++ b/docs/gen_test_case_reference.py @@ -16,9 +16,12 @@ import mkdocs_gen_files import pytest -from git import Repo from ethereum_test_forks import get_development_forks, get_forks +from ethereum_test_tools.utility.versioning import ( + generate_github_url, + get_current_commit_hash_or_tag, +) logger = logging.getLogger("mkdocs") @@ -203,44 +206,6 @@ def run_collect_only(test_path: Path = source_directory) -> Tuple[str, str]: return collect_only_command, collect_only_output -def generate_github_url(file_path, branch_or_commit_or_tag="main"): - """ - Generate a link to a source file in Github. - """ - base_url = "https://github.com" - username = "ethereum" - repository = "execution-spec-tests" - if re.match( - r"^v[0-9]{1,2}\.[0-9]{1,3}\.[0-9]{1,3}(a[0-9]+|b[0-9]+|rc[0-9]+)?$", - branch_or_commit_or_tag, - ): - return f"{base_url}/{username}/{repository}/tree/{branch_or_commit_or_tag}/{file_path}" - else: - return f"{base_url}/{username}/{repository}/blob/{branch_or_commit_or_tag}/{file_path}" - - -def get_current_commit_hash_or_tag(repo_path="."): - """ - Get the latest commit hash or tag from the clone where doc is being built. - """ - repo = Repo(repo_path) - try: - # Get the tag that points to the current commit - current_tag = next((tag for tag in repo.tags if tag.commit == repo.head.commit)) - return current_tag.name - except StopIteration: - # If there are no tags that point to the current commit, return the commit hash - return repo.head.commit.hexsha - - -def get_current_commit_hash(repo_path="."): - """ - Get the latest commit hash from the clone where doc is being built. - """ - repo = Repo(repo_path) - return repo.head.commit.hexsha - - COMMIT_HASH_OR_TAG = get_current_commit_hash_or_tag() diff --git a/setup.cfg b/setup.cfg index 659c91453e2..a296760b6e1 100644 --- a/setup.cfg +++ b/setup.cfg @@ -28,6 +28,7 @@ install_requires = hive.py@git+https://github.com/danceratopz/hive.py@chore/setup.cfg/move-mypy-deps-to-lint-extras setuptools types-setuptools + gitpython>=3.1.31,<4 PyJWT>=2.3.0,<3 tenacity>8.2.0,<9 bidict>=0.23,<1 @@ -87,7 +88,6 @@ lint = docs = cairosvg>=2.7.0,<3 # required for social plugin (material) - gitpython>=3.1.31,<4 mike>=1.1.2,<2 mkdocs>=1.4.3,<2 mkdocs-gen-files>=0.5.0,<1 diff --git a/src/ethereum_test_tools/utility/__init__.py b/src/ethereum_test_tools/utility/__init__.py new file mode 100644 index 00000000000..90717b92579 --- /dev/null +++ b/src/ethereum_test_tools/utility/__init__.py @@ -0,0 +1,3 @@ +""" +Sub-package for utility functions and classes. +""" diff --git a/src/ethereum_test_tools/utility/versioning.py b/src/ethereum_test_tools/utility/versioning.py new file mode 100644 index 00000000000..7cfbfd074c0 --- /dev/null +++ b/src/ethereum_test_tools/utility/versioning.py @@ -0,0 +1,45 @@ +""" +Utility module with helper functions for versioning. +""" + +import re + +from git import Repo # type: ignore + + +def get_current_commit_hash_or_tag(repo_path="."): + """ + Get the latest commit hash or tag from the clone where doc is being built. + """ + repo = Repo(repo_path) + try: + # Get the tag that points to the current commit + current_tag = next((tag for tag in repo.tags if tag.commit == repo.head.commit)) + return current_tag.name + except StopIteration: + # If there are no tags that point to the current commit, return the commit hash + return repo.head.commit.hexsha + + +def generate_github_url(file_path, branch_or_commit_or_tag="main", line_number=""): + """ + Generate a permalink to a source file in Github. + """ + base_url = "https://github.com" + username = "ethereum" + repository = "execution-spec-tests" + if line_number: + line_number = f"#L{line_number}" + if re.match( + r"^v[0-9]{1,2}\.[0-9]{1,3}\.[0-9]{1,3}(a[0-9]+|b[0-9]+|rc[0-9]+)?$", + branch_or_commit_or_tag, + ): + return ( + f"{base_url}/{username}/{repository}/tree/" + f"{branch_or_commit_or_tag}/{file_path}{line_number}" + ) + else: + return ( + f"{base_url}/{username}/{repository}/blob/" + f"{branch_or_commit_or_tag}/{file_path}{line_number}" + ) From dd95019ff08da92eb5e84ef3effaa68482a95eeb Mon Sep 17 00:00:00 2001 From: danceratopz Date: Thu, 30 May 2024 00:52:01 +0200 Subject: [PATCH 05/13] feat(fill): add test function github permalink to _info['url'] --- .../spec/base/base_test.py | 2 ++ src/pytest_plugins/test_filler/test_filler.py | 26 ++++++++++++++++++- whitelist.txt | 1 + 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/ethereum_test_tools/spec/base/base_test.py b/src/ethereum_test_tools/spec/base/base_test.py index 17f03de6521..fbd7021b87a 100644 --- a/src/ethereum_test_tools/spec/base/base_test.py +++ b/src/ethereum_test_tools/spec/base/base_test.py @@ -101,6 +101,7 @@ def fill_info( self, t8n: TransitionTool, fixture_description: str, + fixture_source_url: str, ref_spec: ReferenceSpec | None, ): """ @@ -110,6 +111,7 @@ def fill_info( self.info["comment"] = "`execution-spec-tests` generated test" self.info["filling-transition-tool"] = t8n.version() self.info["description"] = fixture_description + self.info["url"] = fixture_source_url if ref_spec is not None: ref_spec.write_info(self.info) diff --git a/src/pytest_plugins/test_filler/test_filler.py b/src/pytest_plugins/test_filler/test_filler.py index d14259fcdcf..246655376e2 100644 --- a/src/pytest_plugins/test_filler/test_filler.py +++ b/src/pytest_plugins/test_filler/test_filler.py @@ -22,6 +22,10 @@ get_forks_with_solc_support, ) from ethereum_test_tools import SPEC_TYPES, BaseTest, FixtureCollector, TestInfo, Yul +from ethereum_test_tools.utility.versioning import ( + generate_github_url, + get_current_commit_hash_or_tag, +) from evm_transition_tool import FixtureFormats, TransitionTool from pytest_plugins.spec_version_checker.spec_version_checker import EIPSpecTestItem @@ -559,6 +563,20 @@ def node_to_test_info(node) -> TestInfo: ) +@pytest.fixture(scope="function") +def fixture_source_url(request): + """ + Returns the URL to the fixture source. + """ + function_line_number = request.function.__code__.co_firstlineno + module_relative_path = os.path.relpath(request.module.__file__) + hash_or_tag = get_current_commit_hash_or_tag() + github_url = generate_github_url( + module_relative_path, branch_or_commit_or_tag=hash_or_tag, line_number=function_line_number + ) + return github_url + + @pytest.fixture(scope="function") def fixture_description(request): """Fixture to extract and combine docstrings from the test class and the test function.""" @@ -598,6 +616,7 @@ def base_test_parametrizer_func( dump_dir_parameter_level, fixture_collector, fixture_description, + fixture_source_url, ): """ Fixture used to instantiate an auto-fillable BaseTest object from within @@ -622,7 +641,12 @@ def __init__(self, *args, **kwargs): fixture_format=fixture_format, eips=eips, ) - fixture.fill_info(t8n, fixture_description, ref_spec=reference_spec) + fixture.fill_info( + t8n, + fixture_description, + fixture_source_url=fixture_source_url, + ref_spec=reference_spec, + ) fixture_path = fixture_collector.add_fixture( node_to_test_info(request.node), diff --git a/whitelist.txt b/whitelist.txt index a64e4e4b23e..1d080419f4d 100644 --- a/whitelist.txt +++ b/whitelist.txt @@ -126,6 +126,7 @@ extcodehash extcodesize F00 filesystem +firstlineno fn fname forkchoice From 47178699d6ad9f8d7072d8069b1b8af27a7ed628 Mon Sep 17 00:00:00 2001 From: danceratopz Date: Thu, 30 May 2024 01:00:15 +0200 Subject: [PATCH 06/13] feat(consume): add test source url to hive test report description --- src/pytest_plugins/consume/simulator_common.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pytest_plugins/consume/simulator_common.py b/src/pytest_plugins/consume/simulator_common.py index 02278b3f3be..c0b2a8348ab 100644 --- a/src/pytest_plugins/consume/simulator_common.py +++ b/src/pytest_plugins/consume/simulator_common.py @@ -43,7 +43,11 @@ def fixture_description(fixture: Fixture, test_case: TestCase) -> str: """ Return the description of the current test case. """ + description = f"Test id: {test_case.id}" + if "url" in fixture.info: + description += f"\n\nTest source: {fixture.info['url']}" if "description" not in fixture.info: - return "No description field provided in the fixture's 'info' section." - description = f"Test id: {test_case.id}\n\n{fixture.info['description']}" + description += "\n\nNo description field provided in the fixture's 'info' section." + else: + description += f"\n\n{fixture.info['description']}" return description From ef5151d99da15a73a5afdb9be1f31e6177b0162e Mon Sep 17 00:00:00 2001 From: danceratopz Date: Thu, 30 May 2024 10:57:41 +0200 Subject: [PATCH 07/13] fix(fw): add workaround to fix fw pytest_plugin tests --- src/ethereum_test_tools/utility/versioning.py | 25 +++++++++++++------ whitelist.txt | 1 + 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/ethereum_test_tools/utility/versioning.py b/src/ethereum_test_tools/utility/versioning.py index 7cfbfd074c0..7216e34bd9b 100644 --- a/src/ethereum_test_tools/utility/versioning.py +++ b/src/ethereum_test_tools/utility/versioning.py @@ -2,23 +2,32 @@ Utility module with helper functions for versioning. """ +import os import re -from git import Repo # type: ignore +from git import InvalidGitRepositoryError, Repo # type: ignore def get_current_commit_hash_or_tag(repo_path="."): """ Get the latest commit hash or tag from the clone where doc is being built. """ - repo = Repo(repo_path) try: - # Get the tag that points to the current commit - current_tag = next((tag for tag in repo.tags if tag.commit == repo.head.commit)) - return current_tag.name - except StopIteration: - # If there are no tags that point to the current commit, return the commit hash - return repo.head.commit.hexsha + repo = Repo(repo_path) + # Try to get the current tag that points to the current commit + current_tag = next((tag for tag in repo.tags if tag.commit == repo.head.commit), None) + # Return the commit hash if no such tag exits + return current_tag.name if current_tag else repo.head.commit.hexsha + except InvalidGitRepositoryError: + # This hack is necessary for our framework tests. We use the pytester/tempdir fixtures + # to execute pytest within a pytest session (for top-level tests of our pytest plugins). + # The pytester fixture executes these tests in a temporary directory, which is not a git + # repository; this is a workaround to stop these tests failing. + if os.path.abspath(os.getcwd()).startswith("/tmp"): + # Should be true for unix-like systems; this won't work on windows. + return "Not a git repository (running under /tmp)" + else: + raise def generate_github_url(file_path, branch_or_commit_or_tag="main", line_number=""): diff --git a/whitelist.txt b/whitelist.txt index 1d080419f4d..68372406fc5 100644 --- a/whitelist.txt +++ b/whitelist.txt @@ -450,6 +450,7 @@ substring substrings tf teardown +tempdir testdir teststatus tmpdir From efc6cd3a1c72cdae06460ac312c49d2906be2140 Mon Sep 17 00:00:00 2001 From: danceratopz Date: Thu, 30 May 2024 13:03:37 +0200 Subject: [PATCH 08/13] fix(fw): fix pytest plugin fw tests on macos --- src/ethereum_test_tools/utility/versioning.py | 9 +++------ whitelist.txt | 1 + 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/ethereum_test_tools/utility/versioning.py b/src/ethereum_test_tools/utility/versioning.py index 7216e34bd9b..3cbd21eea39 100644 --- a/src/ethereum_test_tools/utility/versioning.py +++ b/src/ethereum_test_tools/utility/versioning.py @@ -2,7 +2,6 @@ Utility module with helper functions for versioning. """ -import os import re from git import InvalidGitRepositoryError, Repo # type: ignore @@ -23,11 +22,9 @@ def get_current_commit_hash_or_tag(repo_path="."): # to execute pytest within a pytest session (for top-level tests of our pytest plugins). # The pytester fixture executes these tests in a temporary directory, which is not a git # repository; this is a workaround to stop these tests failing. - if os.path.abspath(os.getcwd()).startswith("/tmp"): - # Should be true for unix-like systems; this won't work on windows. - return "Not a git repository (running under /tmp)" - else: - raise + # + # Tried monkeypatching the pytest plugin tests, but it didn't play well with pytester. + return "Not a git repository (running under /tmp)" def generate_github_url(file_path, branch_or_commit_or_tag="main", line_number=""): diff --git a/whitelist.txt b/whitelist.txt index 68372406fc5..c75b63676fe 100644 --- a/whitelist.txt +++ b/whitelist.txt @@ -417,6 +417,7 @@ makepyfile makereport metafunc modifyitems +monkeypatching nodeid noop oog From cffb871dd603785ef90ccb79f8ac5567ca7e0401 Mon Sep 17 00:00:00 2001 From: danceratopz Date: Tue, 4 Jun 2024 12:38:27 +0200 Subject: [PATCH 09/13] feat(consume): format id as code --- src/pytest_plugins/consume/simulator_common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pytest_plugins/consume/simulator_common.py b/src/pytest_plugins/consume/simulator_common.py index c0b2a8348ab..11c5888f875 100644 --- a/src/pytest_plugins/consume/simulator_common.py +++ b/src/pytest_plugins/consume/simulator_common.py @@ -43,7 +43,7 @@ def fixture_description(fixture: Fixture, test_case: TestCase) -> str: """ Return the description of the current test case. """ - description = f"Test id: {test_case.id}" + description = f"Test id: {test_case.id}" if "url" in fixture.info: description += f"\n\nTest source: {fixture.info['url']}" if "description" not in fixture.info: From a2bba09dcd6b93fca52b4e4e62c72b82f9311084 Mon Sep 17 00:00:00 2001 From: danceratopz Date: Tue, 4 Jun 2024 12:40:51 +0200 Subject: [PATCH 10/13] Revert "feat(consume): format id as code" This reverts commit cffb871dd603785ef90ccb79f8ac5567ca7e0401. --- src/pytest_plugins/consume/simulator_common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pytest_plugins/consume/simulator_common.py b/src/pytest_plugins/consume/simulator_common.py index 11c5888f875..c0b2a8348ab 100644 --- a/src/pytest_plugins/consume/simulator_common.py +++ b/src/pytest_plugins/consume/simulator_common.py @@ -43,7 +43,7 @@ def fixture_description(fixture: Fixture, test_case: TestCase) -> str: """ Return the description of the current test case. """ - description = f"Test id: {test_case.id}" + description = f"Test id: {test_case.id}" if "url" in fixture.info: description += f"\n\nTest source: {fixture.info['url']}" if "description" not in fixture.info: From 1fab38ee8eaec26295e2384117014db8adac5658 Mon Sep 17 00:00:00 2001 From: danceratopz Date: Tue, 4 Jun 2024 12:54:53 +0200 Subject: [PATCH 11/13] fix(consume): use the consume pytest test id as hive test id --- src/pytest_plugins/pytest_hive/pytest_hive.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pytest_plugins/pytest_hive/pytest_hive.py b/src/pytest_plugins/pytest_hive/pytest_hive.py index db01e58094d..6fcca2482dc 100644 --- a/src/pytest_plugins/pytest_hive/pytest_hive.py +++ b/src/pytest_plugins/pytest_hive/pytest_hive.py @@ -114,7 +114,7 @@ def hive_test(request, test_suite: HiveTestSuite): "Error: The 'fixture_description' fixture has not been defined by the simulator " "or pytest plugin using this plugin!" ) - test_parameter_string = request.node.nodeid.split("[")[-1].rstrip("]") # test fixture name + test_parameter_string = request.node.nodeid # consume pytest test id test: HiveTest = test_suite.start_test( name=test_parameter_string, description=fixture_description, From 71f3d6e0d115c2f39cf3b877e02b4b84b583e8d4 Mon Sep 17 00:00:00 2001 From: danceratopz Date: Tue, 4 Jun 2024 13:57:34 +0200 Subject: [PATCH 12/13] fix(fw): add improvements to versioning.py from review --- src/ethereum_test_tools/utility/versioning.py | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/ethereum_test_tools/utility/versioning.py b/src/ethereum_test_tools/utility/versioning.py index 3cbd21eea39..99aec4709fe 100644 --- a/src/ethereum_test_tools/utility/versioning.py +++ b/src/ethereum_test_tools/utility/versioning.py @@ -24,7 +24,7 @@ def get_current_commit_hash_or_tag(repo_path="."): # repository; this is a workaround to stop these tests failing. # # Tried monkeypatching the pytest plugin tests, but it didn't play well with pytester. - return "Not a git repository (running under /tmp)" + return "Not a git repository; this should only be seen in framework tests." def generate_github_url(file_path, branch_or_commit_or_tag="main", line_number=""): @@ -36,16 +36,9 @@ def generate_github_url(file_path, branch_or_commit_or_tag="main", line_number=" repository = "execution-spec-tests" if line_number: line_number = f"#L{line_number}" - if re.match( - r"^v[0-9]{1,2}\.[0-9]{1,3}\.[0-9]{1,3}(a[0-9]+|b[0-9]+|rc[0-9]+)?$", - branch_or_commit_or_tag, - ): - return ( - f"{base_url}/{username}/{repository}/tree/" - f"{branch_or_commit_or_tag}/{file_path}{line_number}" - ) - else: - return ( - f"{base_url}/{username}/{repository}/blob/" - f"{branch_or_commit_or_tag}/{file_path}{line_number}" - ) + release_tag_regex = r"^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(a[0-9]+|b[0-9]+|rc[0-9]+)?$" + tree_or_blob = "tree" if re.match(release_tag_regex, branch_or_commit_or_tag) else "blob" + return ( + f"{base_url}/{username}/{repository}/{tree_or_blob}/" + f"{branch_or_commit_or_tag}/{file_path}{line_number}" + ) From 4f26c8f7c9e80879e6abadf1427bb3fdfcc81c4c Mon Sep 17 00:00:00 2001 From: danceratopz Date: Tue, 4 Jun 2024 14:18:09 +0200 Subject: [PATCH 13/13] docs: update changelog --- docs/CHANGELOG.md | 1 + whitelist.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 4b1d987a6ce..2a8aa4de1c3 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -35,6 +35,7 @@ Test fixtures for use by clients are available for each release on the [Github r - ✨ Add a "slow" pytest marker, in order to be able to limit the filled tests until release ([#562](https://github.com/ethereum/execution-spec-tests/pull/562)). - ✨ Add a CLI tool that generates blockchain tests as Python from a transaction hash ([#470](https://github.com/ethereum/execution-spec-tests/pull/470), [#576](https://github.com/ethereum/execution-spec-tests/pull/576)). - ✨ Add more Transaction and Block exceptions from existing ethereum/tests repo ([#572](https://github.com/ethereum/execution-spec-tests/pull/572)). +- ✨ Add "description" and "url" fields containing test case documentation and a source code permalink to fixtures during `fill` and use them in `consume`-generated Hive test reports ([#579](https://github.com/ethereum/execution-spec-tests/pull/579)). ### 🔧 EVM Tools diff --git a/whitelist.txt b/whitelist.txt index f9525d8994e..d4c60e2e1cb 100644 --- a/whitelist.txt +++ b/whitelist.txt @@ -251,6 +251,7 @@ parseable pathlib pdb perf +permalink petersburg pformat png