@syncerauk/test-rules 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/package.json +1 -1
- package/test-rules.mjs +9 -7
package/README.md
CHANGED
|
@@ -67,6 +67,10 @@ A repo starts with `"fail": false`: breaches are printed and the exit is 0. One
|
|
|
67
67
|
|
|
68
68
|
## Versions
|
|
69
69
|
|
|
70
|
+
- **1.0.3** — A JSON reads register no longer turns off the scan of the test's code. A source
|
|
71
|
+
file the test builds a path to from its own place, in a test that reads files, is a
|
|
72
|
+
`T4:source-text` breach unless the test declares it `// runs:`. A repo with a JSON register
|
|
73
|
+
(app, portal) can see breaches that are not on its list on its first run of 1.0.3.
|
|
70
74
|
- **1.0.2** — A path that starts with a dot-folder (`.github/workflows/gate.yml`) is a repo
|
|
71
75
|
path; only `./` and `../` are relative to the test. A JSON reads register may be the whole
|
|
72
76
|
file (`"key": null`); a register with no map at its key cannot run (exit 3) instead of reading
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@syncerauk/test-rules",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "The static check of Syncera's test-writing rules (T1, T4, T6 and the line limit of R7). One file, no dependency. Published to npm by the orchestrator's publish-test-rules workflow; each repo pins an exact version.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "UNLICENSED",
|
package/test-rules.mjs
CHANGED
|
@@ -33,11 +33,13 @@
|
|
|
33
33
|
// T4:source-text the test reads a source file as text: a read it declares (the repo's reads
|
|
34
34
|
// register) that is a source file or a folder and is neither under a fixture
|
|
35
35
|
// folder nor on the wording list; a `?raw` import or a raw import.meta.glob;
|
|
36
|
-
// and,
|
|
37
|
-
//
|
|
38
|
-
//
|
|
39
|
-
//
|
|
40
|
-
//
|
|
36
|
+
// and, whatever the register's form, a source file whose path the test
|
|
37
|
+
// builds from its own place (new URL(…, import.meta.url), or join( /
|
|
38
|
+
// resolve( on import.meta.dirname, __dirname, ROOT or HERE) in a test that
|
|
39
|
+
// reads the file system and declares it neither `// reads:`, `// runs:` nor
|
|
40
|
+
// in its JSON register entry (a file that is only run is declared `// runs:`).
|
|
41
|
+
// A JSON register is what a test says it reads; it does not stop the code
|
|
42
|
+
// being read for what it does read (1.0.3).
|
|
41
43
|
// T6:timer setTimeout( / setInterval( / sleep( / timers/promises with no fake timers in the file
|
|
42
44
|
// T6:clock Date.now( / new Date() / performance.now( with no fake timers in the file
|
|
43
45
|
// T6:outside homedir(), process.env.HOME, a relative path that climbs out of the repo,
|
|
@@ -291,8 +293,8 @@ function sourceTextLine({ path, text, code, bare, strings }, { config, register,
|
|
|
291
293
|
if (/\?raw|as\s*:\s*['"]raw['"]/.test(call)) return lineOf(code, m.index);
|
|
292
294
|
}
|
|
293
295
|
// A source file whose path the test builds from its own place, in a test that reads the file
|
|
294
|
-
// system,
|
|
295
|
-
|
|
296
|
+
// system, that the test does not declare: `// runs:` when it is only run. A JSON register does
|
|
297
|
+
// not silence this: a register can miss a read, and a source file it names returned above.
|
|
296
298
|
if (!FS_READ.test(code) || !tracked) return 0;
|
|
297
299
|
const said = [...declared.reads, ...declared.runs].map((r) => r.pattern);
|
|
298
300
|
for (const s of strings) {
|