mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-25 01:21:24 +01:00
The stale-test-value check matches tests by resolved import, not file name (GST-3563) (#4723)
The check that flags tests still holding a changed constant's old value now matches tests by the import that resolves to the changed file, not by file name. Why: when two files share a name (two `config.ts`), it flagged tests of the wrong file and a JSON golden nobody could waive, and a list that only gained an item flagged every test still naming the kept item. What you do: nothing. 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: lib/pregate/checks/literals.ts:197:core reader=core
This commit is contained in:
1 parent
50cc296700
commit
79f3052f35
7 files changed
+261
-29
No files matched your search
@@ -280,6 +280,34 @@ Two stages with separate clocks, both printed:
|
||||
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.
|
||||
When another file in the repository has the module's name (two `config.ts`
|
||||
files), a path fragment or file name alone is ambiguous, so a file counts
|
||||
through the module only when one of its references resolves to the changed
|
||||
file: a relative import, a tsconfig/jsconfig `paths` alias or `baseUrl`
|
||||
import, a quoted repository path or a `join()` of segments, the same
|
||||
resolution lane selection uses. A test importing the other `config.ts` is not
|
||||
a consumer (gbrain#10078: 17 false hits). An alias import counts even when the
|
||||
name is unique. A test that reaches the module only through another module
|
||||
(a barrel or a caller) is not found this way; it needs the constant's name.
|
||||
A JSON file has no comments, so it can't carry a waiver; instead, an old value
|
||||
in it counts only where the JSON ties it to the constant: the value of a key
|
||||
named after the constant, or anything inside a record whose string value is
|
||||
the constant's name (`{ "name": "LIMIT_MS", "signature": ["2000"] }`). An equal
|
||||
value under another name in a golden is not a consumer; a golden that pins the
|
||||
changed constant still is. A JSON file that doesn't parse counts only on lines
|
||||
that name the constant.
|
||||
A quoted one-item list that keeps its item and gains more
|
||||
(`"investigate"` → `"investigate verify"`, every item a bare word) leaves its
|
||||
member valid, so a line holding the old item counts only when it asserts the
|
||||
whole old value: as the whole argument of `toBe`, `toEqual`, `toStrictEqual`
|
||||
or an `equal`/`strictEqual`/`deepEqual` style assert (alone or as a one-item
|
||||
array), beside `==`/`===`/`!=`/`!==`, or as an assignment's value; or in a
|
||||
statement that names the constant or a binding taken from the module or the
|
||||
constant (an alias such as `modes`), unless that line only checks membership
|
||||
(`toContain`, `includes`, `indexOf`, `has`, `in`). Words inside strings
|
||||
don't make a binding. A list that had several items, or a value that is prose
|
||||
(`"file not found"`), keeps the ordinary rule, because its quoted old value is
|
||||
the whole value wherever it appears.
|
||||
A test that keeps the old value on purpose, such as the refused input after a
|
||||
minimum version goes up, marks that one line with a comment on it or on the
|
||||
comment line directly above it:
|
||||
|
||||
@@ -4848,7 +4848,9 @@ keeps the old value on purpose (the refused input after a minimum version goes
|
||||
up), mark that line: `// pregate-literal: NAME=<old value> <reason>` on the line
|
||||
or on the comment line directly above it. The marker waives only that line, and
|
||||
the check lists it as `waived:`. Don't use `warn: ["literals"]` for this, since
|
||||
that turns the check off for every constant.
|
||||
that turns the check off for every constant. A JSON file can't hold a marker,
|
||||
so the check only counts JSON values tied to the constant's name; a listed JSON
|
||||
line really pins the old value, so update the golden.
|
||||
|
||||
<a id="arg-limit"></a>
|
||||
### `PREGATE_ENVIRONMENT` with `environment: arg-limit — E2BIG` (or `Argument list too long`)
|
||||
|
||||
Reference in new issue
Block a user