Skip to content

test: add 31 new regression tests - #305

Merged
ferdingler merged 3 commits into
strands-agents:mainfrom
ferdingler:test/regression-gaps
Nov 14, 2026
Merged

ferdingler merged 3 commits into
strands-agents:mainfrom
ferdingler:test/regression-gaps

Conversation

@ferdingler

@ferdingler ferdingler commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Description

About 30 open PRs refactor or extend code that main barely tests: the command lists, export and env handling, command -v, the find walk, the date math, and the MCP shell tool result. I broke that code on purpose in about 20 ways, and 16 of 21 of them still passed the existing tests. As those PRs get rebased and merged, a bad conflict resolution or a refactor slip would go unnoticed.

This adds tests that pin what main does today, so each of those PRs can be checked against them. Test-only change, nothing under src/ changes. Most of it is new differential cases recorded from bash 5.2.15 (coreutils 8.32, jq 1.8.1), plus a few integration tests for things the differential suite can't express.

What's covered:

┌───────────────────────────┬───────┐
│           File            │ Tests │
├───────────────────────────┼───────┤
│ tests/lookup_and_env.rs   │ 10    │
├───────────────────────────┼───────┤
│ tests/command_registry.rs │ 5     │
├───────────────────────────┼───────┤
│ tests/date_fixed_clock.rs │ 5     │
├───────────────────────────┼───────┤
│ tests/mcp_integration.rs  │ 1     │
├───────────────────────────┼───────┤
│ tests/differential/cases/ │ 10    │
└───────────────────────────┴───────┘

How I checked it:

  • The full Rust suite passes on main.
  • I broke each piece of code on purpose, one at a time, and checked that the new tests caught it, then reverted:
Break Caught
Drop a command from the WASM lookup table yes
Drop a command from the WASM /bin list yes
README command count off by one yes
list-commands output unsorted yes
local x with no value does nothing yes
Function locals not restored on return yes
readonly x with no value sets it to empty yes
export x with no value clears it yes
unset keeps the value yes
x=1 cmd prefix not applied yes
command -v skips the hash table yes
Empty PATH entry not treated as the current directory yes
Unset PATH falls back to a default PATH yes
Functions checked before builtins in command -V no, see below
Special builtins labeled as plain builtins yes
find doubles the slash after a trailing-slash start path yes
find -empty true for a directory with one entry yes
Every 4th year is a leap year yes
Leap day every 4th year in the month table only yes
No 400-year leap rule yes
Tool description claims three blocks yes

Related Issues

Part of #207

Documentation PR

N/A

Type of Change

Other (please describe): test-only change

Testing

How have you tested the change? Verify that the changes do not break functionality or introduce new warnings.

  • I ran the relevant test suites for the bindings I touched (cargo test --workspace --all-targets, pytest tests/python, npm test)
  • If I touched Rust, I ran cargo fmt and cargo clippy

Checklist

  • I have read the CONTRIBUTING document
  • I have reviewed and understand every line of code in this PR, including any generated by AI tools, and I can explain why it works
  • My change is focused and reasonably small; I have split unrelated work into separate PRs
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@ferdingler

Copy link
Copy Markdown
Collaborator Author

@strandly-the-agent Please review this change

@strandly-the-agent strandly-the-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve, with two should-fixes. All the expectations I checked match bash and GNU date, and the full suite passes. But one test pins a known bug as correct, and the MCP exit-code check doesn't run against #268's description.

  • 🟡 tests/lookup_and_env.rs:49 expects command -V echo to say builtin after echo() {...}. Bash says echo is a function and runs the function. #174 already lists this as a bug, so whoever fixes it will see this test fail as if they'd caused a regression.
  • 🟡 tests/mcp_integration.rs:157 only checks the exit code when the description mentions metadata.exit_code. #268's description doesn't, so on #268 nothing checks that exit 3 comes back as 3.

Details and suggested fixes are inline.

