From e18a6a0c03263f385e608d9661abadd8db5ac8d8 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Wed, 3 Jan 2024 20:41:14 -0600 Subject: [PATCH] Include permalink to scenarios used to generate test cases (#767) --- .../puffin-cli/tests/pip_install_scenarios.rs | 5 ++++- scripts/scenarios/template.mustache | 6 +++++- scripts/scenarios/update.py | 21 ++++++++++++++----- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/crates/puffin-cli/tests/pip_install_scenarios.rs b/crates/puffin-cli/tests/pip_install_scenarios.rs index 57aa26015..47c41a001 100644 --- a/crates/puffin-cli/tests/pip_install_scenarios.rs +++ b/crates/puffin-cli/tests/pip_install_scenarios.rs @@ -1,6 +1,9 @@ #![cfg(all(feature = "python", feature = "pypi"))] -/// Generated by `./scripts/scenarios/update.py` +/// DO NOT EDIT +/// +/// GENERATED WITH `./scripts/scenarios/update.py` +/// SCENARIOS FROM `https://github.com/zanieb/packse/tree/682bf4ff269f130f92bf35fdb58b6b27c94b579a/scenarios` use std::process::Command; use anyhow::Result; diff --git a/scripts/scenarios/template.mustache b/scripts/scenarios/template.mustache index c6faf60e5..ae6131f80 100644 --- a/scripts/scenarios/template.mustache +++ b/scripts/scenarios/template.mustache @@ -1,7 +1,11 @@ #![cfg(all(feature = "python", feature = "pypi"))] -/// {{generated_by}} +/// DO NOT EDIT +/// +/// GENERATED WITH `{{generated_with}}` +/// SCENARIOS FROM `{{generated_from}}` + use std::process::Command; diff --git a/scripts/scenarios/update.py b/scripts/scenarios/update.py index 6981cae39..9562e19af 100755 --- a/scripts/scenarios/update.py +++ b/scripts/scenarios/update.py @@ -4,7 +4,7 @@ # # Usage: # -# $ scripts/scenarios/update.py +# $ ./scripts/scenarios/update.py # # Requirements: # @@ -84,10 +84,12 @@ if packse.__development_base_path__.name != "packse": ) scenarios_path = str(PACKSE / "scenarios") else: - print("Using local packse scenarios...", file=sys.stderr) + print( + f"Using scenarios in packse repository at {packse.__development_base_path__}", + file=sys.stderr, + ) scenarios_path = str(packse.__development_base_path__ / "scenarios") - print("Loading scenario metadata...", file=sys.stderr) data = json.loads( subprocess.check_output( @@ -99,8 +101,17 @@ data = json.loads( ) ) -# Add a generated note -data["generated_by"] = f"Generated by `{' '.join(sys.argv)}`" +# Add generated metadata +commit = ( + subprocess.check_output( + ["git", "show", "-s", "--format=%H", "HEAD"], cwd=scenarios_path + ) + .decode() + .strip() +) +data["generated_from"] = f"https://github.com/zanieb/packse/tree/{commit}/scenarios" +data["generated_with"] = " ".join(sys.argv) + # Add normalized names for tests for scenario in data["scenarios"]: