Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
424 changes: 416 additions & 8 deletions tests/conftest.py

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,29 @@

prog="${0##*/}"

# THE ROOTS ARE PASSED THROUGH, NEVER CHOSEN HERE (opensoft/openRepoTools#186,
# T009). `OPENREPOTOOLS_CODE_ROOT`, `_ASSEMBLY_ROOT` and `_SPEC_ROOT` name the
# trees `tests/conftest.py` reads, and they reach pytest in the environment as
# they are - except that the `cd` below would read a RELATIVE one against the
# code root rather than against where the caller stood. So a relative value is
# made absolute against the caller's directory first, and nothing else is
# touched. `OPENREPOTOOLS_COMPOSED` is a mode, not a path, and passes as it is.
abs_root() { # <value> - absolute against the caller's directory

Check warning on line 82 in tests/run.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add an explicit return statement at the end of the function.

See more on https://sonarcloud.io/project/issues?id=opensoft_openRepoTools&issues=AaEdg3ru5xa7Ewsj-JYC&open=AaEdg3ru5xa7Ewsj-JYC&pullRequest=190
case "$1" in
/*) printf '%s\n' "$1" ;;

Check warning on line 84 in tests/run.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Assign this positional parameter to a local variable.

See more on https://sonarcloud.io/project/issues?id=opensoft_openRepoTools&issues=AaEdg3ru5xa7Ewsj-JYA&open=AaEdg3ru5xa7Ewsj-JYA&pullRequest=190
*) printf '%s/%s\n' "$PWD" "$1" ;;

Check warning on line 85 in tests/run.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Assign this positional parameter to a local variable.

See more on https://sonarcloud.io/project/issues?id=opensoft_openRepoTools&issues=AaEdg3ru5xa7Ewsj-JYB&open=AaEdg3ru5xa7Ewsj-JYB&pullRequest=190
esac
}
if [ -n "${OPENREPOTOOLS_CODE_ROOT:-}" ]; then

Check failure on line 88 in tests/run.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=opensoft_openRepoTools&issues=AaEdg3ru5xa7Ewsj-JYD&open=AaEdg3ru5xa7Ewsj-JYD&pullRequest=190
OPENREPOTOOLS_CODE_ROOT="$(abs_root "$OPENREPOTOOLS_CODE_ROOT")"; export OPENREPOTOOLS_CODE_ROOT
fi
if [ -n "${OPENREPOTOOLS_ASSEMBLY_ROOT:-}" ]; then

Check failure on line 91 in tests/run.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=opensoft_openRepoTools&issues=AaEdg3ru5xa7Ewsj-JYE&open=AaEdg3ru5xa7Ewsj-JYE&pullRequest=190
OPENREPOTOOLS_ASSEMBLY_ROOT="$(abs_root "$OPENREPOTOOLS_ASSEMBLY_ROOT")"; export OPENREPOTOOLS_ASSEMBLY_ROOT
fi
if [ -n "${OPENREPOTOOLS_SPEC_ROOT:-}" ]; then

Check failure on line 94 in tests/run.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=opensoft_openRepoTools&issues=AaEdg3ru5xa7Ewsj-JYF&open=AaEdg3ru5xa7Ewsj-JYF&pullRequest=190
OPENREPOTOOLS_SPEC_ROOT="$(abs_root "$OPENREPOTOOLS_SPEC_ROOT")"; export OPENREPOTOOLS_SPEC_ROOT
fi

# THE REPOSITORY ROOT, so the suite runs the same from anywhere. `cd -P` is
# the portable physical path: `readlink -f` is not in the stock macOS userland.
cd -P -- "$(dirname -- "$0")/.." 2>/dev/null || {
Expand Down
40 changes: 35 additions & 5 deletions tests/test_lane_helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ TESTS_DIR="$(cd -- "$(dirname -- "$SELF")" && pwd)"
# `repos.tsv` BESIDE it, because in `opensoft/brett-wip` they were. They are at
# the root of `opensoft/openRepoTools` now and this suite is in `tests/`.
SRC_DIR="$(cd -- "$TESTS_DIR/.." && pwd)"
# THE LANE MANUAL IS THE SPEC LEG'S (opensoft/openRepoTools#186, T009). Two
# sections below quote `docs/README-lanes.md` back against the code, and in the
# triad that file is in the spec leg, not beside the code. The pytest runner
# (`tests/test_lane_helpers_suite.py`) names it from the run's roots; SET AND
# EMPTY means the run has no spec root - a standalone code leg - and those
# quotes are SKIPPED, naming it. Unset, it is this checkout's own copy, as it
# always was, and a composed run never reaches here without one.
LANE_MANUAL="${OPENREPOTOOLS_LANE_MANUAL-$SRC_DIR/docs/README-lanes.md}"

for f in lane-start lane-end lanes-edit.sh link-estates lane lanes lane-rename lane-worktrees; do
[ -x "$SRC_DIR/$f" ] || { echo "missing or not executable: $SRC_DIR/$f" >&2; exit 1; }
Expand Down Expand Up @@ -3733,16 +3741,24 @@ unset FAKE_TMUX_WINDOW_NAME
# and not one example block carrying the `as of … (no fetch)` line Amendment
# 8(e) requires on EVERY block — and nothing noticed, because no assertion in
# this suite had ever read the document. A quoted line nobody reads is the same
# defect as an untested sentence (RV-B2), one file over. Read from `$SRC_DIR`,
# the checkout's own copy, which is the one a person opens.
ss_doc="$(cat "$SRC_DIR/docs/README-lanes.md" 2>/dev/null || :)"
# defect as an untested sentence (RV-B2), one file over. Read from
# `$LANE_MANUAL`, the run's own copy, which is the one a person opens.
if [ -n "$LANE_MANUAL" ]; then
# A MANUAL THAT IS NOT THERE IS A FAILURE NAMING IT, never an empty string the
# assertions below then misread as a manual that says nothing (#186, T009).
if [ -r "$LANE_MANUAL" ]; then ok "the lane manual is where the run's roots put it"
else bad "the lane manual is where the run's roots put it" "no readable file at $LANE_MANUAL"; fi
ss_doc="$(cat "$LANE_MANUAL" 2>/dev/null || :)"
has "the README states the subcommand's THIRD safety property, not just two" "$ss_doc" "It never writes, it never touches the network, and it always exits 0"
has "…and carries the line every block ends with" "$ss_doc" "as of 4m ago (no fetch)"
has "…quoting the superseded-transcript branch as the hook really prints it" "$ss_doc" "WARNING: this is a superseded transcript of lane repoSS-1; the live one is <U>; you resumed <V> — exit this session and run: lane-start repoSS 1"
has "…its \`unknown\`-stamp sub-branch, which sends the reader to the RECORDING act" "$ss_doc" "which the row records as \`unknown\` — a relaunch would record nothing either, so run: lane-start --no-launch repoSS 1"
has "…the in-no-row branch, its command filled in too" "$ss_doc" "this session <V> is in no row — the harness minted a new transcript — run: lane-start --no-launch repoSS 1"
has "…and the third bound-branch line, the one Rule 3's stamp is owed on" "$ss_doc" "stamp the handoff RESUMED (Rule 3) and follow its top block"
hasnt "…never the drifted spelling, which no branch of the hook has ever printed" "$ss_doc" "whose current session is <U>; you resumed <V> — run: lane-start <repo> <n>"
else
skip "the manual quotes the session-start hook (seven assertions)" "no spec root in this run: docs/README-lanes.md is the spec leg's (#186, T009)"
fi

# ------------------------------------------------- Rule 1's sibling reads
#
Expand Down Expand Up @@ -6223,9 +6239,12 @@ has "…in ITS arm's own words" "$err" "--estate needs a name"
# went on calling `lanes` "every lane on this workstation, newest write first"
# — the pre-settlement default, wrong twice over, because the scope is the
# ESTATE now and inside a checkout it is one repository. Nothing was red for it:
# no assertion had ever read that sentence. Read from `$SRC_DIR`, the checkout's
# no assertion had ever read that sentence. Read from `$LANE_MANUAL`, the run's
# own copy, which is the one a person opens.
ln_doc="$(cat "$SRC_DIR/docs/README-lanes.md" 2>/dev/null || :)"
if [ -n "$LANE_MANUAL" ]; then
if [ -r "$LANE_MANUAL" ]; then ok "…and still there for the bare-lanes quotes"
else bad "…and still there for the bare-lanes quotes" "no readable file at $LANE_MANUAL"; fi
ln_doc="$(cat "$LANE_MANUAL" 2>/dev/null || :)"
has "the manual quotes the settlement that narrowed the bare word" "$ln_doc" \
"Narrow inside a checkout (Recommended)"
has "…and the one that made \`lane-start <repo>\` list and suggest" "$ln_doc" \
Expand All @@ -6240,6 +6259,9 @@ has "…and the way back to every lane, which is the word the stale sentence l
"\`lanes --all\`, and a bare \`lanes\` outside every checkout, are clause (j)'s"
hasnt "…never the pre-settlement default it documented while building the narrowing" "$ln_doc" \
"every lane on this workstation"
else
skip "the manual says what a bare lanes lists (seven assertions)" "no spec root in this run: docs/README-lanes.md is the spec leg's (#186, T009)"
fi

run "$LANES_CMD" --all </dev/null
is "lanes exits 0 with rows" "$rc" 0
Expand Down Expand Up @@ -6576,8 +6598,16 @@ hasnt "the listing no longer says the retire act writes a record" "$lanes_text"
has "…it says what the act does, which is prove and print" "$lanes_text" "which PROVES the pid or uuid is"
hasnt "the helper's parser comment no longer says one writer still writes that line" "$le_text" '`<pid|uuid>` writes `RETIRED'
has "…it names the line as the legacy an append-only log still carries" "$le_text" "NOTHING WRITES ONE ANY MORE"
# The manual's half is guarded like the two sections that read it: `ln_doc` is
# bound only when the run has a spec root, and this suite runs under `set -u`,
# so an unguarded read ABORTS a code leg's run instead of skipping (the #190
# review by lane openRepoTools-3).
if [ -n "$LANE_MANUAL" ]; then
hasnt "the manual no longer promises an Amendment 6(d) record" "$ln_doc" "which writes the Amendment 6(d) record"
has "…and says in terms that it writes nothing" "$ln_doc" "**It writes nothing**"
else
skip "the manual says --retire writes nothing (two assertions)" "no spec root in this run: docs/README-lanes.md is the spec leg's (#186, T009)"
fi
# A PAUSED LANE WITH NO RECORDED PROFILE GETS NO `restart` LINE — it gets the
# form that works, with the profile named as the one token to supply.
has "a lane with no recorded profile is offered the launcher form, not a line it cannot type" \
Expand Down
12 changes: 11 additions & 1 deletion tests/test_lane_helpers_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

import pytest

from conftest import REPO, WINDOWS_SKIP
from conftest import REPO, ROOTS, WINDOWS_SKIP

SUITE = REPO / "tests" / "test_lane_helpers.sh"

Expand Down Expand Up @@ -170,6 +170,16 @@ def test_the_lane_helper_suite_passes():
"LANES_REPOS_TSV_SHIPPED", "AGENT_PROTOCOL_ROOT",
"OPENREPOTOOLS_BIN_DIR", "PROJECTS_ROOT", "CLAUDE_NO_LANE"):
env.pop(name, None)
# THE LANE MANUAL IS THE SPEC LEG'S (opensoft/openRepoTools#186, T009):
# the suite quotes `docs/README-lanes.md` back against the code, and in the
# triad that file is not beside the code. Named from this run's roots - the
# code root itself on today's layout - and EMPTY where the run has no spec
# root (a standalone code leg), which the suite reads as "skip the quotes,
# naming why". A composed run without one never gets here: conftest
# refuses it before the first test.
spec = ROOTS.root_of("spec")
env["OPENREPOTOOLS_LANE_MANUAL"] = (
"" if spec is None else str(spec / "docs" / "README-lanes.md"))

# `errors="replace"`, because the thing this wrapper exists to print is the
# TRANSCRIPT, and a decode that raises loses all of it. The suite renders
Expand Down
7 changes: 5 additions & 2 deletions tests/test_openrepotools_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

import pytest

from conftest import REPO, WINDOWS_SKIP
from conftest import REPO, ROOTS, WINDOWS_SKIP

COMMAND = REPO / "openRepoTools"

Expand Down Expand Up @@ -1395,7 +1395,10 @@ def test_the_help_and_the_readme_say_the_mode_the_receipt_is_born_at():
paragraph and neither carries a 0644 there.
"""
help_text = run_cmd("--help").stdout
readme = (REPO / "README.md").read_text(encoding="utf-8")
# The README is the ASSEMBLY root's in the triad (#186, T009): read from
# the root that owns it - a skip in a standalone code leg, and in the
# composed run a failure, never a skip, if that root is absent.
readme = ROOTS.path_for("README.md").read_text(encoding="utf-8")
for where, text, start in (("--help", help_text, "It then writes a RECEIPT"),
("README.md", readme, "**And it writes down what it placed.**")):
assert start in text, f"{where} no longer has the receipt paragraph"
Expand Down
Loading
Loading