What I verified
  • Tests: ran on f2ec042. cargo test --workspace --all-targets passes. The five new or touched targets pass on their own: command_registry 5, date_fixed_clock 5, lookup_and_env 10, mcp_integration 41, and differential 1 test (92 cases passed, 0 failed, 20 known differences).
  • Recorded output: I ran all 9 new .sh cases under env -i PATH=/usr/bin:/bin LC_ALL=C bash (5.2.15) in an empty directory, the same way record() does. All 9 match their .expected byte for byte. I also ran export_attributes.sh separately and got the same stdout, exit 0, and the readonly errors on stderr.
  • Known differences: each of the 5 markers really does differ on main when run through strands-shell -c. For example, local_without_value gives v=[global] z=[1], and find_missing_start exits 0/0. None of them depends on the environment.
  • Dates: all 11 instants and the 12-hour format line match GNU date -u -d @N. Nothing depends on the host TZ.
  • Source parsers in command_registry.rs: the parsed lists are compared as sets against the native registry, so a parse that finds nothing fails. Formats the parser can't read, like "a" \| "b" => arms or a reworded anchor comment, also fail loudly. The curl and sleep omissions are real.

I ran only the correctness pass. There's no public API or src/ change, so I skipped API review, and I skipped the adversarial pass because the PR's own mutation table already covers that ground.

Non-blocking (1)
  • Known-difference cases (local_without_value, command_v_unset_path, find_missing_start, etc.) only notice when main starts matching bash. They don't pin what main does today, so a refactor that changes one wrong output into a different wrong output passes. That's how the harness is built, so it's fine here, but it's worth keeping in mind when reading the "Caught" column.

Comment thread tests/lookup_and_env.rs Resolved
Comment thread tests/mcp_integration.rs Resolved
@ferdingler

Copy link
Copy Markdown
Collaborator Author

@strandly-the-agent Please review this change

@strandly-the-agent strandly-the-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still approving. Both earlier findings are fixed in e7f4268. The new differential case has one problem of its own (inline).

  • ✅ lookup_and_env.rs: the integration test no longer pins the #174 bug.
  • ✅ mcp_integration.rs: it passes on top of #268, and it fails when #268 reports the wrong exit code.
  • 🟡 function_shadows_builtin.sh: this marker won't flip when #174 is fixed, because command -V prints functions differently from bash.

I can't resolve review threads with my permissions, so the two old ones need resolving by hand.

What I verified
  • On e7f4268 these pass: differential (92 passed, 0 failed, 21 known differences), lookup_and_env (10), and mcp_integration (41).
  • I put e7f4268's tests/mcp_integration.rs on top of #268 and the test passes. When I changed #268's third block to exit code: {exit_code + 1}, it failed at mcp_integration.rs:161 with left: "exit code: 1" right: "exit code: 0".
  • strands-shell prints f is a shell function for command -V f, the same as dash. Bash prints f is a function followed by the function body.

@ferdingler

Copy link
Copy Markdown
Collaborator Author

@strandly-the-agent Please review this change

@strandly-the-agent strandly-the-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved on 673071d. All three findings are fixed, and I have nothing new.

function_shadows_builtin now checks only whether the function runs, so fixing #174 will flip its marker. strands-shell already supports builtin echo, so the function body will work once the function is actually called. I can't resolve review threads, so the last one needs resolving by hand.

What I verified
  • The re-recorded .expected matches bash 5.2.15 run with env -i PATH=/usr/bin:/bin LC_ALL=C in an empty directory: stdout fn, exit 0.
  • On main, strands-shell prints hi, so the known difference is real.
  • cargo test --test differential on 673071d: 92 passed, 0 failed, 21 known differences.

@ferdingler ferdingler changed the title test: add regression tests for behavior the open PRs refactor test: add 31 new regression tests Nov 14, 2026
@ferdingler
ferdingler merged commit f5c6ac4 into strands-agents:main Nov 14, 2026
33 checks passed
@ferdingler
ferdingler deleted the test/regression-gaps branch November 14, 2026 17:12
ferdingler added a commit to ferdingler/shell that referenced this pull request Nov 19, 2026
strands-agents#305 added this differential case with a known-difference marker noting
that every variable reached child commands, "fixed by strands-agents#285". This PR is
that fix: env and other child commands now see only exported variables,
so the case matches bash and the harness fails until the marker goes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants