@roomi-fields/grillhouse 0.28.2 → 0.29.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.
Files changed (71) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/bin/grillhouse.mjs +55 -14
  3. package/cadre/templates/projet/CLAUDE.md +1 -1
  4. package/cadre/templates/projet/README.md +11 -11
  5. package/cadre/templates/projet/_gitignore +2 -5
  6. package/charte.md +24 -3
  7. package/docs/ARCHITECTURE.md +279 -31
  8. package/docs/INTERFACE.md +59 -11
  9. package/package.json +1 -1
  10. package/scripts/aiguillage.mjs +324 -0
  11. package/scripts/avancement.mjs +33 -50
  12. package/scripts/circuit.mjs +558 -146
  13. package/scripts/composition-des-langages.mjs +16 -1
  14. package/scripts/conformite.mjs +16 -0
  15. package/scripts/copies-finies.mjs +181 -29
  16. package/scripts/demon.mjs +134 -21
  17. package/scripts/enveloppe/enveloppe.mjs +8 -5
  18. package/scripts/enveloppe/lancer.sh +24 -15
  19. package/scripts/enveloppe/travail-de-la-copie.mjs +94 -11
  20. package/scripts/etapes.mjs +1 -1
  21. package/scripts/fusion-du-changelog.mjs +0 -1
  22. package/scripts/grillhouse-maj.mjs +16 -7
  23. package/scripts/integration/file.mjs +3 -3
  24. package/scripts/integration/integrer.mjs +3 -3
  25. package/scripts/jointure.d.ts +53 -17
  26. package/scripts/langages/cargo/commandes.mjs +152 -25
  27. package/scripts/langages/cargo/composants.mjs +94 -2
  28. package/scripts/langages/cargo/exemples.mjs +68 -1
  29. package/scripts/langages/cargo/index.mjs +21 -10
  30. package/scripts/langages/cargo/migrations/0.28.4-tailles-des-tests.mjs +35 -0
  31. package/scripts/langages/cargo/sccache.mjs +89 -6
  32. package/scripts/langages/cargo/squelette.mjs +72 -3
  33. package/scripts/langages/cargo/tailles-des-tests.mjs +195 -0
  34. package/scripts/langages/cargo/tests-de-head.mjs +159 -0
  35. package/scripts/langages/python/commandes.mjs +53 -9
  36. package/scripts/langages/python/composants.mjs +33 -3
  37. package/scripts/langages/python/exemples.mjs +19 -0
  38. package/scripts/langages/python/index.mjs +7 -2
  39. package/scripts/langages/python/squelette.mjs +119 -17
  40. package/scripts/langages/typescript/exemples.mjs +16 -0
  41. package/scripts/langages/typescript/index.mjs +6 -3
  42. package/scripts/langages/typescript/regle-des-tests.mjs +13 -0
  43. package/scripts/langages/typescript/squelette.mjs +18 -2
  44. package/scripts/langages/typescript/tests-de-nuit.mjs +50 -20
  45. package/scripts/langages/typescript/verifier.mjs +82 -288
  46. package/scripts/langages/typescript/vitest-config/base.mjs +8 -9
  47. package/scripts/langages/typescript/vitest-config/cibles.mjs +92 -53
  48. package/scripts/langages/typescript/vitest-config/duree.reporter.mjs +11 -5
  49. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +6 -1
  50. package/scripts/langages/typescript/vitest-config/mesure.mjs +3 -2
  51. package/scripts/langages/typescript/vitest.nuit.config.mjs +18 -13
  52. package/scripts/lecture-unique.mjs +51 -0
  53. package/scripts/mesure/base-de-passe.mjs +202 -9
  54. package/scripts/mesure/pression.mjs +9 -7
  55. package/scripts/nuit.sh +19 -12
  56. package/scripts/outil.mjs +72 -0
  57. package/scripts/paquet.mjs +39 -10
  58. package/scripts/resultats.mjs +22 -5
  59. package/scripts/services-du-noyau.mjs +16 -10
  60. package/scripts/session-start.sh +10 -1
  61. package/scripts/sortie.mjs +20 -1
  62. package/scripts/sources.mjs +3 -3
  63. package/scripts/sous-commandes.mjs +2 -0
  64. package/scripts/superviseur.mjs +369 -14
  65. package/scripts/tableau.mjs +219 -58
  66. package/scripts/verrou-de-machine.mjs +425 -37
  67. package/skills/developpeur/SKILL.md +11 -3
  68. package/skills/pitmaster/SKILL.md +64 -23
  69. package/skills/pitmaster/references/consigne-agent.md +4 -0
  70. package/skills/relecteur/SKILL.md +18 -6
  71. package/skills/testwriter/SKILL.md +11 -15
@@ -7,10 +7,12 @@
7
7
  // npx grillhouse verifier [--tout | --gardes] verifier
8
8
  // node commandes.mjs typer typer
9
9
  // npx grillhouse preparer preparer
10
- // npx grillhouse clippy | frontieres | index-interfaces each guard, its own script
10
+ // npx grillhouse tests-de-nuit tests-de-nuit
11
+ // npx grillhouse tailles-des-tests | clippy | frontieres | index-interfaces
12
+ // each guard, its own script
11
13
  //
12
- // - Each guard of structure of the module (./clippy.mjs, ./frontieres.mjs, ./index-interfaces.mjs)
13
- // is a command by its name too, its own script, as the module typescript's: the line of a red
14
+ // - Each guard of structure of the module (./tailles-des-tests.mjs, ./clippy.mjs,
15
+ // ./frontieres.mjs, ./index-interfaces.mjs) is a command by its name too, its own script, as the module typescript's: the line of a red
14
16
  // guard (`grillhouse <garde>`, scripts/gardes-du-cadre.mjs) names a command that exists.
15
17
  // - `tester` plays the tests of each crate chosen, one crate after the other. For a crate that
16
18
  // plays tests (./composants.mjs, `joueDesTests`): the build of its test targets, `cargo test
@@ -28,6 +30,19 @@
28
30
  // (`GRILLHOUSE_DEPUIS_LE_VERT`), the crates the changes since the last green touch and their
29
31
  // dependents (./touches.mjs), every crate when no last green counts. `--force` changes nothing:
30
32
  // cargo keeps no result of a test to replay. Another option goes to nextest.
33
+ // - A test target is named by its file, as `*_nuit_test.py` and `*.budget.test.*` (grillhouse-wbk):
34
+ // `tests/<nom>_nuit.rs` (or `tests/<nom>_nuit/main.rs`, the target `<nom>_nuit`) is a night
35
+ // test, `tests/<nom>_budget.rs` a time budget bench. A crate played whole leaves both out of
36
+ // nextest, in `tester` as in `verifier`, which then plays its library (`--lib`), its binaries
37
+ // (`--bins`) and each other test target (`--test <nom>`); its build still compiles them. The
38
+ // night plays them (`tests-de-nuit`), as the module typescript's `*.budget.test.*`. A path that
39
+ // names the file of one plays it, as Bazel builds a target tagged `manual` when named; a folder
40
+ // named leaves them out, as the day does.
41
+ // - A time budget bench plays alone, one test at a time (`--test-threads 1`), in a task `budget` of
42
+ // its own after the other tests: in `tests-de-nuit` and in a path that names it. A red of the
43
+ // task while the CPU pressure of the machine (`lirePression` of ./jointure) is at or above its
44
+ // threshold at its start or at its end is « à repasser », 75, said in one line with the
45
+ // pressure; at rest, a red.
31
46
  // - `verifier` plays the tests of the crates the changes since the last green touch and of their
32
47
  // dependents (every crate with `--tout`, or when no last green counts), as Turborepo's
33
48
  // `--filter=...[<commit>]`, then `cargo deny check`; green, it keeps the last green
@@ -39,7 +54,7 @@
39
54
  // project's root scripts `grillhouse:gardes` (the frame's guards) then `gardes` (its own), each
40
55
  // one the package.json holds a task of the root, by npm, without its tests nor cargo deny, and
41
56
  // keeps no last green.
42
- // - `tester` and `verifier` play under a temporary directory of their pass, the module's guard of
57
+ // - `tester`, `verifier` and `tests-de-nuit` play under a temporary directory of their pass, the module's guard of
43
58
  // the temporary directory, as the CI of osc-bridge (OB-ud1.3): a base (`ouvrirBase` of
44
59
  // ./jointure, genre `tests` or `verification`) in the temporary directory of the environment,
45
60
  // named in TMPDIR, TMP and TEMP to cargo, which nextest and the doctests inherit; removed at the
@@ -47,6 +62,9 @@
47
62
  // fails the pass (code 1), each name written on the error stream. A test makes its temporary
48
63
  // directory or file with the crate `tempfile` (`TempDir`, `NamedTempFile`), removed when dropped,
49
64
  // a failed test included, never a path built by hand under `std::env::temp_dir()`.
65
+ // - `tests-de-nuit`: the night tests then the benches of each crate that holds some; none, nothing
66
+ // plays and the code is 0. The night (scripts/nuit.sh) runs it after the full pass, and plays it
67
+ // again at rest after a 75.
50
68
  // - `typer`: `cargo check --all-targets`. `preparer`: `cargo fetch --locked`.
51
69
  // - Cargo runs with rustc wrapped by sccache, its cache common to the copies of the machine
52
70
  // (./sccache.mjs), in a copy as in an agent's envelope (grillhouse-cyr), its server started
@@ -54,8 +72,9 @@
54
72
  // and `typer` refuse, before any run of cargo, a PATH without sccache, in one line that names it
55
73
  // and `npx grillhouse maj`, which installs it (code 2).
56
74
  // - Nextest reads the frame's profile `grillhouse` (./nextest.toml, a tool's configuration under
57
- // the project's own, `--tool-config-file`), whose JUnit report lands at
58
- // `<target>/nextest/grillhouse/junit.xml`.
75
+ // the project's own, `--tool-config-file`), whose JUnit report lands in nextest's store, at
76
+ // `<workspace root>/target/nextest/grillhouse/junit.xml` (nextest's default `store.dir`, under
77
+ // the workspace's root, even when the compilations' target directory lies elsewhere).
59
78
  // - While the environment names a results directory (`GRILLHOUSE_RESULTATS`), the run writes
60
79
  // there what ./verdict.mjs reads: its tasks, each planned before it plays (`code` null until it
61
80
  // ran), and the JUnit report of each run of nextest. A task of the workspace is named after its
@@ -89,13 +108,16 @@ import {
89
108
  avecLaMachine,
90
109
  CHANGEMENTS,
91
110
  DEPUIS_LE_VERT,
111
+ ecrirePression,
92
112
  garderLeVert,
93
113
  ligneDesRestes,
114
+ lirePression,
94
115
  mesure,
95
116
  ouvrirBase,
96
117
  retirerALInterruption,
118
+ SEUIL_PRESSION,
97
119
  } from '../../services-du-noyau.mjs';
