diff options
Diffstat (limited to 'docs/testing.md')
| -rw-r--r-- | docs/testing.md | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/docs/testing.md b/docs/testing.md index a5686330c..31ab93653 100644 --- a/docs/testing.md +++ b/docs/testing.md | |||
| @@ -144,10 +144,12 @@ python -I scripts/red_green.py <pull request number> | |||
| 144 | cherry-picked with a 3-way merge. A conflict, or a pull request that changes no test, is "red not constructible". | 144 | cherry-picked with a 3-way merge. A conflict, or a pull request that changes no test, is "red not constructible". |
| 145 | A hunk that mixes test and other code stays on the green side only. | 145 | A hunk that mixes test and other code stays on the green side only. |
| 146 | - It runs `cargo test --no-fail-fast` for the crates under `d3d12/crates` and `d3d12/apps` the pull request touches, | 146 | - It runs `cargo test --no-fail-fast` for the crates under `d3d12/crates` and `d3d12/apps` the pull request touches, |
| 147 | from `d3d12/` so the pinned toolchain applies. It also runs each changed `tests/**/test*.py` with unittest. Both | 147 | from `d3d12/` so the pinned toolchain applies. It also runs each changed `tests/**/test*.py` with unittest, after |
| 148 | sides run in one worktree with one cargo target dir, red first, under `<git common dir>/red-green` (`--work-dir` | 148 | removing the worktree's `__pycache__` folders so that no test runs stale bytecode. Both sides run in one worktree |
| 149 | to move it). The worktree and the target dir stay for the next run, which then builds only what changed. The | 149 | with one cargo target dir, red first, under `<git common dir>/red-green` (`--work-dir` to move it). The worktree |
| 150 | target dir takes several GB; delete the folder (and run `git worktree prune`) when done. | 150 | and the target dir stay for the next run, which then builds only what changed. The target dir takes several GB. |
| 151 | The worktree stays registered in git, in the default folder as with `--work-dir`: when done, run | ||
| 152 | `git worktree remove --force <folder>/tree` and delete the folder, or delete the folder and run `git worktree prune`. | ||
| 151 | - It prints the tests that go from red to green, those that pass on red and fail on green, those that fail on both | 153 | - It prints the tests that go from red to green, those that pass on red and fail on green, those that fail on both |
| 152 | (failing on `main` too), and those found on one side only. The verdict is one of: `red then green` (exit 0), | 154 | (failing on `main` too), and those found on one side only. The verdict is one of: `red then green` (exit 0), |
| 153 | `no red`, `red does not build`, `green fails`, `red not constructible`, `green not constructible`, `no tests ran`, | 155 | `no red`, `red does not build`, `green fails`, `red not constructible`, `green not constructible`, `no tests ran`, |
| @@ -157,6 +159,25 @@ python -I scripts/red_green.py <pull request number> | |||
| 157 | and the report says so; a second crash gives `compiler crashed`. Run it again later, or on another machine. | 159 | and the report says so; a second crash gives `compiler crashed`. Run it again later, or on another machine. |
| 158 | - `red does not build` is the case the fork-CI steps above call "does not build without the pull request's new | 160 | - `red does not build` is the case the fork-CI steps above call "does not build without the pull request's new |
| 159 | file": the test needs the new code, which does not show that it catches the bug. | 161 | file": the test needs the new code, which does not show that it catches the bug. |
| 162 | - `--mutate` also checks that the tests catch the change itself, what verifiers do by hand by removing a line of the | ||
| 163 | fix. After the green side, it undoes each hunk of the pull request's code alone (Rust and Python files it changes, | ||
| 164 | outside the tests and `#[cfg(test)]` code) and runs the tests again. A hunk is `caught` when a test that went red | ||
| 165 | then green fails, `not caught` when they all still pass, `does not build` when those tests no longer run, | ||
| 166 | `compiler crashed` when the compiler crashed twice, or `does not apply` when `main` moved those lines since. Each | ||
| 167 | mutation starts from the green tree, reset and cleaned, so what a test writes into the tree changes no other. It | ||
| 168 | tries at most `--mutate-max` hunks (10) and lists the others as `not tried, past --mutate-max` | ||
| 169 | (`mutations_skipped` in `--json`). A `not caught` hunk is code no new test looks at; it does not change the | ||
| 170 | verdict. | ||
| 171 | - Files the pull request adds are not mutated: undoing one would delete it, which only shows that something uses it. | ||
| 172 | The report lists them (`not mutated, added by the pull request`), so a fix whose code sits in a new file is not | ||
| 173 | read as covered. When no hunk is undone, the report says why: `nothing to undo` when the pull request changes no | ||
| 174 | Rust or Python code outside its tests (a test-only one, whose `no red` then says nothing against its test), or | ||
| 175 | `not run` when no test went red then green. `--json` has these in `mutations_not_run` and `added_not_mutated`. | ||
| 176 | - Each command of a mutated run (`cargo test`, one Python test file) is stopped with the processes it started after | ||
| 177 | `--mutate-timeout` seconds (600). The hunk is then `caught by timeout` when a test was running (the undone code | ||
| 178 | made it hang), or `timed out building` when cargo had not started a test yet, which says nothing about the tests | ||
| 179 | (raise the option for a crate that builds slowly). When the command ends, the processes it left behind are | ||
| 180 | stopped too (a Windows job object, the process group elsewhere). | ||
| 160 | - `--crate <name>` adds a crate, `--no-cargo` or `--no-python` leaves one kind out, `--base <ref>` tests on another | 181 | - `--crate <name>` adds a crate, `--no-cargo` or `--no-python` leaves one kind out, `--base <ref>` tests on another |
| 161 | base, and `--no-fetch` uses the refs as they are. | 182 | base, and `--no-fetch` uses the refs as they are. |
| 162 | 183 | ||