From e763a87b42cca9c9a1cb35a45ba4517dbb42d8c9 Mon Sep 17 00:00:00 2001 From: nuno maduro Date: Mon, 24 Aug 2026 10:51:08 +0100 Subject: [PATCH] chore: updates snapshots --- .hod/lock | 14 ++-- .hod/skills/snapshots-update/SKILL.md | 74 +++++++++++++++++++ .../snapshots-update/agents/openai.yaml | 5 ++ AGENTS.md | 12 ++- src/Pest.php | 2 +- ...s_the_same_snapshot_on_every_retry__2.snap | 1 - ...isual_snapshot_of_help_command_output.snap | 2 +- ...isual_snapshot_of_help_command_output.snap | 2 +- tests/Visual/Parallel.php | 12 --- 9 files changed, 101 insertions(+), 23 deletions(-) create mode 100644 .hod/skills/snapshots-update/SKILL.md create mode 100644 .hod/skills/snapshots-update/agents/openai.yaml delete mode 100644 tests/.pest/snapshots/Features/Flaky/it_matches_the_same_snapshot_on_every_retry__2.snap diff --git a/.hod/lock b/.hod/lock index 84944935..82dbd473 100644 --- a/.hod/lock +++ b/.hod/lock @@ -1,10 +1,14 @@ 1a51f3f6c4eef45e6995bb5ac9a82cf3f23ccad0c68cc4f957796bb9fc198f58 .agents/skills/deps-upgrade/SKILL.md 984c7232ae1681ebba980ede2a0543db9a850dd2406990cdfa011384f929e981 .agents/skills/deps-upgrade/agents/openai.yaml -cb04cd147c57791f740b37a9b486851858388867ba4b32b4af4454ca28ba0b5f .agents/skills/learn/SKILL.md -6a9515e9c8b30b33743ac5b1beb797d683ae7b1acaee50f4dd3d0a445da735c6 .agents/skills/learn/agents/openai.yaml +e68fb750f54ca3b17d6797954cb7838f0415c2faa65496ae68cb3918474c68bf .agents/skills/init/SKILL.md +14ea76cbc5a8f35356ccf6aa20beddb249c6bc4aeb9999ec722c3acf92389d57 .agents/skills/init/agents/openai.yaml +3f7f77275ada85b55ed874cea8ada94ad6f838800311f46ecb2a31b68ae95ac7 .agents/skills/snapshots-update/SKILL.md +bb5339d7abcaba163a384a00a9ba8607ddf8b6820a63be3570e9b6fc6a912479 .agents/skills/snapshots-update/agents/openai.yaml 1a51f3f6c4eef45e6995bb5ac9a82cf3f23ccad0c68cc4f957796bb9fc198f58 .claude/skills/deps-upgrade/SKILL.md 984c7232ae1681ebba980ede2a0543db9a850dd2406990cdfa011384f929e981 .claude/skills/deps-upgrade/agents/openai.yaml -cb04cd147c57791f740b37a9b486851858388867ba4b32b4af4454ca28ba0b5f .claude/skills/learn/SKILL.md -6a9515e9c8b30b33743ac5b1beb797d683ae7b1acaee50f4dd3d0a445da735c6 .claude/skills/learn/agents/openai.yaml -c246ffcdee10cea23b94b1b1efa379beca374c672e8aefb54d52e8fc007f98cc AGENTS.md +e68fb750f54ca3b17d6797954cb7838f0415c2faa65496ae68cb3918474c68bf .claude/skills/init/SKILL.md +14ea76cbc5a8f35356ccf6aa20beddb249c6bc4aeb9999ec722c3acf92389d57 .claude/skills/init/agents/openai.yaml +3f7f77275ada85b55ed874cea8ada94ad6f838800311f46ecb2a31b68ae95ac7 .claude/skills/snapshots-update/SKILL.md +bb5339d7abcaba163a384a00a9ba8607ddf8b6820a63be3570e9b6fc6a912479 .claude/skills/snapshots-update/agents/openai.yaml +d1e4a22c7e3b8b833d873b139d331d85fb9f5247818911b35082ae9a8f6edf9f AGENTS.md 336cc4fbf19beaada7ccf9986414fa91851a8d7a07dfb3ccbe800a69eed0ab49 CLAUDE.md diff --git a/.hod/skills/snapshots-update/SKILL.md b/.hod/skills/snapshots-update/SKILL.md new file mode 100644 index 00000000..806295e6 --- /dev/null +++ b/.hod/skills/snapshots-update/SKILL.md @@ -0,0 +1,74 @@ +--- +name: snapshots-update +description: "Write each snapshot of this project again, then run the integration suite until it passes. Use when the user asks to update the snapshots, when a test of `tests/Visual/` fails, or when `composer test:integration` fails after a change of the number of the tests." +disable-model-invocation: true +--- + +# Snapshots + +Write each snapshot of this project again, then run `composer test:integration` until it passes. + +`tests/Pest.php` puts each test of `tests/Visual/` in the group `integration`, and each of those tests asserts the output of a full run of the suite. Thus a change of the number of the tests, of the number of the assertions, or of one line of the output of `bin/pest` breaks the integration suite, and this skill repairs it. + +Obey the order of the sections. Section 3 writes the number of the tests of a clean run, and section 4 writes that number into `tests/.snapshots/success.txt`. The reverse order writes the failure of the test `parallel` into that snapshot, and the integration suite then fails on the test `visual snapshot of test suite on success`. + +## 1. Read the working tree + +Run `git status --short`. Name each file that carries a change, then continue with that change in place, because the user starts this skill in the middle of a change. + +Write no commit and no tag during this work. Leave each change in the working tree. + +## 2. Turn off the coverage driver + +Put `XDEBUG_MODE=off` in front of each command of this skill. `.github/workflows/tests.yml` gives `coverage: none` to each job, thus a run of this project on GitHub collects no coverage, and `tests/.snapshots/success.txt` holds the line `it adds coverage if --coverage exist → Coverage is not available`. A run with a coverage driver writes one test more as passed, and the snapshot then fails on GitHub. + +Run `php -m | grep -iE "xdebug|pcov"` and read the name of each coverage driver of this computer. `XDEBUG_MODE=off` turns off `xdebug`. Add `-d pcov.enabled=0` to `php` for `pcov`, and run the command of the composer script `update:snapshots` directly for that flag. + +## 3. Write the summary of the parallel run + +Run this command with a timeout of 900 seconds: + +``` +XDEBUG_MODE=off COLLISION_PRINTER=DefaultPrinter COLLISION_IGNORE_DURATION=true PAO_DISABLE=1 php bin/pest --parallel --processes=3 --exclude-group=integration +``` + +Read the line that starts with `Tests:`. Take the text after `Tests:` up to and with `( assertions)`, such as `2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1578 passed (3426 assertions)`. That text is the summary. + +Run `grep -n "assertions)';" tests/Visual/Parallel.php`. The command gives one line, and that line holds the value of `$expected` of the test `parallel`. Write the summary in that line when the two texts differ, and change no other line of the file. + +## 4. Write each snapshot again + +Run `XDEBUG_MODE=off composer update:snapshots` with a timeout of 1800 seconds. The command runs `REBUILD_SNAPSHOTS=true php bin/pest --update-snapshots --exclude-group=tia`, and it writes `tests/.snapshots/success.txt` and each file under `tests/.pest/snapshots/`. The command starts a full suite inside a test of `tests/Visual/`, thus the command needs some minutes. + +The command exits with the code 2 after a correct run. Read the output and accept these three results: + +- a `FAILED` test of `tests/Visual/`, because the test reads the old snapshot and writes the new snapshot in the same run. +- a `FAILED` test of `tests/Features/Flaky.php`, because `--update-snapshots` writes each snapshot and a flaky test stops the retry when a snapshot changes. +- a `RISKY` test that performs no assertion, because a test that only writes a snapshot asserts nothing. + +Run `XDEBUG_MODE=off composer test:unit` for a `FAILED` test outside `tests/Visual/` and outside `tests/Features/Flaky.php`. That command writes no snapshot, thus it separates a regression of the code from an effect of `--update-snapshots`. Stop when the test fails again, give the report of section 6, and write no snapshot again. + +Run `grep -c "Coverage is not available" tests/.snapshots/success.txt`. The count is 1. Return to section 2 for the count 0, because a coverage driver of this computer stays on. + +## 5. Run the integration suite + +Run `XDEBUG_MODE=off composer test:integration` with a timeout of 3600 seconds. + +Read each test that failed, then take one action. + +| Test that failed | Action | +| --- | --- | +| the test `parallel` of `tests/Visual/Parallel.php` | Return to section 3, because the numbers of the suite moved after the last measure. | +| a different test of `tests/Visual/` | Return to section 3, because `tests/.snapshots/success.txt` holds the numbers of section 3. | +| a test outside `tests/Visual/` | Stop. Give the report of section 6, and write no snapshot again. | + +Return to section 3 two times at the most. Give the report of section 6 after the last run, and name each test that failed in that run. + +## 6. Report + +Give four items: + +- each file that this work changed, from `git status --short`. +- the summary that `tests/Visual/Parallel.php` holds now, and the summary that the file held before this work. +- the result of the last run of `composer test:integration`, and the name of each test that failed in that run. +- each section that you repeated, and the reason. diff --git a/.hod/skills/snapshots-update/agents/openai.yaml b/.hod/skills/snapshots-update/agents/openai.yaml new file mode 100644 index 00000000..085a6480 --- /dev/null +++ b/.hod/skills/snapshots-update/agents/openai.yaml @@ -0,0 +1,5 @@ +interface: + display_name: "Snapshots Update" + short_description: "Write each snapshot of this project again" +policy: + allow_implicit_invocation: false diff --git a/AGENTS.md b/AGENTS.md index f844f96d..1cb561ba 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -12,7 +12,7 @@ This file is for a coding agent. No user reads it. Write an instruction that an Start each rule with a verb in the imperative. Put the condition before the instruction. Give the exact path, the exact command and the exact name that the agent must use. If a rule needs a test, give the command that does the test. -The public files are different. `README.md`, the website, the release notes and the `description` in each manifest are for a user. Section 3 controls them. +The public files are different. `README.md`, the website, the release notes and the `description` in each manifest are for a user. Section 3 controls them. Section 5 controls each message that you give the user. --- @@ -32,7 +32,7 @@ A fact that you learned during one task is not a rule. Use it in that task, then Write no sentence for a fact that an agent finds when it reads the code. The cost of that read does not change the answer: a fact that four files hold is in the code. Put the fact in the code first, because a test stops the agent that breaks it and a sentence here does not. -Ask the user before you write a rule. Give the fault, then call the skill `learn` after the user agrees. Keep the number of the rules: delete a rule file in the same change, or ask the user to accept one more rule. A correction from the user is a rule and needs no question: write it in a file before you continue the work. +Ask the user before you write a rule. Give the fault, and write the rule after the user agrees. Give the file the path `.hod/rules/.md`. Give `` two or three words with a hyphen between them, and name the subject of the rule. Give the file `name` and `description` in its front matter, and write one rule in one file. Run `hod update --project` after the write, thus this file names the rule in section 6. Keep the number of the rules: delete a rule file in the same change, or ask the user to accept one more rule. A correction from the user is a rule and needs no question: write it in a file before you continue the work. Give no new part of the program its own rule, because the code of that part holds its design. Delete text that follows the order of a file of source code: that text describes the file, and the file describes itself. Replace an old rule. Do not write a second rule near it. Delete a rule that the project does not obey. Do not keep a record of what the project stopped doing, in a file or in a directory. Git holds the history. @@ -65,3 +65,11 @@ Write a reason that the code cannot hold in a file in `.hod/rules/`, with the pa When a library reads the text of a comment as data, such as the description of a command on a help screen, write that text in an attribute or a field of that library instead. A tool that writes a comment into a file that it owns keeps that comment. Do not delete it: the tool fails until it writes the comment again. + +--- + +## 5. How to write a message to the user + +Write each message that you give the user in the English of section 2: one instruction in one sentence, the imperative, the active voice, one meaning for one word, and no contraction. A question, a report, a plan and an answer obey this rule. + +Give the result first. Give the exact path, the exact command and the exact name. Write no sentence that says the work again, and no adjective that gives the reader no new fact. diff --git a/src/Pest.php b/src/Pest.php index 6e7e5122..f1e4c3d9 100644 --- a/src/Pest.php +++ b/src/Pest.php @@ -6,7 +6,7 @@ namespace Pest; function version(): string { - return '5.1.1'; + return '5.1.2'; } function testDirectory(string $file = ''): string diff --git a/tests/.pest/snapshots/Features/Flaky/it_matches_the_same_snapshot_on_every_retry__2.snap b/tests/.pest/snapshots/Features/Flaky/it_matches_the_same_snapshot_on_every_retry__2.snap deleted file mode 100644 index ff010066..00000000 --- a/tests/.pest/snapshots/Features/Flaky/it_matches_the_same_snapshot_on_every_retry__2.snap +++ /dev/null @@ -1 +0,0 @@ -the same on every attempt \ No newline at end of file diff --git a/tests/.pest/snapshots/Visual/Help/visual_snapshot_of_help_command_output.snap b/tests/.pest/snapshots/Visual/Help/visual_snapshot_of_help_command_output.snap index e1c653d4..befabe6e 100644 --- a/tests/.pest/snapshots/Visual/Help/visual_snapshot_of_help_command_output.snap +++ b/tests/.pest/snapshots/Visual/Help/visual_snapshot_of_help_command_output.snap @@ -1,5 +1,5 @@ - Pest Testing Framework 5.1.1. + Pest Testing Framework 5.1.2. USAGE: pest [options] diff --git a/tests/.pest/snapshots/Visual/Version/visual_snapshot_of_help_command_output.snap b/tests/.pest/snapshots/Visual/Version/visual_snapshot_of_help_command_output.snap index bd798b40..022dada5 100644 --- a/tests/.pest/snapshots/Visual/Version/visual_snapshot_of_help_command_output.snap +++ b/tests/.pest/snapshots/Visual/Version/visual_snapshot_of_help_command_output.snap @@ -1,3 +1,3 @@ - Pest Testing Framework 5.1.1. + Pest Testing Framework 5.1.2. diff --git a/tests/Visual/Parallel.php b/tests/Visual/Parallel.php index 9cfa05cb..fa4af783 100644 --- a/tests/Visual/Parallel.php +++ b/tests/Visual/Parallel.php @@ -20,18 +20,6 @@ test('parallel', function () use ($run): void { $output = $run('--exclude-group=integration'); $output = implode("\n", array_slice(explode("\n", (string) $output), -10)); - if (getenv('REBUILD_SNAPSHOTS')) { - preg_match('/Tests:\s+(.+\(\d+ assertions\))/', $output, $matches); - - $file = file_get_contents(__FILE__); - $file = preg_replace( - '/\$expected = \'.*?\';/', - "\$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1578 passed (3426 assertions)';", - $file, - ); - file_put_contents(__FILE__, $file); - } - $expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1578 passed (3426 assertions)'; expect($output)