98
- import { composantDans, crates, joueDesTests, metadonnees } from './composants.mjs';
120
+ import { BANC, composantDans, crates, DE_NUIT, joueDesTests, metadonnees } from './composants.mjs';
99
121
  import { avecSccache, demarrerLeServeur, sccacheAbsent } from './sccache.mjs';
100
122
  import { touchesDesFichiers } from './touches.mjs';
101
123
  import { JUNIT, TACHES } from './verdict.mjs';
@@ -103,20 +125,39 @@ import { JUNIT, TACHES } from './verdict.mjs';
103
125
  const ICI = fileURLToPath(import.meta.url);
104
126
  const NEXTEST = path.join(path.dirname(ICI), 'nextest.toml');
105
127
  const PROFIL = 'grillhouse';
106
- export const NOMS = ['tester', 'verifier', 'typer', 'preparer'];
128
+ export const NOMS = ['tester', 'verifier', 'typer', 'preparer', 'tests-de-nuit'];
107
129
  const A_REPASSER = 75;
108
130
  const RACINE = '//';
131
+ // The task of the time budget benches of a crate.
132
+ const BUDGET = 'budget';
109
133
  const VERROU = 'Cargo.lock';
110
134
  // The commands that play the exact versions of the repository, refused without its Cargo.lock.
111
- const VERROUILLEES = ['tester', 'verifier', 'preparer'];
135
+ const VERROUILLEES = ['tester', 'verifier', 'preparer', 'tests-de-nuit'];
112
136
  // The commands that compile, refused without sccache on the PATH (./sccache.mjs).
113
- const COMPILENT = ['tester', 'verifier', 'typer'];
137
+ const COMPILENT = ['tester', 'verifier', 'typer', 'tests-de-nuit'];
138
+ // The kinds of a target that are no library.
139
+ const PAS_UNE_BIBLIOTHEQUE = ['test', 'bin', 'example', 'bench', 'custom-build'];
140
+
141
+ /**
142
+ * Whether the target <t> of a crate is a test target out of the day: `nuit`, `banc`, or null.
143
+ * @param {{ kind: string[], name: string }} t
144
+ */
145
+ export function horsDuJour(t) {
146
+ if (!t.kind.includes('test')) {
147
+ return null;
148
+ }
149
+ if (t.name.endsWith(DE_NUIT)) {
150
+ return 'nuit';
151
+ }
152
+ return t.name.endsWith(BANC) ? 'banc' : null;
153
+ }
114
154
  // The subcommands of cargo that compile, before which the server of sccache starts.
115
155
  const COMPILATIONS = ['test', 'nextest', 'check'];
116
156
 
117
157
  /** The guards of structure of the module, in the order they play: each its name, its script beside
118
158
  * this one, and its arguments as a guard. */
