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
25 changes: 25 additions & 0 deletions .github/instructions/zsh-scripting.instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,31 @@ and remember that a system `zshenv` may still execute.
Mark intentionally invalid, legacy, or lint-negative fixtures in repository
metadata instead of excluding an entire test directory.

### `zsh/test/cover-removed-behavior`

- Level: `required`
- Profiles: `test-fixture`
- Minimum Zsh: `null`
- Basis: `organization-policy`
- Evidence: `manual-index`
- Enforcement: `human-review`

When a change removes code on the grounds that it is unnecessary, a test
offered as evidence for that removal must exercise the behaviour the removed
code provided. Observe it failing with the code removed and passing with it
present. A test that passes in both states supports nothing and must not be
cited as though it does.

Run the candidate test against the unmodified source before removing anything.
If it passes there, it is not evidence, and either the test or the premise of
the removal is wrong.

This applies with particular force where a line looks inert: a declaration that
appears redundant, an assignment whose value seems unused, a mutation that
resembles a leak. Such a line is exactly the kind that gets removed on
inspection, and exactly the kind whose loss a nearby test will not notice
because the test covers the path the line does not serve.

### `zsh/test/match-production-profile`

- Level: `required`
Expand Down
9 changes: 9 additions & 0 deletions lib/zsh-standard-policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,15 @@
"evidence": ["shell-grammar"],
"enforcement": ["classifier"]
},
{
"id": "zsh/test/cover-removed-behavior",
"level": "required",
"profiles": ["test-fixture"],
"minimum_zsh": null,
"basis": "organization-policy",
"evidence": ["manual-index"],
"enforcement": ["human-review"]
},
{
"id": "zsh/test/match-production-profile",
"level": "required",
Expand Down
4 changes: 2 additions & 2 deletions scripts/test_validate_zsh_standard_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1979,7 +1979,7 @@ def test_repair_2_consumer_parser_outputs_match_frozen_golden(self) -> None:
},
"parsed_rules": validator._markdown_rules(instruction),
}
self.assertEqual(len(snapshot["rule_blocks"]), 65)
self.assertEqual(len(snapshot["rule_blocks"]), 66)
digest = hashlib.sha256(
json.dumps(
snapshot,
Expand All @@ -1991,7 +1991,7 @@ def test_repair_2_consumer_parser_outputs_match_frozen_golden(self) -> None:

self.assertEqual(
digest,
"d841ec864632352bc399bb035780e6805200425a4f14b0b700d3e7a9e8f7c59e",
"c2faea55b03018e947b6e1b5fef023c4d50a9474cfc9f4c4f372f68cabf6ba58",
msg=(
"The frozen golden covers the parsed output of every path in "
f"{paths}. Editing any of them changes this digest, which is "
Expand Down
1 change: 1 addition & 0 deletions scripts/validate-zsh-standard-policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
"zsh/completion/preserve-trust-boundaries",
"zsh/test/isolate-environment",
"zsh/test/declare-negative-fixtures",
"zsh/test/cover-removed-behavior",
"zsh/test/match-production-profile",
"zsh/options/canonical-spelling",
"zsh/options/declare-correctness-state",
Expand Down
Loading