mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-24 17:11:28 +01:00
Changed-constant check stops flagging unrelated tests for one- and two-digit numbers (#4683)
Changing a small constant such as `MAX_ITEMS = 10` no longer flags every test that mentions its module and holds a `10` somewhere; only lines that use something taken from the module, or name the constant, count. Why: one-line raises of two-digit constants were blocked by dozens of false matches (#4312); on gstack itself, changing `RECEIPT_RUNS_KEPT` (30) flagged 20 test files and now flags 4. Nothing to do. Three-digit and longer values keep the old rule, and a test that imports the module and asserts the old value is still caught. Co-authored-by: Mahmoud ElNeMR <83190847+ElNeMeR70@users.noreply.github.com> Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> Review-Finding: p1/red-team#1 reader=red-team Review-Finding: p1/specialist-batched#1 reader=testing Review-Finding: p1/red-team#2 reader=red-team
This commit is contained in:
4 files changed
+119
-25
No files matched your search
+12
-2
@@ -245,7 +245,8 @@ Two stages with separate clocks, both printed:
|
||||
literal (a named literal the branch only adds, such as `limit: 300` in a new
|
||||
object, is not a change), the whole test tree (nightly- and Heavy-only files included) is
|
||||
searched for the old value in files that name the constant or, when the old
|
||||
value is longer than one character, its module (the module's file name not
|
||||
value is longer than one character, its module (for a one- or two-digit
|
||||
integer, only on a line that uses a name taken from the module, below; the module's file name not
|
||||
followed by another extension, or a path ending
|
||||
in its stem followed by its own extension, for a JS/TS module also any JS/TS
|
||||
extension or `.d.ts`, a sentence-ending `.`, or anything but a word
|
||||
@@ -266,7 +267,16 @@ Two stages with separate clocks, both printed:
|
||||
line before ends with `(`, `[`, `{`, `,`, `.`, `=` or another operator, or the
|
||||
line starts with `.`, `)`, `]`, `}` or an operator), never on a comment line, plus the history rows
|
||||
above. A `$2` in a shell stub, a comment, or `export default 2` in a fixture
|
||||
elsewhere in the file is not a consumer. A call-site name such as `attempts`
|
||||
elsewhere in the file is not a consumer.
|
||||
A one- or two-digit integer (`12`, `-10`) found through the module counts only
|
||||
in a statement that names the constant or a binding the file takes from the
|
||||
module: a JS/TS import of it (type-only imports excluded) or a variable that a
|
||||
statement naming the module or another such binding declares or assigns, its
|
||||
continuation lines included (`const out = run('scripts/arms.ts')`,
|
||||
`const items = listItems()`). So `expect(shards()).toBe(12)` after importing
|
||||
`shards` still fails, while a comment naming the module beside an unrelated
|
||||
`10` does not (#4312). A local helper function that wraps an imported name is
|
||||
not followed, so its assertions need the constant's name to count. A call-site name such as `attempts`
|
||||
or `limit` is an ordinary word, so for it the file must also name the changed
|
||||
module, whatever the old value's length: a test that only uses the word is not
|
||||
a consumer, and a test that imports the module still is.
|
||||
|
||||
Reference in new issue
Block a user