119
159
  export const GARDES = [
160
+ { nom: 'tailles-des-tests', args: [] },
120
161
  { nom: 'clippy', args: [] },
121
162
  { nom: 'frontieres', args: [] },
122
163
  { nom: 'index-interfaces', args: ['--verifier'] },
@@ -156,6 +197,8 @@ function passe(racine, env) {
156
197
  const cibles = {};
157
198
  // Cargo compiles through sccache (./sccache.mjs).
158
199
  const compilation = avecSccache(racine, env);
200
+ // The CPU pressure of the machine, the file <env> names or the kernel's.
201
+ const pression = () => lirePression(env.GRILLHOUSE_PRESSION_CPU || undefined);
159
202
  const ecrire = () => {
160
203
  if (!dossier) {
161
204
  return;
@@ -192,6 +235,8 @@ function passe(racine, env) {
192
235
  if (COMPILATIONS.includes(args[0])) {
193
236
  demarrerLeServeur(racine, env);
194
237
  }
238
+ const banc = t.script === BUDGET;
239
+ const avant = banc ? pression() : null;
195
240
  let r;
196
241
  if (journal) {
197
242
  // The output of cargo, both streams in their order, goes to the task's log, then to the
@@ -215,7 +260,11 @@ function passe(racine, env) {
215
260
  t.code = r.error ? 127 : (r.status ?? 128 + (constants.signals[r.signal] ?? 0));
216
261
  if (junit && dossier && existsSync(junit)) {
217
262
  mkdirSync(path.join(dossier, JUNIT), { recursive: true });
218
- copyFileSync(junit, path.join(dossier, JUNIT, `${id}-${t.paquet}.xml`));
263
+ const suffixe = t.script === 'nextest' ? '' : `-${t.script}`;
264
+ copyFileSync(junit, path.join(dossier, JUNIT, `${id}-${t.paquet}${suffixe}.xml`));
265
+ }
266
+ if (banc && t.code !== 0) {
267
+ sousCharge(t, [avant, pression()]);
219
268
  }
220
269
  ecrire();
221
270
  return t.code;
@@ -230,6 +279,25 @@ function passe(racine, env) {
230
279
  };
231
280
  }
232
281
 
282
+ // A red of the time budget benches of the task <t>, the pressures <pressions> measured at its start
283
+ // and at its end: « à repasser » (75) when one is at or above the threshold, said; else its code
284
+ // stands, a pressure that does not read said.
285
+ function sousCharge(t, pressions) {
286
+ const lues = pressions.filter(p => p !== null);
287
+ if (lues.length === 0) {
288
+ process.stderr.write(`⏱ banc de temps de ${t.paquet} rouge, pression CPU illisible : rouge.\n`);
289
+ return;
290
+ }
291
+ const haute = Math.max(...lues);
292
+ if (haute < SEUIL_PRESSION) {
293
+ return;
294
+ }
295
+ process.stderr.write(
296
+ `⏱ banc de temps de ${t.paquet} rouge sous charge (pression CPU ${ecrirePression(haute)}, seuil ${SEUIL_PRESSION} %) : à repasser (${A_REPASSER}).\n`
297
+ );
298
+ t.code = A_REPASSER;
299
+ }
300
+
233
301
  // The crates the changes since the last green of <racine> touch, and their dependents; every crate
234
302
  // with <tout> or without a last green that counts. `{ choix, m }`, `m` the measure.
235
303
  function depuisLeVert(racine, tous, tout, env) {
@@ -245,42 +313,84 @@ function depuisLeVert(racine, tous, tout, env) {
245
313
  return { choix: tous.filter(c => nommes.has(c.composant.dossier)), m };
246
314
  }
247
315
 
248
- // Plans and plays the tests of the crates <choix> (each `{ c, cibles }`, `cibles` the test targets
249
- // named, empty for the whole crate) in the run <p>: for a crate that plays tests, the build of its
250
- // test targets first, then nextest, then its doctests; a failed build leaves the crate's other
251
- // tasks not played.
316
+ // Plans and plays the tests of the crates <choix> in the run <p>, each `{ c, cibles }`: `cibles`
317
+ // the test targets named, empty for the whole crate of the day (its night tests and its benches
318
+ // left out). For a crate that plays tests:
319
+ // the build of its test targets first, then nextest, then its doctests; a failed build leaves the
320
+ // crate's other tasks not played. The benches named, each crate's in a task `budget`, are
321
+ // planned with the rest and played by the function this one returns, after the other tests.
252
322
  function jouerLesTests(racine, p, choix, options) {
253
323
  const m = metadonnees(racine);
254
- const junit = path.join(m.target_directory, 'nextest', PROFIL, 'junit.xml');
324
+ // Nextest's store is `target/nextest` under the workspace's root (its default `store.dir`),
325
+ // whatever the target directory of the compilations (./sccache.mjs).
326
+ const junit = path.join(m.workspace_root, 'target', 'nextest', PROFIL, 'junit.xml');
327
+ const nextest = ['nextest', 'run', '--tool-config-file', `${PROFIL}:${NEXTEST}`];
328
+ nextest.push('--profile', PROFIL, '--no-fail-fast');
255
329
  const parCrate = [];
330
+ const bancs = [];
256
331
  for (const { c, cibles } of choix) {
257
332
  Object.assign(p.cibles, binaires(c));
258
333
  const d = c.composant.dossier;
259
334
  const nom = c.composant.nom;
260
335
  const prevues = [];
336
+ const etat = { construit: true };
261
337
  if (joueDesTests(racine, c.composant)) {
262
- const selection = ['-p', nom, ...cibles.flatMap(n => ['--test', n])];
338
+ const tests = c.cibles.filter(t => t.kind.includes('test'));
339
+ const deBanc = n => tests.some(t => t.name === n && horsDuJour(t) === 'banc');
340
+ const desBancs = cibles.filter(deBanc);
341
+ const autres = cibles.filter(n => !deBanc(n));
263
342
  const journal = path.join(m.target_directory, 'grillhouse', `${nom}-build.log`);
264
- const construction = ['test', '--no-run', ...selection];
343
+ const construction = ['test', '--no-run', '-p', nom, ...cibles.flatMap(n => ['--test', n])];
265
344
  prevues.push([p.prevoir(nom, d, 'build', false, construction), { journal }]);
266
- const args = ['nextest', 'run', '--tool-config-file', `${PROFIL}:${NEXTEST}`];
267
- args.push('--profile', PROFIL, '--no-fail-fast', ...selection);
268
- prevues.push([p.prevoir(nom, d, 'nextest', true, [...args, ...options]), { junit }]);
345
+ if (cibles.length === 0 || autres.length) {
346
+ const selection = cibles.length ? autres.flatMap(n => ['--test', n]) : duJour(c);
347
+ const args = [...nextest, '-p', nom, ...selection, ...options];
348
+ prevues.push([p.prevoir(nom, d, 'nextest', true, args), { junit }]);
349
+ }
350
+ if (desBancs.length) {
351
+ const args = [...nextest, '-p', nom, ...desBancs.flatMap(n => ['--test', n])];
352
+ bancs.push({ nom, d, args: [...args, '--test-threads', '1', ...options], etat });
353
+ }
269
354
  }
270
355
  const doctests = c.cibles.some(t => t.kind.includes('lib') && t.doctest !== false);
271
356
  if (cibles.length === 0 && doctests) {
272
357
  const args = ['test', '--doc', '-p', nom];
273
358
  prevues.push([p.prevoir(nom, d, 'doctest', true, args), {}]);
274
359
  }
275
- parCrate.push(prevues);
360
+ parCrate.push([prevues, etat]);
276
361
  }
277
- for (const prevues of parCrate) {
362
+ const prevusBancs = bancs.map(b => [p.prevoir(b.nom, b.d, BUDGET, true, b.args), b.etat]);
363
+ for (const [prevues, etat] of parCrate) {
278
364
  for (const [t, o] of prevues) {
279
365
  if (p.jouer(t, o) !== 0 && t.t.script === 'build') {
366
+ etat.construit = false;
280
367
  break;
281
368
  }
282
369
  }
283
370
  }
371
+ return () => {
372
+ for (const [t, etat] of prevusBancs) {
373
+ if (etat.construit) {
374
+ p.jouer(t, { junit });
375
+ }
376
+ }
377
+ };
378
+ }
379
+
380
+ // The selection of nextest of the crate <c> played whole in the day: none when it has no night
381
+ // test nor bench; else its library, its binaries and each other test target, named.
382
+ function duJour(c) {
383
+ const tests = c.cibles.filter(t => t.kind.includes('test'));
384
+ if (!tests.some(horsDuJour)) {
385
+ return [];
386
+ }
387
+ const lib = c.cibles.some(t => !t.kind.some(k => PAS_UNE_BIBLIOTHEQUE.includes(k)));
388
+ const bins = c.cibles.some(t => t.kind.includes('bin'));
389
+ return [
390
+ ...(lib ? ['--lib'] : []),
391
+ ...(bins ? ['--bins'] : []),
392
+ ...tests.filter(t => !horsDuJour(t)).flatMap(t => ['--test', t.name]),
393
+ ];
284
394
  }
285
395
 
286
396
  // The crates the paths <chemins> choose in <racine>: `{ choix }`, or `{ refus }` naming each path
@@ -340,7 +450,7 @@ function verifier(racine, args, env) {
340
450
  p,
341
451
  choix.map(c => ({ c, cibles: [] })),
342
452
  []
343
- );
453
+ )();
344
454
  p.jouer(p.prevoir(RACINE, racine, 'deny', false, ['deny', 'check']));
345
455
  const code = p.code();
346
456
  if (code === 0 && m.etat) {
@@ -458,6 +568,9 @@ export function lancer(nom, args, { racine = process.cwd(), env = process.env }
458
568
  if (nom === 'tester') {
459
569
  return sousLaBase('tests', env, envBase => tester(racine, tous, args, envBase));
460
570
  }
571
+ if (nom === 'tests-de-nuit') {
572
+ return sousLaBase('tests', env, envBase => testsDeNuit(racine, tous, envBase));
573
+ }
461
574
  process.stderr.write(`⛔ commande inconnue du module cargo : ${nom} (${NOMS.join(', ')})\n`);
462
575
  return 2;
463
576
  }
@@ -485,13 +598,27 @@ function tester(racine, tous, args, env) {
485
598
  choix = tous.map(c => ({ c, cibles: [] }));
486
599
  }
487
600
  try {
488
- jouerLesTests(racine, p, choix, options);
601
+ jouerLesTests(racine, p, choix, options)();
489
602
  } finally {
490
603
  m?.retirer();
491
604
  }
492
605
  return p.code();
493
606
  }
494
607
 
608
+ // The pass of `tests-de-nuit` in <racine>, the crates <tous>, under <env>: the night tests and the
609
+ // benches of each crate that holds some, each named.
610
+ function testsDeNuit(racine, tous, env) {
611
+ const p = passe(racine, env);
612
+ const choix = tous
613
+ .filter(c => joueDesTests(racine, c.composant))
614
+ .map(c => ({ c, cibles: c.cibles.filter(horsDuJour).map(t => t.name) }))
615
+ .filter(x => x.cibles.length);
616
+ if (choix.length) {
617
+ jouerLesTests(racine, p, choix, [])();
618
+ }
619
+ return p.code();
620
+ }
621
+
495
622
  if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
496
623
  const [nom, ...args] = process.argv.slice(2);
497
624
  try {
@@ -1,7 +1,7 @@
1
1
  // The components of a workspace of cargo, as cargo itself describes them (`cargo metadata
2
2
  // --format-version 1 --no-deps --offline`): the crates the module cargo answers the join with
3
3
  // (scripts/jointure.d.ts, `composants`, `composantDe`, `matieres`, `joueDesTests`, `lecteurs`,
4
- // `estUnTest`).
4
+ // `estUnTest`, `soeurDAvant`, `testsDeHead`).
5
5
  //
6
6
  // - A component is a member of the workspace (`workspace_members`): its folder, the manifest's;
7
7
  // its name and its package, the crate's name. A directory without a Cargo.toml at its root holds
@@ -29,6 +29,12 @@
29
29
  // `tests.rs` under `src/`, and any file of a folder `tests/` under `src/`, is a unit test file,
30
30
  // played with its crate when it is Rust; a file of a crate of the shared test material is
31
31
  // material; any other file of a crate (the code of `src/`) is none of them.
32
+ // - The sibling of HEAD's version of a test file (`soeurDAvant`), which the proof of the red plays
33
+ // beside it: `tests/<nom>_circuit_avant.rs` for a target `tests/<nom>.rs`, a target cargo finds
34
+ // by itself, the end `_nuit` or `_budget` kept last; none for `tests/<dossier>/main.rs` nor a
35
+ // unit test of `src/`, whose names of tests HEAD's version holds are read without playing them
36
+ // (`testsDeHead`, ./tests-de-head.mjs), the proof holding each for a green HEAD holds; those of
37
+ // a target `tests/<nom>.rs` too, when its sibling no longer compiles (grillhouse-3e2.2).
32
38
  // - What the testwriter writes of the manifests (`manifestes`): the tables that declare what the
33
39
  // tests of a crate depend on, `[dev-dependencies]` and `[target.<cible>.dev-dependencies]` of
34
40
  // its Cargo.toml (cargo's book, « Development dependencies »), as the author of a test of Bazel
@@ -46,6 +52,9 @@ import { existsSync, readdirSync, statSync } from 'node:fs';
46
52
  import { createRequire } from 'node:module';
47
53
  import path from 'node:path';
48
54
  import { isDeepStrictEqual } from 'node:util';
55
+ import { luUneFois } from '../../services-du-noyau.mjs';
56
+ import { cibleDeCompilation } from './sccache.mjs';
57
+ import { nomsDeHead } from './tests-de-head.mjs';
49
58
 
50
59
  // The loader of the optional peers this module reads when it needs them (smol-toml), under the
51
60
  // name by which knip reads a dependency.
@@ -63,8 +72,17 @@ export function metadonnees(racine) {
63
72
  if (!existsSync(path.join(racine, 'Cargo.toml'))) {
64
73
  return null;
65
74
  }
75
+ // Read once in a scope of the core (`luUneFois`): a sweep asks it of every file of a folder.
76
+ return luUneFois(`cargo metadata ${path.resolve(racine)}`, () => lireLesMetadonnees(racine));
77
+ }
78
+
79
+ // What `cargo metadata` says of the workspace at <racine>, read at each call.
80
+ function lireLesMetadonnees(racine) {
81
+ // The target directory cargo reports is the one the compilations use (./sccache.mjs), named
82
+ // without being made: a reading writes nothing in the home.
66
83
  const r = spawnSync('cargo', ['metadata', '--format-version', '1', '--no-deps', '--offline'], {
67
84
  cwd: racine,
85
+ env: { ...process.env, ...cibleDeCompilation(racine, process.env, { creer: false }) },
68
86
  encoding: 'utf8',
69
87
  maxBuffer: 256 * 1024 * 1024,
70
88
  });
@@ -126,7 +144,7 @@ export const matieres = racine =>
126
144
  // Whether <parts>, a path from the folder of a crate split, is a unit test file under its `src/`:
127
145
  // a file `tests.rs`, or a file of a folder `tests/`.
128
146
  // `src/bin/tests.rs` and `src/bin/tests/` are a binary target for cargo, its code.
129
- const unitaire = parts =>
147
+ export const unitaire = parts =>
130
148
  parts[0] === 'src' &&
131
149
  parts.length > 1 &&
132
150
  !(parts[1] === 'bin' && ['tests.rs', 'tests'].includes(parts[2])) &&
@@ -246,6 +264,80 @@ export function estUnTest(chemin, racine) {
246
264
  return matiere ? { joue: false, test: false, matiere: true } : null;
247
265
  }
248
266
 
267
+ /** The end of the name of a night test target, and of a time budget bench's (./commandes.mjs,
268
+ * `horsDuJour`). */
269
+ export const DE_NUIT = '_nuit';
270
+ export const BANC = '_budget';
271
+
272
+ /**
273
+ * The sibling of HEAD's version of the test file <chemin> (from the root <racine>), which cargo
274
+ * plays in the same run: `tests/<nom>_circuit_avant.rs` beside a test target `tests/<nom>.rs`, a
275
+ * target cargo finds by itself (`autotests`), its `mod` of the same folder read as the file's,
276
+ * and nextest names its tests as the file's, without the target; the end of a night test or of a
277
+ * bench kept, so that the sibling plays as its file does (`tests/<nom>_circuit_avant_budget.rs`
278
+ * beside `tests/<nom>_budget.rs`, alone on one thread). Null for any other file: a target
279
+ * `tests/<dossier>/main.rs` holds its modules beside it, and a unit test of `src/` is compiled in
280
+ * its crate's module.
281
+ */
282
+ export function soeurDAvant(chemin, racine) {
283
+ const abs = path.resolve(racine, chemin);
284
+ const c = composantDans(
285
+ crates(racine).map(x => x.composant),
286
+ racine,
287
+ abs
288
+ );
289
+ const parts = c ? path.relative(c.dossier, abs).split(path.sep) : [];
290
+ const cible = parts.length === 2 && parts[0] === 'tests' && parts[1].endsWith('.rs');
291
+ if (!cible) {
292
+ return null;
293
+ }
294
+ const base = chemin.slice(0, -'.rs'.length);
295
+ const fin = [DE_NUIT, BANC].find(f => base.endsWith(f)) ?? '';
296
+ return `${base.slice(0, base.length - fin.length)}_circuit_avant${fin}.rs`;
297
+ }
298
+
299
+ /**
300
+ * The names of the tests of HEAD's version of the test file <chemin> (from the root <racine>),
301
+ * read without playing them, for a file cargo cannot play twice in a run and that has no sibling
302
+ * (`soeurDAvant`): a unit test file of `src/` (`tests.rs`, a file of a folder `tests/` under
303
+ * `src/`, out of `src/bin/`) and a target `tests/<dossier>/main.rs` (./tests-de-head.mjs); with
304
+ * <sansSoeur>, a target `tests/<nom>.rs` too, whose sibling the proof does not play because it no
305
+ * longer compiles (grillhouse-3e2.2): its names as nextest gives them, without the target, its
306
+ * out-of-line modules read (`mod common;`, `common::<fn>`). <lire> gives HEAD's text of a file
307
+ * from the root. Null for any other file, or one HEAD does not hold.
308
+ * @param {string} chemin
309
+ * @param {string} racine
310
+ * @param {(f: string) => string | null} lire
311
+ * @param {{ sansSoeur?: boolean }} [options]
312
+ */
313
+ export function testsDeHead(chemin, racine, lire, { sansSoeur = false } = {}) {
314
+ const abs = path.resolve(racine, chemin);
315
+ const c = composantDans(
316
+ crates(racine).map(x => x.composant),
317
+ racine,
318
+ abs
319
+ );
320
+ if (!c || !chemin.endsWith('.rs')) {
321
+ return null;
322
+ }
323
+ const parts = path.relative(c.dossier, abs).split(path.sep);
324
+ if (parts.length === 3 && parts[0] === 'tests' && parts[2] === 'main.rs') {
325
+ return nomsDeHead(chemin, null, lire);
326
+ }
327
+ if (sansSoeur && soeurDAvant(chemin, racine) !== null) {
328
+ return nomsDeHead(chemin, null, lire);
329
+ }
330
+ if (!unitaire(parts) || parts[1] === 'bin') {
331
+ return null;
332
+ }
333
+ const module = parts.slice(1);
334
+ module[module.length - 1] = module[module.length - 1].replace(/\.rs$/, '');
335
+ if (module.at(-1) === 'mod') {
336
+ module.pop();
337
+ }
338
+ return nomsDeHead(chemin, module, lire);
339
+ }
340
+
249
341
  // The tables of a manifest that declare what its tests depend on.
250
342
  const DES_TESTS = 'dev-dependencies';
251
343
 
@@ -196,6 +196,37 @@ function resultats(dans, taches, rapports, cibles) {
196
196
  return dossier;
197
197
  }
198
198
 
199
+ // HEAD's text of a unit test file of `src/`: two tests, one in an inline module, and braces and
200
+ // a false test in a comment, a raw string and a character, which are not counted.
201
+ const UNITAIRE = [
202
+ 'use super::*;',
203
+ '// fn faux() { #[test]',
204
+ '#[test]',
205
+ 'fn ancien() {',
206
+ ' let _ = r#"{ #[test] fn dans_la_chaine() {} "#;',
207
+ " let _ = '{';",
208
+ '}',
209
+ '/* } #[test] fn commentee() {} */',
210
+ 'mod groupe {',
211
+ ' #[test]',
212
+ ' #[ignore]',
213
+ ' fn interne() {}',
214
+ '}',
215
+ '',
216
+ ].join('\n');
217
+ // HEAD's text of a target `tests/<dossier>/main.rs`: a test, one under `#[tokio::test]` in an
218
+ // inline module, and an out-of-line module `aide`.
219
+ const PRINCIPAL = [
220
+ 'mod aide;',
221
+ '#[test]',
222
+ 'fn principal() {}',
223
+ 'mod m {',
224
+ ' #[tokio::test]',
225
+ ' async fn dedans() {}',
226
+ '}',
227
+ '',
228
+ ].join('\n');
229
+
199
230
  export default {
200
231
  // The trials under <dans>.
201
232
  preparer(dans) {
@@ -343,12 +374,48 @@ export default {
343
374
  'crates/matiere/src/lib.rs : matiere',
344
375
  ],
345
376
  },
377
+ versionDeHead: {
378
+ valide: [
379
+ 'crates/core/src/lib.rs',
380
+ 'crates/core/src/tests.rs',
381
+ 'crates/core/tests/common/mod.rs',
382
+ 'crates/core/tests/scenario/main.rs',
383
+ 'Cargo.toml',
384
+ ],
385
+ // A night test and a bench keep their end, so that their sibling plays as they do.
386
+ invalide: [
387
+ 'crates/core/tests/t.rs',
388
+ 'crates/core/tests/t_nuit.rs',
389
+ 'crates/core/tests/t_budget.rs',
390
+ // A unit test of `src/` and a target `tests/<dossier>/main.rs` have no sibling: the
391
+ // names of HEAD's tests are read, as nextest reports them (its module path), the
392
+ // braces of a comment, a string or a character not counted, a `mod` of main.rs read.
393
+ {
394
+ chemin: 'crates/core/src/rendu/tests.rs',
395
+ textes: { 'crates/core/src/rendu/tests.rs': UNITAIRE },
396
+ },
397
+ {
398
+ chemin: 'crates/core/tests/scenario/main.rs',
399
+ textes: {
400
+ 'crates/core/tests/scenario/main.rs': PRINCIPAL,
401
+ 'crates/core/tests/scenario/aide.rs': '#[test]\nfn aidant() {}\n',
402
+ },
403
+ },
404
+ ],
405
+ attendu: [
406
+ 'crates/core/tests/t.rs → crates/core/tests/t_circuit_avant.rs',
407
+ 'crates/core/tests/t_nuit.rs → crates/core/tests/t_circuit_avant_nuit.rs',
408
+ 'crates/core/tests/t_budget.rs → crates/core/tests/t_circuit_avant_budget.rs',
409
+ 'crates/core/src/rendu/tests.rs : rendu::tests::ancien, rendu::tests::groupe::interne',
410
+ 'crates/core/tests/scenario/main.rs : principal, m::dedans, aide::aidant',
411
+ ],
412
+ },
346
413
  fichiersEngendres: {
347
414
  valide: aJour,
348
415
  invalide: enRetard,
349
416
  attendu: ["l'index des interfaces : en retard"],
350
417
  },
351
- gardes: { valide: ['clippy', 'frontieres', 'index-interfaces'] },
418
+ gardes: { valide: ['tailles-des-tests', 'clippy', 'frontieres', 'index-interfaces'] },
352
419
  elementsDuLot: {
353
420
  valide: { racine: aJour, avant: 'HEAD', apres: 'HEAD' },
354
421
  invalide: { racine: lot, avant: avantLeLot, apres: 'HEAD' },
@@ -17,17 +17,21 @@
17
17
  // (./composants.mjs).
18
18
  // - The crates touched since a commit and their dependents (./touches.mjs).
19
19
  // - The elements of a lot, one per crate (./elements-du-lot.mjs).
20
- // - The commands `tester`, `verifier`, `typer` and `preparer` (./commandes.mjs), each described,
21
- // `{ script, args }`, never run, `preparer` played by the integration before the verification;
20
+ // - The commands `tester`, `verifier`, `typer`, `preparer` and `tests-de-nuit` (./commandes.mjs),
21
+ // each described, `{ script, args }`, never run, `preparer` played by the integration before the
22
+ // verification, `tests-de-nuit` by the night (the test targets `tests/*_nuit.rs`, then the time
23
+ // budget benches `tests/*_budget.rs`, which the day leaves out);
22
24
  // the verdict of a run (./verdict.mjs). The tool of a test's temporary directory, the crate
23
25
  // `tempfile`, and its guard: `tester` and `verifier` play under a base of their pass, named in
24
26
  // TMPDIR, TMP and TEMP, and fail naming what the tests left there (./commandes.mjs).
25
27
  // - The generated file, the index of the interfaces (./index-interfaces.mjs), its command and its
26
- // check; the guards of structure, in the order they play: clippy (./clippy.mjs), the boundaries
27
- // between crates (./frontieres.mjs), the index of the interfaces up to date, each a command by
28
- // its name too (./commandes.mjs), which the line of a red guard names; the entries of the index
29
- // of each interface (`entreesDeLIndex`), which the core assembles in a project of several
30
- // languages. No migration yet.
28
+ // check; the guards of structure, in the order they play: the sizes of the tests
29
+ // (./tailles-des-tests.mjs), clippy (./clippy.mjs), the boundaries between crates
30
+ // (./frontieres.mjs), the index of the interfaces up to date, each a command by its name too
31
+ // (./commandes.mjs), which the line of a red guard names; the entries of the index of each
32
+ // interface (`entreesDeLIndex`), which the core assembles in a project of several languages.
33
+ // - Its migrations (./migrations/): 0.28.4, the large tests of the day a project holds inscribed
34
+ // in its debt when the guard of the sizes arrives.
31
35
  // - Its share of the update (./mise-a-jour.mjs, `miseAJour`): the template of a project of cargo
32
36
  // (`templates/cargo/`) and its test scripts.
33
37
  // - The skeleton of a new crate (./squelette.mjs, `squelette`), which `grillhouse paquet` writes.
@@ -39,6 +43,8 @@ import {
39
43
  composantDans,
40
44
  composants,
41
45
  estUnTest,
46
+ soeurDAvant,
47
+ testsDeHead,
42
48
  joueDesTests,
43
49
  lecteurs,
44
50
  manifestes,
@@ -47,8 +53,9 @@ import {
47
53
  import { elementsDuLot } from './elements-du-lot.mjs';
48
54
  import { enRetard, entreesDeLIndex, SORTIE } from './index-interfaces.mjs';
49
55
  import { miseAJour } from './mise-a-jour.mjs';
56
+ import * as taillesDesTests from './migrations/0.28.4-tailles-des-tests.mjs';
50
57
  import { squelette } from './squelette.mjs';
51
- import { CACHE } from './sccache.mjs';
58
+ import { CACHE, CIBLES } from './sccache.mjs';
52
59
  import { touches } from './touches.mjs';
53
60
  import { verdict } from './verdict.mjs';
54
61
 
@@ -70,7 +77,8 @@ export default {
70
77
  // registry's index and sources, the git dependencies, cargo-deny's advisories, and the files of
71
78
  // its locks and of the SQLite cache of its packages (`.package-cache`, `.package-cache-mutate`,
72
79
  // `.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`
80
+ // (./sccache.mjs), where a server of sccache the session starts writes; the targets of the
81
+ // workspaces rooted in the temporary directory, `~/.cache/grillhouse/cargo/` (./sccache.mjs). What it reads, read-only: its home, `~/.cargo`
74
82
  // (its binaries, its `env`, which the shells source, and its configuration stay unwritten), and
75
83
  // rustup's toolchains, `~/.rustup`. Measured on 2026-10-30: `cargo fetch --locked` of
76
84
  // osc-bridge in bwrap with these mounts alone, green, the cache of its packages written.
@@ -84,6 +92,7 @@ export default {
84
92
  '~/.cargo/.package-cache-mutate',
85
93
  '~/.cargo/.global-cache',
86
94
  CACHE,
95
+ CIBLES,
87
96
  ],
88
97
  propres: [],
89
98
  lues: ['~/.cargo/', '~/.rustup/'],
@@ -106,6 +115,8 @@ export default {
106
115
  commandes,
107
116
  verdict,
108
117
  estUnTest,
118
+ soeurDAvant,
119
+ testsDeHead,
109
120
  manifestes,
110
121
  fichiersEngendres: () => [
111
122
  {
@@ -120,7 +131,7 @@ export default {
120
131
  ],
121
132
  entreesDeLIndex,
122
133
  gardes: () => GARDES.map(({ script, args }) => [script, ...args]),
123
- migrations: [],
134
+ migrations: [taillesDesTests],
124
135
  miseAJour,
125
136
  squelette,
126
137
  };