diff --git a/tests/test_tool_messages.py b/tests/test_tool_messages.py index 3f1a8abbd..1ba332604 100644 --- a/tests/test_tool_messages.py +++ b/tests/test_tool_messages.py @@ -213,6 +213,45 @@ class AnOfflineExportWithNoOriginalsStopsFirst(unittest.TestCase): self.assertIn("export_native.py --all --refresh-cache", text) +class ThePipelineFlagTableSaysEveryRefusal(unittest.TestCase): + """tools.md said --full-narrowings is refused with --skip-packs only, and + advanced-usage.md kept its own shorter list: `--source truth + --full-narrowings` failed with nothing on either page saying so.""" + + PAIRS = {"--source": "platform", "--all-variants": True, "--full-narrowings": True, + "--skip-packs": True} + + def _refused(self, flags: dict) -> bool: + import argparse + + args = argparse.Namespace(source=None, all_variants=False, full_narrowings=False, + skip_packs=False) + for flag, value in flags.items(): + setattr(args, flag.lstrip("-").replace("-", "_"), value) + parser = mock.Mock() + pipeline._refuse_unapplied_flags(parser, args) + return parser.error.called + + def test_each_refused_pair_is_in_the_row_of_a_flag(self): + import itertools + + text = (REPO_ROOT / "wiki" / "tools.md").read_text(encoding="utf-8") + rows = {line.split("`")[1].split()[0]: line for line in text.splitlines() + if line.startswith("| `--")} + for (a, va), (b, vb) in itertools.combinations(self.PAIRS.items(), 2): + if not self._refused({a: va, b: vb}): + continue + with self.subTest(pair=(a, b)): + self.assertTrue(f"`{b}" in rows.get(a, "") or f"`{a}" in rows.get(b, ""), + f"{a} with {b} is refused, and neither row says so") + self.assertIn("`--source truth`", rows["--full-narrowings"]) + + def test_one_list_of_refusals(self): + text = (REPO_ROOT / "wiki" / "advanced-usage.md").read_text(encoding="utf-8") + self.assertNotIn("are refused with", text) + self.assertIn("tools.md#pipeline", text) + + class TheTruthDiffShowsWhereAndAsksNothing(unittest.TestCase): """The markdown wrote `**Remove** hiscore.dat (phantom)` beside six `**Add** hiscore.dat`, none with a path, for files profiled cores read.""" diff --git a/wiki/advanced-usage.md b/wiki/advanced-usage.md index d54969839..9f230fe2e 100644 --- a/wiki/advanced-usage.md +++ b/wiki/advanced-usage.md @@ -543,7 +543,7 @@ python scripts/pipeline.py --offline --with-export ### Combining flags -These flags compose (`--source` and `--all-variants` are refused with `--skip-packs`): +These flags compose, except the pairs the [pipeline flags](tools.md#pipeline) table marks as refused: ```bash python scripts/pipeline.py --offline --skip-packs --skip-docs --with-truth --target switch diff --git a/wiki/tools.md b/wiki/tools.md index 2c4b4290a..0e62fec66 100644 --- a/wiki/tools.md +++ b/wiki/tools.md @@ -76,7 +76,7 @@ Pipeline flags: | `--target TARGET` | filter verify, packs and truth by hardware target | | `--source {platform,truth,full}` | pack file source, passed through to `generate_pack.py`. Refused with `--skip-packs` | | `--all-variants` | build the 6 source x required combinations. Refused with `--skip-packs` and with `--source` | -| `--full-narrowings` | step 5 compares every region, target and system of each platform instead of three of each. Refused with `--skip-packs` | +| `--full-narrowings` | step 5 compares every region, target and system of each platform instead of three of each. Refused with `--skip-packs` and with `--source platform` or `--source truth` | | `--check-buildbot` | run step 2b. Additive, and ignored under `--offline` | | `--with-truth` | run steps 2c and 2d | | `--with-export` | run steps 2c, 2d and 2e |