This is an automated email from the ASF dual-hosted git repository.
sbp pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-releases-client.git
The following commit(s) were added to refs/heads/main by this push:
new f27ca26 Run transcripts in the correct environment and add stderr
f27ca26 is described below
commit f27ca2667417b5471a3d05ed654510279d25b742
Author: Sean B. Palmer <[email protected]>
AuthorDate: Thu Jul 10 15:58:11 2025 +0100
Run transcripts in the correct environment and add stderr
---
pyproject.toml | 4 ++--
src/atrclient/client.py | 11 +++++++++++
tests/cli_config.t | 7 +++++++
tests/cli_version.t | 2 +-
tests/test_all.py | 43 ++++++++++++++++++++++++++++++++++---------
uv.lock | 4 ++--
6 files changed, 57 insertions(+), 14 deletions(-)
diff --git a/pyproject.toml b/pyproject.toml
index 2826c92..2100e59 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -11,7 +11,7 @@ build-backend = "hatchling.build"
[project]
name = "apache-trusted-releases"
-version = "0.20250710.1426"
+version = "0.20250710.1457"
description = "ATR CLI and Python API"
readme = "README.md"
requires-python = ">=3.13"
@@ -48,4 +48,4 @@ atr = "atrclient.client:main"
packages = ["src/atrclient"]
[tool.uv]
-exclude-newer = "2025-07-10T14:26:00Z"
+exclude-newer = "2025-07-10T14:57:00Z"
diff --git a/src/atrclient/client.py b/src/atrclient/client.py
index 3a0b88f..ec74e77 100755
--- a/src/atrclient/client.py
+++ b/src/atrclient/client.py
@@ -171,6 +171,17 @@ def app_config_path() -> None:
print(config_path())
[email protected](name="env", help="Show the environment variables.")
+def app_dev_env() -> None:
+ total = 0
+ for key, value in sorted(os.environ.items()):
+ if not key.startswith("ATR_"):
+ continue
+ print(f"{key}={json.dumps(value, indent=None)}")
+ total += 1
+ print(f"There are {total} ATR_* environment variables.")
+
+
@DEV.command(name="stamp", help="Update version and exclude-newer in
pyproject.toml.")
def app_dev_stamp() -> None:
path = pathlib.Path("pyproject.toml")
diff --git a/tests/cli_config.t b/tests/cli_config.t
new file mode 100644
index 0000000..b24bb31
--- /dev/null
+++ b/tests/cli_config.t
@@ -0,0 +1,7 @@
+$ atr dev env
+ATR_CLIENT_CONFIG_PATH="<!CONFIG_PATH!>"
+<!...!>
+
+! atr config file
+<!stderr!>
+No configuration file found.
diff --git a/tests/cli_version.t b/tests/cli_version.t
index 2fb95e8..dfa16d1 100644
--- a/tests/cli_version.t
+++ b/tests/cli_version.t
@@ -1,2 +1,2 @@
$ atr --version
-0.20250710.1426
+0.20250710.1457
diff --git a/tests/test_all.py b/tests/test_all.py
index 83bcaad..e63db3b 100755
--- a/tests/test_all.py
+++ b/tests/test_all.py
@@ -18,6 +18,8 @@
# TODO: Use transcript style script testing
from __future__ import annotations
+import os
+import re
import shlex
import atrclient.client as client
@@ -193,10 +195,13 @@ def test_cli_version(script_runner:
pytest_console_scripts.ScriptRunner) -> None
"transcript_path", decorator_transcript_file_paths(), ids=lambda p: p.name
)
def test_cli_transcripts(
- transcript_path: pathlib.Path, script_runner:
pytest_console_scripts.ScriptRunner
+ transcript_path: pathlib.Path,
+ script_runner: pytest_console_scripts.ScriptRunner,
+ fixture_config_env: pathlib.Path,
) -> None:
+ r_variable = re.compile(r"<!([A-Z_]+)!>")
with open(transcript_path, "r", encoding="utf-8") as f:
- actual_stdout = []
+ actual_output = []
for line in f:
line = line.rstrip("\n")
if line.startswith("$ ") or line.startswith("! "):
@@ -205,18 +210,38 @@ def test_cli_transcripts(
if not command.startswith("atr"):
pytest.fail(f"Command does not start with 'atr':
{command}")
return
- result = script_runner.run(shlex.split(command))
+ env = os.environ.copy()
+ env["ATR_CLIENT_CONFIG_PATH"] = str(fixture_config_env)
+ result = script_runner.run(shlex.split(command), env=env)
assert result.returncode == expected_code
- actual_stdout[:] = result.stdout.splitlines()
- elif actual_stdout:
- actual_stdout_line = actual_stdout.pop(0)
- if actual_stdout_line != line:
- pytest.fail(f"Expected {line!r} but got
{actual_stdout_line!r}")
+ actual_output[:] = result.stdout.splitlines()
+ if result.stderr:
+ actual_output.append("<!stderr!>")
+ actual_output.extend(result.stderr.splitlines())
+ elif actual_output:
+ if line == "<!...!>":
+ actual_output[:] = []
+ continue
+ actual_output_line = actual_output.pop(0)
+ # Replace variables with (?P<variable>.*?)
+ line_pattern = r_variable.sub(r"(?P<\1>.*?)", line)
+ if line_pattern != line:
+ success = re.match(line_pattern, actual_output_line)
+ else:
+ success = actual_output_line == line
+ if not success:
+ # TODO: Improve this
+ got = f"{actual_output_line!r}"
+ if actual_output:
+ got += f", {actual_output[:10]}"
+ if len(actual_output) > 10:
+ got += "..."
+ pytest.fail(f"Expected {line!r} but got {got}")
return
elif line:
pytest.fail(f"Unexpected line: {line!r}")
return
- assert not actual_stdout
+ assert not actual_output
def test_config_set_get_roundtrip() -> None:
diff --git a/uv.lock b/uv.lock
index 5e59bf5..5fd67ab 100644
--- a/uv.lock
+++ b/uv.lock
@@ -2,7 +2,7 @@ version = 1
requires-python = ">=3.13"
[options]
-exclude-newer = "2025-07-10T14:26:00Z"
+exclude-newer = "2025-07-10T14:57:00Z"
[[package]]
name = "aiohappyeyeballs"
@@ -74,7 +74,7 @@ wheels = [
[[package]]
name = "apache-trusted-releases"
-version = "0.20250710.1426"
+version = "0.20250710.1457"
source = { editable = "." }
dependencies = [
{ name = "aiohttp" },
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]