@roomi-fields/grillhouse 0.25.5 → 0.26.0
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/.claude-plugin/plugin.json +1 -1
- package/agents/testwriter.md +1 -1
- package/bin/grillhouse.mjs +20 -3
- package/cadre/templates/cargo/package.json +3 -0
- package/cadre/templates/projet/.gitattributes +1 -0
- package/cadre/templates/projet/CLAUDE.md +6 -0
- package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
- package/charte.md +10 -1
- package/docs/ARCHITECTURE.md +91 -26
- package/docs/INTERFACE.md +16 -4
- package/hooks/register.tsx +57 -16
- package/package.json +9 -3
- package/scripts/circuit.mjs +121 -19
- package/scripts/copies-finies.mjs +167 -28
- package/scripts/crochets.mjs +9 -3
- package/scripts/enveloppe/enveloppe.mjs +59 -17
- package/scripts/enveloppe/lancer.sh +15 -22
- package/scripts/enveloppe/travail-de-la-copie.mjs +188 -0
- package/scripts/etapes.mjs +1 -1
- package/scripts/fusion-du-changelog.mjs +120 -0
- package/scripts/grillhouse-maj.mjs +19 -0
- package/scripts/integration/file.mjs +196 -104
- package/scripts/jointure.d.ts +22 -1
- package/scripts/langages/cargo/binaires.json +2 -1
- package/scripts/langages/cargo/clippy.mjs +10 -2
- package/scripts/langages/cargo/commandes.mjs +19 -4
- package/scripts/langages/cargo/composants.mjs +229 -8
- package/scripts/langages/cargo/index.mjs +17 -8
- package/scripts/langages/cargo/sccache.mjs +143 -0
- package/scripts/langages/cargo/verdict.mjs +50 -10
- package/scripts/langages/typescript/index.mjs +4 -2
- package/scripts/langages/typescript/regle-des-tests.mjs +37 -0
- package/scripts/nuit.sh +15 -1
- package/scripts/outils-cles.mjs +188 -0
- package/scripts/resultats.mjs +22 -6
- package/scripts/sous-commandes.mjs +16 -0
- package/scripts/verrou-de-machine.mjs +14 -13
- package/scripts/verrous/verrou.mjs +50 -14
- package/skills/developpeur/SKILL.md +4 -0
- package/skills/explorateur/SKILL.md +3 -1
- package/skills/pitmaster/SKILL.md +6 -2
- package/skills/pitmaster/references/consigne-agent.md +3 -3
- package/skills/relecteur/SKILL.md +6 -2
- package/skills/testwriter/SKILL.md +23 -6
|
@@ -13,20 +13,43 @@
|
|
|
13
13
|
// ./touches.mjs reads as the whole workspace.
|
|
14
14
|
// - The shared test material: the crates whose manifest says `[package.metadata.grillhouse]
|
|
15
15
|
// matiere = true`.
|
|
16
|
-
// - A
|
|
17
|
-
// the tests
|
|
16
|
+
// - A test lives in a file of its own, never in a file of code (decision 5 of the epic
|
|
17
|
+
// grillhouse-pkl, amended by grillhouse-agr): the tests by the interface under `tests/` of each
|
|
18
|
+
// crate, where cargo finds its integration tests; the unit tests near their module, under
|
|
19
|
+
// `src/`, in a file `tests.rs` or a folder `tests/`, as rustc's tidy check wants them
|
|
20
|
+
// (src/tools/tidy/src/unit_tests.rs), declared in the module by `#[cfg(test)] mod tests;`, a line
|
|
21
|
+
// the testwriter writes with his test. A crate plays tests when it has either.
|
|
18
22
|
// - The readers of a crate: the members that depend on it by its path, of any kind (`normal`,
|
|
19
23
|
// `dev`, `build`), the kind in `par`; a name no member bears is without provider. The types
|
|
20
24
|
// give no survey of their own: `etat` done, no element.
|
|
21
25
|
// - What the testwriter writes: a file of `<crate>/tests/` is a test file; the runner plays the
|
|
22
26
|
// ones cargo makes a test target of, `tests/<nom>.rs` and `tests/<dossier>/main.rs`, and the
|
|
23
27
|
// others are their helpers and data (`tests/fixtures/`, as OSC Bridge's devices); a file of
|
|
24
|
-
// `<crate>/tests/common/`, the helpers cargo's book puts there, is test material too; a file
|
|
25
|
-
//
|
|
26
|
-
// is
|
|
28
|
+
// `<crate>/tests/common/`, the helpers cargo's book puts there, is test material too; a file
|
|
29
|
+
// `tests.rs` under `src/`, and any file of a folder `tests/` under `src/`, is a unit test file,
|
|
30
|
+
// played with its crate when it is Rust; a file of a crate of the shared test material is
|
|
31
|
+
// material; any other file of a crate (the code of `src/`) is none of them.
|
|
32
|
+
// - What the testwriter writes of the manifests (`manifestes`): the tables that declare what the
|
|
33
|
+
// tests of a crate depend on, `[dev-dependencies]` and `[target.<cible>.dev-dependencies]` of
|
|
34
|
+
// its Cargo.toml (cargo's book, « Development dependencies »), as the author of a test of Bazel
|
|
35
|
+
// declares the deps of its target; and Cargo.lock at the root, which cargo brings in line with
|
|
36
|
+
// them. A change of any other table is named by it; the Cargo.toml of a virtual workspace is
|
|
37
|
+
// no crate's. Of a file of code of `src/` of a crate, the testwriter writes its test module
|
|
38
|
+
// alone (grillhouse-agr): the declaration `#[cfg(test)] mod tests;` added or removed, without
|
|
39
|
+
// which a new tests.rs is never compiled, and an inline `#[cfg(test)] mod tests { … }` removed,
|
|
40
|
+
// which he moves into tests.rs; any other change is named by its first line. The manifests are
|
|
41
|
+
// read with smol-toml, a tool of this module (`outils`), an optional peer of the package loaded
|
|
42
|
+
// when a manifest is judged, so that a project of another language, which loads this module
|
|
43
|
+
// without it, never needs it.
|
|
27
44
|
import { spawnSync } from 'node:child_process';
|
|
28
|
-
import { existsSync, statSync } from 'node:fs';
|
|
45
|
+
import { existsSync, readdirSync, statSync } from 'node:fs';
|
|
46
|
+
import { createRequire } from 'node:module';
|
|
29
47
|
import path from 'node:path';
|
|
48
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
49
|
+
|
|
50
|
+
// The loader of the optional peers this module reads when it needs them (smol-toml), under the
|
|
51
|
+
// name by which knip reads a dependency.
|
|
52
|
+
const require = createRequire(import.meta.url);
|
|
30
53
|
|
|
31
54
|
// The genre of a dependency as cargo names its kind, null for a normal one.
|
|
32
55
|
const genre = kind => kind ?? 'normal';
|
|
@@ -100,10 +123,33 @@ export const matieres = racine =>
|
|
|
100
123
|
.filter(c => c.matiere)
|
|
101
124
|
.map(c => c.composant);
|
|
102
125
|
|
|
103
|
-
|
|
126
|
+
// Whether <parts>, a path from the folder of a crate split, is a unit test file under its `src/`:
|
|
127
|
+
// a file `tests.rs`, or a file of a folder `tests/`.
|
|
128
|
+
// `src/bin/tests.rs` and `src/bin/tests/` are a binary target for cargo, its code.
|
|
129
|
+
const unitaire = parts =>
|
|
130
|
+
parts[0] === 'src' &&
|
|
131
|
+
parts.length > 1 &&
|
|
132
|
+
!(parts[1] === 'bin' && ['tests.rs', 'tests'].includes(parts[2])) &&
|
|
133
|
+
(parts.at(-1) === 'tests.rs' || parts.slice(1, -1).includes('tests'));
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Whether the crate <composant> plays tests: a folder `tests/`, its integration tests, or a unit
|
|
137
|
+
* test file under `src/`.
|
|
138
|
+
*/
|
|
104
139
|
export function joueDesTests(_racine, composant) {
|
|
105
140
|
const d = path.join(composant.dossier, 'tests');
|
|
106
|
-
|
|
141
|
+
if (existsSync(d) && statSync(d).isDirectory()) {
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
const src = path.join(composant.dossier, 'src');
|
|
145
|
+
if (!existsSync(src)) {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
return readdirSync(src, { recursive: true, withFileTypes: true }).some(
|
|
149
|
+
e =>
|
|
150
|
+
e.isFile() &&
|
|
151
|
+
unitaire(['src', ...path.relative(src, path.join(e.parentPath, e.name)).split(path.sep)])
|
|
152
|
+
);
|
|
107
153
|
}
|
|
108
154
|
|
|
109
155
|
/**
|
|
@@ -193,5 +239,180 @@ export function estUnTest(chemin, racine) {
|
|
|
193
239
|
(parts.length === 3 && parts[2] === 'main.rs');
|
|
194
240
|
return { joue, test: true, matiere };
|
|
195
241
|
}
|
|
242
|
+
// The unit tests near their module, compiled with it: `tests.rs`, the files of `tests/`.
|
|
243
|
+
if (unitaire(parts)) {
|
|
244
|
+
return { joue: parts.at(-1).endsWith('.rs'), test: true, matiere };
|
|
245
|
+
}
|
|
196
246
|
return matiere ? { joue: false, test: false, matiere: true } : null;
|
|
197
247
|
}
|
|
248
|
+
|
|
249
|
+
// The tables of a manifest that declare what its tests depend on.
|
|
250
|
+
const DES_TESTS = 'dev-dependencies';
|
|
251
|
+
|
|
252
|
+
// The table <t> of a parsed manifest, an object; {} for any other value.
|
|
253
|
+
const table = t => (t !== null && typeof t === 'object' && !Array.isArray(t) ? t : {});
|
|
254
|
+
|
|
255
|
+
// The parts of the parsed manifests <a> and <b> that differ, out of the tables of the tests: each
|
|
256
|
+
// `[<table>]` (`[target.<cible>.<table>]` under `target`), a key out of every table bare.
|
|
257
|
+
function partiesHors(a, b) {
|
|
258
|
+
const cles = (x, y) => [...new Set([...Object.keys(x), ...Object.keys(y)])].sort();
|
|
259
|
+
const out = [];
|
|
260
|
+
for (const k of cles(a, b)) {
|
|
261
|
+
if (k === DES_TESTS || isDeepStrictEqual(a[k], b[k])) continue;
|
|
262
|
+
if (k !== 'target') {
|
|
263
|
+
const tableau = [a[k], b[k]].some(v => v !== null && typeof v === 'object');
|
|
264
|
+
out.push(tableau ? `[${k}]` : k);
|
|
265
|
+
continue;
|
|
266
|
+
}
|
|
267
|
+
const [ta, tb] = [table(a.target), table(b.target)];
|
|
268
|
+
for (const c of cles(ta, tb)) {
|
|
269
|
+
const [ca, cb] = [table(ta[c]), table(tb[c])];
|
|
270
|
+
for (const s of cles(ca, cb)) {
|
|
271
|
+
if (s !== DES_TESTS && !isDeepStrictEqual(ca[s], cb[s])) out.push(`[target.${c}.${s}]`);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
return out;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// The head of the test module, `#[cfg(test)]`, other attributes after it, then `mod tests`.
|
|
279
|
+
const TETE = String.raw`#\[cfg\(test\)\](?:\s*#\[[^\]\n]*\])*\s*(?:pub(?:\([^)]*\))?\s+)?mod\s+tests\s*`;
|
|
280
|
+
|
|
281
|
+
// The declaration of the test module in a file of code, `#[cfg(test)] mod tests;`, its lines and
|
|
282
|
+
// the blank line before them.
|
|
283
|
+
const DECLARATION = new RegExp(String.raw`(?:^\r?\n)?^[ \t]*${TETE};[ \t]*(?:\r?\n|$)`, 'gm');
|
|
284
|
+
|
|
285
|
+
// The head of an inline test module, `#[cfg(test)] mod tests {`.
|
|
286
|
+
const EN_LIGNE = new RegExp(String.raw`^[ \t]*${TETE}\{`, 'm');
|
|
287
|
+
|
|
288
|
+
// The lexemes of Rust whose braces and quotes are no code, each a sticky expression from its
|
|
289
|
+
// start: a raw string (`r#"…"#`, `br`, `cr`, its hashes captured), a string (`"…"`, `b"`, `c"`),
|
|
290
|
+
// a character or a byte (`'{'`, `b'{'`, `'\''`, `'\u{7B}'`); a lifetime (`'a`) is none.
|
|
291
|
+
const BRUTE = /(?<![\w])[bc]?r(#*)"/y;
|
|
292
|
+
const CHAINE = /(?<![\w])[bc]?"(?:\\[\s\S]|[^\\"])*"/y;
|
|
293
|
+
const CARACTERE = /(?<![\w])b?'(?:\\u\{[0-9a-fA-F]{1,6}\}|\\x[0-9a-fA-F]{2}|\\[\s\S]|[^\\'\n])'/y;
|
|
294
|
+
|
|
295
|
+
// The end of the lexeme of <texte> that starts at <i> and holds no code (a comment, nested ones
|
|
296
|
+
// included, a string, a character), its index past it; null when code starts at <i>. A lexeme
|
|
297
|
+
// left open ends with the text.
|
|
298
|
+
function finDuLexeme(texte, i) {
|
|
299
|
+
if (texte.startsWith('//', i)) {
|
|
300
|
+
const fin = texte.indexOf('\n', i);
|
|
301
|
+
return fin < 0 ? texte.length : fin;
|
|
302
|
+
}
|
|
303
|
+
if (texte.startsWith('/*', i)) {
|
|
304
|
+
let profondeur = 0;
|
|
305
|
+
for (let j = i; j < texte.length; j++) {
|
|
306
|
+
if (texte.startsWith('/*', j)) {
|
|
307
|
+
profondeur++;
|
|
308
|
+
j++;
|
|
309
|
+
} else if (texte.startsWith('*/', j)) {
|
|
310
|
+
j++;
|
|
311
|
+
if (--profondeur === 0) return j + 1;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
return texte.length;
|
|
315
|
+
}
|
|
316
|
+
for (const re of [BRUTE, CHAINE, CARACTERE]) {
|
|
317
|
+
re.lastIndex = i;
|
|
318
|
+
const m = re.exec(texte);
|
|
319
|
+
if (!m) continue;
|
|
320
|
+
if (re !== BRUTE) return m.index + m[0].length;
|
|
321
|
+
const fin = texte.indexOf(`"${m[1]}`, i + m[0].length);
|
|
322
|
+
return fin < 0 ? texte.length : fin + 1 + m[1].length;
|
|
323
|
+
}
|
|
324
|
+
return null;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// The inline test module of the Rust text <texte>, from its attribute to its closing brace and the
|
|
328
|
+
// end of that line, with the blank line before it; null for none, or for one never closed. The
|
|
329
|
+
// braces of a comment, a string or a character do not count.
|
|
330
|
+
function moduleEnLigne(texte) {
|
|
331
|
+
const m = EN_LIGNE.exec(texte);
|
|
332
|
+
if (!m) {
|
|
333
|
+
return null;
|
|
334
|
+
}
|
|
335
|
+
let profondeur = 0;
|
|
336
|
+
let i = m.index + m[0].length - 1;
|
|
337
|
+
while (i < texte.length) {
|
|
338
|
+
const fin = finDuLexeme(texte, i);
|
|
339
|
+
if (fin !== null) {
|
|
340
|
+
i = fin;
|
|
341
|
+
continue;
|
|
342
|
+
}
|
|
343
|
+
if (texte[i] === '{') {
|
|
344
|
+
profondeur++;
|
|
345
|
+
} else if (texte[i] === '}' && --profondeur === 0) {
|
|
346
|
+
const ligne = texte.indexOf('\n', i);
|
|
347
|
+
const debut = /\n\r?\n$/.test(texte.slice(0, m.index))
|
|
348
|
+
? texte.lastIndexOf('\n', m.index - 2) + 1
|
|
349
|
+
: m.index;
|
|
350
|
+
return texte.slice(debut, ligne < 0 ? texte.length : ligne + 1);
|
|
351
|
+
}
|
|
352
|
+
i++;
|
|
353
|
+
}
|
|
354
|
+
return null;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* The parts of a file of code of a crate that change from <avant> (null: no file) to <apres> out
|
|
359
|
+
* of its test module: the declaration `#[cfg(test)] mod tests;` added or removed, an inline
|
|
360
|
+
* `#[cfg(test)] mod tests { … }` removed, as the testwriter moves it into tests.rs. The lines
|
|
361
|
+
* compare as they are, the module's blank line before it apart.
|
|
362
|
+
*/
|
|
363
|
+
function codeHorsDuModuleDeTest(avant, apres) {
|
|
364
|
+
const [a, b] = [(avant ?? '').replace(DECLARATION, ''), apres.replace(DECLARATION, '')];
|
|
365
|
+
const [ma, mb] = [moduleEnLigne(a), moduleEnLigne(b)];
|
|
366
|
+
if (mb !== null && mb !== ma) {
|
|
367
|
+
return ['le module de test en ligne, qui va dans tests.rs'];
|
|
368
|
+
}
|
|
369
|
+
const lignes = (texte, m) => (m === null ? texte : texte.replace(m, '')).split('\n');
|
|
370
|
+
const [la, lb] = [lignes(a, ma), lignes(b, mb)];
|
|
371
|
+
const n = Array.from({ length: Math.max(la.length, lb.length) }, (_, k) => k).find(
|
|
372
|
+
k => la[k] !== lb[k]
|
|
373
|
+
);
|
|
374
|
+
if (n === undefined) {
|
|
375
|
+
return [];
|
|
376
|
+
}
|
|
377
|
+
const ligne = (lb[n] ?? la[n]).trim();
|
|
378
|
+
return [`le code hors du module de test (« ${ligne || 'une ligne vide'} »)`];
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* The parts of a file of a crate at <chemin> (absolute, or from <racine>) that change from
|
|
383
|
+
* <avant> (null: no file) to <apres> out of the part of its tests: of its Cargo.toml, the tables
|
|
384
|
+
* of its tests; of a file of code of its `src/`, its test module. Null for any other file.
|
|
385
|
+
* @param {string} chemin
|
|
386
|
+
* @param {string} racine
|
|
387
|
+
* @param {string | null} avant
|
|
388
|
+
* @param {string} apres
|
|
389
|
+
*/
|
|
390
|
+
function horsDesTests(chemin, racine, avant, apres) {
|
|
391
|
+
const abs = path.resolve(racine, chemin);
|
|
392
|
+
const tous = crates(racine);
|
|
393
|
+
if (abs.endsWith('.rs')) {
|
|
394
|
+
const c = composantDans(
|
|
395
|
+
tous.map(x => x.composant),
|
|
396
|
+
racine,
|
|
397
|
+
abs
|
|
398
|
+
);
|
|
399
|
+
const parts = c ? path.relative(c.dossier, abs).split(path.sep) : [];
|
|
400
|
+
return parts[0] === 'src' && !unitaire(parts) ? codeHorsDuModuleDeTest(avant, apres) : null;
|
|
401
|
+
}
|
|
402
|
+
if (path.basename(abs) !== 'Cargo.toml') return null;
|
|
403
|
+
if (!tous.some(c => path.join(c.composant.dossier, 'Cargo.toml') === abs)) return null;
|
|
404
|
+
const { parse } = require('smol-toml');
|
|
405
|
+
const lire = texte => {
|
|
406
|
+
try {
|
|
407
|
+
return { valeur: parse(texte ?? '') };
|
|
408
|
+
} catch (e) {
|
|
409
|
+
return { faute: `le manifeste entier, illisible (${e.message.split('\n')[0]})` };
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
const [a, b] = [lire(avant), lire(apres)];
|
|
413
|
+
if (a.faute || b.faute) return [a.faute ?? b.faute];
|
|
414
|
+
return partiesHors(a.valeur, b.valeur);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/** What the testwriter writes of the manifests (scripts/jointure.d.ts, `manifestes`). */
|
|
418
|
+
export const manifestes = { verrous: ['Cargo.lock'], horsDesTests };
|
|
@@ -5,14 +5,16 @@
|
|
|
5
5
|
// entries alone.
|
|
6
6
|
//
|
|
7
7
|
// - Where it is found: a repository with a Cargo.toml at its root, the manifest of its workspace
|
|
8
|
-
// or of its one crate (`trouve`). Its
|
|
9
|
-
//
|
|
10
|
-
//
|
|
8
|
+
// or of its one crate (`trouve`). Its one tool of npm is what its scripts import, smol-toml, the
|
|
9
|
+
// reader of a Cargo.toml (`outils`, an optional peer of the package, which the update adds to a
|
|
10
|
+
// project of cargo alone): cargo and its subcommands live on the machine, and the update
|
|
11
|
+
// installs the binaries the module runs, nextest, cargo-deny and sccache, at their versions
|
|
11
12
|
// (`binaires`, ./binaires.json). What cargo writes in a project: `target` (`ignorer`).
|
|
12
13
|
// - Where cargo writes, which the envelope opens to a session (`sorties`), and the rules that
|
|
13
14
|
// refuse a role that writes the test runner run directly (`droits`).
|
|
14
15
|
// - The components, a file's, the shared test material, the components that play tests, the
|
|
15
|
-
// readers of a crate
|
|
16
|
+
// readers of a crate, the rule of a test file and what the testwriter writes of the manifests
|
|
17
|
+
// (./composants.mjs).
|
|
16
18
|
// - The crates touched since a commit and their dependents (./touches.mjs).
|
|
17
19
|
// - The elements of a lot, one per crate (./elements-du-lot.mjs).
|
|
18
20
|
// - The commands `tester`, `verifier`, `typer` and `preparer` (./commandes.mjs), each described,
|
|
@@ -36,11 +38,13 @@ import {
|
|
|
36
38
|
estUnTest,
|
|
37
39
|
joueDesTests,
|
|
38
40
|
lecteurs,
|
|
41
|
+
manifestes,
|
|
39
42
|
matieres,
|
|
40
43
|
} from './composants.mjs';
|
|
41
44
|
import { elementsDuLot } from './elements-du-lot.mjs';
|
|
42
45
|
import { enRetard, SORTIE } from './index-interfaces.mjs';
|
|
43
46
|
import { miseAJour } from './mise-a-jour.mjs';
|
|
47
|
+
import { CACHE } from './sccache.mjs';
|
|
44
48
|
import { touches } from './touches.mjs';
|
|
45
49
|
import { verdict } from './verdict.mjs';
|
|
46
50
|
|
|
@@ -54,16 +58,19 @@ export default {
|
|
|
54
58
|
nom: 'cargo',
|
|
55
59
|
trouve,
|
|
56
60
|
signe: 'un Cargo.toml à la racine',
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
//
|
|
61
|
+
// The reader of TOML by which the lock judges a Cargo.toml (./composants.mjs, `manifestes`).
|
|
62
|
+
outils: ['smol-toml'],
|
|
63
|
+
// The binaries the module runs, each at an exact version: nextest and cargo-deny at the ones the
|
|
64
|
+
// probe of grillhouse-pkl.1 measured; sccache, the cache of compilation common to the copies
|
|
65
|
+
// (./sccache.mjs), at the last release of mozilla/sccache, v0.19.0 (2026-10-24).
|
|
60
66
|
binaires: JSON.parse(readFileSync(ici('binaires.json'), 'utf8')),
|
|
61
67
|
// What cargo writes in a project: its target directory.
|
|
62
68
|
ignorer: ['target'],
|
|
63
69
|
// Where cargo writes, in writing: the target directory of the workspace; in its home, the
|
|
64
70
|
// registry's index and sources, the git dependencies, cargo-deny's advisories, and the files of
|
|
65
71
|
// its locks and of the SQLite cache of its packages (`.package-cache`, `.package-cache-mutate`,
|
|
66
|
-
// `.global-cache`), files without a trailing
|
|
72
|
+
// `.global-cache`), files without a trailing `/`; the cache of sccache, common to the copies
|
|
73
|
+
// (./sccache.mjs), where a server of sccache the session starts writes. What it reads, read-only: its home, `~/.cargo`
|
|
67
74
|
// (its binaries, its `env`, which the shells source, and its configuration stay unwritten), and
|
|
68
75
|
// rustup's toolchains, `~/.rustup`. Measured on 2026-10-30: `cargo fetch --locked` of
|
|
69
76
|
// osc-bridge in bwrap with these mounts alone, green, the cache of its packages written.
|
|
@@ -76,6 +83,7 @@ export default {
|
|
|
76
83
|
'~/.cargo/.package-cache',
|
|
77
84
|
'~/.cargo/.package-cache-mutate',
|
|
78
85
|
'~/.cargo/.global-cache',
|
|
86
|
+
CACHE,
|
|
79
87
|
],
|
|
80
88
|
propres: [],
|
|
81
89
|
lues: ['~/.cargo/', '~/.rustup/'],
|
|
@@ -98,6 +106,7 @@ export default {
|
|
|
98
106
|
commandes,
|
|
99
107
|
verdict,
|
|
100
108
|
estUnTest,
|
|
109
|
+
manifestes,
|
|
101
110
|
fichiersEngendres: () => [
|
|
102
111
|
{
|
|
103
112
|
nom: "l'index des interfaces",
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
// The cache of compilation of the module cargo: sccache (Mozilla), the wrapper of rustc
|
|
2
|
+
// (`RUSTC_WRAPPER=sccache`) that Firefox and the CI of Rust use, which the update installs
|
|
3
|
+
// (./binaires.json). Each copy keeps its own target directory, so that two compilations never wait
|
|
4
|
+
// on the lock cargo takes on a target directory; sccache shares their compilations, its cache one
|
|
5
|
+
// directory of the home (`SCCACHE_DIR`, ~/.cache/sccache, sccache's default on Linux, named so
|
|
6
|
+
// that the envelope opens the same, ./index.mjs `sorties`), common to every copy of the machine.
|
|
7
|
+
// Every command of the module that compiles (tests, verification, typing, clippy) runs cargo
|
|
8
|
+
// under this environment, in a copy as in an agent's envelope.
|
|
9
|
+
//
|
|
10
|
+
// - One server per copy and per namespace of processes: by default the server of sccache listens
|
|
11
|
+
// on 127.0.0.1:4226 (README of v0.19.0), one for the whole machine, and the envelope shares the
|
|
12
|
+
// network, so that a server born in one agent's envelope would serve another copy, and one born
|
|
13
|
+
// outside would compile for an agent out of his envelope. Each run names its server's socket
|
|
14
|
+
// (`SCCACHE_SERVER_UDS`), an abstract unix socket (the README's `\x00<name>` form), named after
|
|
15
|
+
// the copy and the namespace of processes it runs in (`/proc/self/ns/pid`), which each envelope
|
|
16
|
+
// creates (`--unshare-pid`): the two sides of an envelope, and two envelopes of one copy, never
|
|
17
|
+
// share a server, whatever the environment says. An abstract socket writes no file, so that
|
|
18
|
+
// neither the read-only copy nor the 108 bytes of a socket's path bind it, and it goes with its
|
|
19
|
+
// server, leaving no stale file. The disk cache stays common.
|
|
20
|
+
// - A wrapper the project sets already is its own: the run keeps it, without sccache. It is read
|
|
21
|
+
// as cargo reads it: the environment (`RUSTC_WRAPPER`, `CARGO_BUILD_RUSTC_WRAPPER`), then
|
|
22
|
+
// `build.rustc-wrapper` of each `.cargo/config.toml` (or `.cargo/config`) from the project up to
|
|
23
|
+
// the root, then of `$CARGO_HOME` (`~/.cargo` by default).
|
|
24
|
+
// - A machine without sccache on the PATH of the command is refused before any run of cargo, in
|
|
25
|
+
// one line that names it and the command that installs it (`sccacheAbsent`), rather than on the
|
|
26
|
+
// error of cargo that cannot run its wrapper.
|
|
27
|
+
import { createHash } from 'node:crypto';
|
|
28
|
+
import { accessSync, constants, readFileSync, readlinkSync, realpathSync } from 'node:fs';
|
|
29
|
+
import { createRequire } from 'node:module';
|
|
30
|
+
import { homedir } from 'node:os';
|
|
31
|
+
import path from 'node:path';
|
|
32
|
+
|
|
33
|
+
// The loader of smol-toml, an optional peer of the package, a tool of this module.
|
|
34
|
+
const require = createRequire(import.meta.url);
|
|
35
|
+
|
|
36
|
+
/** The cache of sccache, from the home: what the envelope opens in writing. */
|
|
37
|
+
export const CACHE = '~/.cache/sccache/';
|
|
38
|
+
|
|
39
|
+
// The directories of cargo's configuration for a run in <racine> under <env>, in cargo's order:
|
|
40
|
+
// `.cargo` of the project and of each parent up to the root, then `$CARGO_HOME`.
|
|
41
|
+
function dossiersDeConfiguration(racine, env) {
|
|
42
|
+
const dossiers = [];
|
|
43
|
+
for (let d = path.resolve(racine); ; d = path.dirname(d)) {
|
|
44
|
+
dossiers.push(path.join(d, '.cargo'));
|
|
45
|
+
if (path.dirname(d) === d) {
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const maison = env.CARGO_HOME || path.join(env.HOME || homedir(), '.cargo');
|
|
50
|
+
return [...dossiers, maison];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// The wrapper of rustc the project at <racine> sets, as cargo reads it (see the header), or null.
|
|
54
|
+
function lanceurDuProjet(racine, env) {
|
|
55
|
+
const parLEnvironnement = env.RUSTC_WRAPPER || env.CARGO_BUILD_RUSTC_WRAPPER;
|
|
56
|
+
if (parLEnvironnement) {
|
|
57
|
+
return parLEnvironnement;
|
|
58
|
+
}
|
|
59
|
+
const { parse } = require('smol-toml');
|
|
60
|
+
for (const dossier of dossiersDeConfiguration(racine, env)) {
|
|
61
|
+
for (const nom of ['config.toml', 'config']) {
|
|
62
|
+
try {
|
|
63
|
+
const w = parse(readFileSync(path.join(dossier, nom), 'utf8'))?.build?.['rustc-wrapper'];
|
|
64
|
+
if (w) {
|
|
65
|
+
return String(w);
|
|
66
|
+
}
|
|
67
|
+
} catch {
|
|
68
|
+
// An absent or unreadable configuration sets no wrapper.
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The namespace of processes this process runs in, `pid:[<inode>]`. */
|
|
76
|
+
export const espaceDesProcessus = () => readlinkSync('/proc/self/ns/pid');
|
|
77
|
+
|
|
78
|
+
const reel = p => {
|
|
79
|
+
try {
|
|
80
|
+
return realpathSync(p);
|
|
81
|
+
} catch {
|
|
82
|
+
return path.resolve(p);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* The socket of the server of sccache for the copy at <racine> in the namespace of processes
|
|
88
|
+
* <espace>: an abstract unix socket, named after both.
|
|
89
|
+
* @param {string} racine
|
|
90
|
+
* @param {string} [espace] this process's namespace by default
|
|
91
|
+
*/
|
|
92
|
+
export function socketDuServeur(racine, espace = espaceDesProcessus()) {
|
|
93
|
+
const empreinte = createHash('sha256')
|
|
94
|
+
.update(`${reel(racine)}\0${espace}`)
|
|
95
|
+
.digest('hex');
|
|
96
|
+
return `\\x00grillhouse-sccache-${empreinte.slice(0, 16)}`;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* The line that refuses a run in <racine> whose PATH (<env>'s) holds no sccache, the command that
|
|
101
|
+
* installs it named; null when one is there, or when the project sets its own wrapper.
|
|
102
|
+
* @param {string} racine
|
|
103
|
+
* @param {NodeJS.ProcessEnv} env
|
|
104
|
+
* @returns {string | null}
|
|
105
|
+
*/
|
|
106
|
+
export function sccacheAbsent(racine, env) {
|
|
107
|
+
if (lanceurDuProjet(racine, env)) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
const present = (env.PATH ?? '')
|
|
111
|
+
.split(path.delimiter)
|
|
112
|
+
.filter(Boolean)
|
|
113
|
+
.some(d => {
|
|
114
|
+
try {
|
|
115
|
+
accessSync(path.join(d, 'sccache'), constants.X_OK);
|
|
116
|
+
return true;
|
|
117
|
+
} catch {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
return present
|
|
122
|
+
? null
|
|
123
|
+
: "⛔ sccache absent du PATH : cargo compile à travers lui (RUSTC_WRAPPER=sccache) ; `npx grillhouse maj` l'installe avec les autres binaires du module cargo.";
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* <env> with rustc wrapped by sccache for the copy at <racine>, its cache the home's, its server
|
|
128
|
+
* the copy's; <env> as it is when the project sets its own wrapper.
|
|
129
|
+
* @param {string} racine
|
|
130
|
+
* @param {NodeJS.ProcessEnv} env
|
|
131
|
+
* @returns {NodeJS.ProcessEnv}
|
|
132
|
+
*/
|
|
133
|
+
export function avecSccache(racine, env) {
|
|
134
|
+
if (lanceurDuProjet(racine, env)) {
|
|
135
|
+
return env;
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
...env,
|
|
139
|
+
RUSTC_WRAPPER: 'sccache',
|
|
140
|
+
SCCACHE_DIR: path.join(env.HOME || homedir(), '.cache', 'sccache'),
|
|
141
|
+
SCCACHE_SERVER_UDS: socketDuServeur(racine),
|
|
142
|
+
};
|
|
143
|
+
}
|
|
@@ -9,7 +9,10 @@
|
|
|
9
9
|
// `ws-core::integ`, `ws-core::bin/outil`), its target's source.
|
|
10
10
|
// - `<dossier>/nextest/<run>-<crate>.xml`, the JUnit report of each run of nextest: each
|
|
11
11
|
// `testsuite`, a test binary, gives a test file, each `testcase` a test, failed when it holds a
|
|
12
|
-
// `failure` or an `error`, skipped when it holds `skipped`; its message, the failure's.
|
|
12
|
+
// `failure` or an `error`, skipped when it holds `skipped`; its message, the failure's. A unit
|
|
13
|
+
// test of a module `tests` that lives in a file of its own (`server::tests::relais`, in
|
|
14
|
+
// `src/server/tests.rs` beside the library's root, grillhouse-agr) gives that file, so that the
|
|
15
|
+
// proof of the red finds the result of a new tests.rs.
|
|
13
16
|
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
14
17
|
import path from 'node:path';
|
|
15
18
|
|
|
@@ -46,26 +49,63 @@ const attribut = (balise, nom) => {
|
|
|
46
49
|
return m ? texte(m[1]) : null;
|
|
47
50
|
};
|
|
48
51
|
|
|
49
|
-
// The
|
|
52
|
+
// The file of the unit test <nom> (its module path, `server::tests::relais`) of the binary whose
|
|
53
|
+
// root is <racine>: the file of its module `tests` that exists, as rustc finds a module's file
|
|
54
|
+
// from its crate root's folder — `server/tests.rs` or `server/tests/mod.rs`, a module under it
|
|
55
|
+
// `server/tests/<m>.rs` or `server/tests/<m>/mod.rs`, the deepest first; <racine> for a test of
|
|
56
|
+
// no such file (an inline module).
|
|
57
|
+
function fichierDuTest(racine, nom) {
|
|
58
|
+
const parts = nom.split('::').slice(0, -1);
|
|
59
|
+
const k = parts.indexOf('tests');
|
|
60
|
+
if (k < 0) {
|
|
61
|
+
return racine;
|
|
62
|
+
}
|
|
63
|
+
const dossier = path.join(path.dirname(racine), ...parts.slice(0, k), 'tests');
|
|
64
|
+
const sous = parts.slice(k + 1);
|
|
65
|
+
for (let j = sous.length; j >= 0; j--) {
|
|
66
|
+
const d = path.join(dossier, ...sous.slice(0, j));
|
|
67
|
+
const candidats = [`${d}.rs`, path.join(d, 'mod.rs')];
|
|
68
|
+
const trouve = candidats.find(f => existsSync(f));
|
|
69
|
+
if (trouve) {
|
|
70
|
+
return trouve;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return racine;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// The test files of the JUnit report <xml>, each binary's file read in <cibles>, each unit test
|
|
77
|
+
// under its own file (`fichierDuTest`).
|
|
50
78
|
function rapportsDe(xml, cibles) {
|
|
51
79
|
const out = [];
|
|
52
80
|
for (const s of xml.matchAll(/<testsuite\b([^>]*?)(?:\/>|>([\s\S]*?)<\/testsuite>)/g)) {
|
|
53
81
|
const nom = attribut(s[1], 'name') ?? '';
|
|
54
|
-
const
|
|
82
|
+
const racine = cibles[nom] ?? nom;
|
|
83
|
+
const parFichier = new Map([[racine, []]]);
|
|
55
84
|
for (const c of (s[2] ?? '').matchAll(/<testcase\b([^>]*?)(?:\/>|>([\s\S]*?)<\/testcase>)/g)) {
|
|
56
85
|
const corps = c[2] ?? '';
|
|
57
86
|
const echec = /<(failure|error)\b([^>]*?)(?:\/>|>([\s\S]*?)<\/\1>)/.exec(corps);
|
|
58
87
|
const etat = echec ? 'failed' : /<skipped\b/.test(corps) ? 'skipped' : 'passed';
|
|
59
88
|
const message = echec ? (attribut(echec[2], 'message') ?? texte(echec[3] ?? '')) : '';
|
|
60
89
|
const titre = attribut(c[1], 'name') ?? '';
|
|
61
|
-
|
|
90
|
+
const test = { titre, nom: titre, etat, message };
|
|
91
|
+
const fichier = cibles[nom] ? fichierDuTest(racine, titre) : racine;
|
|
92
|
+
if (!parFichier.has(fichier)) {
|
|
93
|
+
parFichier.set(fichier, []);
|
|
94
|
+
}
|
|
95
|
+
parFichier.get(fichier).push(test);
|
|
96
|
+
}
|
|
97
|
+
for (const [fichier, deCeFichier] of parFichier) {
|
|
98
|
+
// The binary's root without a test of its own reports nothing, but for an empty binary.
|
|
99
|
+
if (deCeFichier.length === 0 && parFichier.size > 1) {
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
out.push({
|
|
103
|
+
fichier,
|
|
104
|
+
etat: deCeFichier.some(t => t.etat === 'failed') ? 'failed' : 'passed',
|
|
105
|
+
message: '',
|
|
106
|
+
tests: deCeFichier,
|
|
107
|
+
});
|
|
62
108
|
}
|
|
63
|
-
out.push({
|
|
64
|
-
fichier: cibles[nom] ?? nom,
|
|
65
|
-
etat: tests.some(t => t.etat === 'failed') ? 'failed' : 'passed',
|
|
66
|
-
message: '',
|
|
67
|
-
tests,
|
|
68
|
-
});
|
|
69
109
|
}
|
|
70
110
|
return out;
|
|
71
111
|
}
|
|
@@ -32,7 +32,8 @@
|
|
|
32
32
|
// (./vitest-config/base.mjs).
|
|
33
33
|
// - The verdict: the summaries of Turborepo and the reports of Vitest of a results directory
|
|
34
34
|
// (./verdict.mjs).
|
|
35
|
-
// - The rule of a test file
|
|
35
|
+
// - The rule of a test file and what the testwriter writes of the manifests
|
|
36
|
+
// (./regle-des-tests.mjs).
|
|
36
37
|
// - The generated files, each its command, the guard that checks it and the names its findings
|
|
37
38
|
// carry: the index of the interfaces, the turbo.json of the packages, the reports of API.
|
|
38
39
|
// - The guards of structure, in the order they play.
|
|
@@ -53,7 +54,7 @@ import { elementsDuLot } from './elements-du-lot.mjs';
|
|
|
53
54
|
import { A_ELAGUER, lireSarif, RESULTATS } from '../../resultats.mjs';
|
|
54
55
|
import { paquets } from '../../paquets.mjs';
|
|
55
56
|
import { lecteurs } from './lecteurs.mjs';
|
|
56
|
-
import { estUnTest } from './regle-des-tests.mjs';
|
|
57
|
+
import { estUnTest, manifestes } from './regle-des-tests.mjs';
|
|
57
58
|
import { SCRIPT_DES_TESTS } from './script-des-tests.mjs';
|
|
58
59
|
import { verdict } from './verdict.mjs';
|
|
59
60
|
import { miseAJour } from './mise-a-jour.mjs';
|
|
@@ -268,6 +269,7 @@ export default {
|
|
|
268
269
|
}),
|
|
269
270
|
verdict,
|
|
270
271
|
estUnTest,
|
|
272
|
+
manifestes,
|
|
271
273
|
fichiersEngendres: () => [
|
|
272
274
|
engendre(
|
|
273
275
|
{
|
|
@@ -10,7 +10,15 @@
|
|
|
10
10
|
// whose package exports `./test-fixtures` (`matieres` of scripts/langages/typescript/consommateurs.mjs).
|
|
11
11
|
//
|
|
12
12
|
// Any other file is none of them: null.
|
|
13
|
+
//
|
|
14
|
+
// What the testwriter writes of the manifests (`manifestes`): the field that declares what the
|
|
15
|
+
// tests of a package depend on, `devDependencies` of its package.json (npm's docs,
|
|
16
|
+
// « devDependencies »), as the author of a test of Bazel declares the deps of its target; and
|
|
17
|
+
// package-lock.json at the root, which npm brings in line with it. A change of any other field is
|
|
18
|
+
// named by it; the root package.json is no package's.
|
|
13
19
|
import path from 'node:path';
|
|
20
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
21
|
+
import { dossiers } from './composants.mjs';
|
|
14
22
|
import { matieres, NOM_DE_TEST } from './consommateurs.mjs';
|
|
15
23
|
|
|
16
24
|
const DOSSIERS = new Set(['test', 'tests', '__tests__']);
|
|
@@ -37,3 +45,32 @@ export function estUnTest(chemin, racine) {
|
|
|
37
45
|
const matiere = matieres(racine).some(m => isInside(abs, m.dir));
|
|
38
46
|
return joue || test || matiere ? { joue, test, matiere } : null;
|
|
39
47
|
}
|
|
48
|
+
|
|
49
|
+
// The field of a manifest that declares what its tests depend on.
|
|
50
|
+
const DES_TESTS = 'devDependencies';
|
|
51
|
+
|
|
52
|
+
// The fields of the package.json of a package at <chemin>, absolute or from <racine>, that change
|
|
53
|
+
// from <avant> (null: no file) to <apres> out of the field of its tests; null when <chemin> is the
|
|
54
|
+
// manifest of no package.
|
|
55
|
+
function horsDesTests(chemin, racine, avant, apres) {
|
|
56
|
+
const abs = path.resolve(racine, chemin);
|
|
57
|
+
if (!dossiers(racine).some(d => path.join(d.dir, 'package.json') === abs)) return null;
|
|
58
|
+
const lire = texte => {
|
|
59
|
+
try {
|
|
60
|
+
const v = texte === null ? {} : JSON.parse(texte);
|
|
61
|
+
return v !== null && typeof v === 'object' && !Array.isArray(v)
|
|
62
|
+
? { valeur: v }
|
|
63
|
+
: { faute: 'le manifeste entier, qui n’est pas un objet' };
|
|
64
|
+
} catch (e) {
|
|
65
|
+
return { faute: `le manifeste entier, illisible (${e.message})` };
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const [a, b] = [lire(avant), lire(apres)];
|
|
69
|
+
if (a.faute || b.faute) return [a.faute ?? b.faute];
|
|
70
|
+
return [...new Set([...Object.keys(a.valeur), ...Object.keys(b.valeur)])]
|
|
71
|
+
.filter(k => k !== DES_TESTS && !isDeepStrictEqual(a.valeur[k], b.valeur[k]))
|
|
72
|
+
.sort();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// What the testwriter writes of the manifests (scripts/jointure.d.ts, `manifestes`).
|
|
76
|
+
export const manifestes = { verrous: ['package-lock.json'], horsDesTests };
|