Commit bc2e590
authored
fix(toolshed): accept
`check_generated_file_seals.py` declares three comment styles for the seal
line, one per generated-file family:
_COMMENT_CHARS = {".py": b"#", ..., ".rst": b"..", ".c": b"//",
".cpp": b"//", ".h": b"//"}
and `validate_generated_file_seal` compares the seal's captured prefix
against `expected_comment_prefix(filepath)` so a `.rst` file cannot be
sealed with a `#`, and so on. But the marker regex only ever accepts two of
the three:
rb"^(?P<prefix>#|\.\.) "
`//` can never be captured, so `fullmatch` returns None for any sealed
`.c` / `.cpp` / `.h` file and it is rejected as `MALFORMED generated-file
seal` before the prefix comparison runs at all. The `b"//"` entries in
`_COMMENT_CHARS` and the branch that would validate them are dead.
Add `//` to the alternation, with a note tying it to `_COMMENT_CHARS` so
the two do not drift again.
This also adds the first tests for the script, under `toolshed/tests/`, and
runs them alongside the existing `ci/tools/tests` in the nightly tooling
job. The parametrized case is driven from `_COMMENT_CHARS` itself, so a
future entry whose prefix the regex cannot match fails immediately instead
of silently becoming dead code.// seals so C/C++ generated files can be sealed (#2539)1 parent 8457bb0 commit bc2e590
1 file changed
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
20 | 23 | | |
21 | 24 | | |
22 | 25 | | |
| |||
0 commit comments