@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
@@ -11,12 +11,13 @@
11
11
  // writes (scripts/grillhouse-maj.mjs). Grillhouse's package imports it by its own name.
12
12
  //
13
13
  // - The exclusions of the day: a night test (`*.nuit.test.*`, `*.nuit.spec.*`) is too long for the
14
- // day, and the measures of a time budget bench (`*.budget.test.*`, `*.budget.spec.*`) move with
15
- // the load of the day: `npm test`, `npm run verifier` and the integration leave both out, and
16
- // the night plays them (scripts/nuit.sh, scripts/langages/typescript/vitest.nuit.config.mjs); a targeted run that
14
+ // day, and every measure of time, a time budget bench (`*.budget.test.*`, `*.budget.spec.*`) or
15
+ // a time witness (a test file that imports `mesurerAuRepos`), moves with the load of the day:
16
+ // `npm test`, `npm run verifier` and the integration leave them out, and the night plays them
17
+ // (scripts/nuit.sh, scripts/langages/typescript/vitest.nuit.config.mjs); a targeted run that
17
18
  // names the file of one itself plays it, under the measure of time below (./cibles.mjs, where
18
- // the patterns live). `mergeConfig` adds the exclusions of a configuration that extends this one
19
- // to these.
19
+ // the patterns live, and whose plugin leaves the witnesses out). `mergeConfig` adds the
20
+ // exclusions of a configuration that extends this one to these.
20
21
  // - A run that plays no test fails, as Vitest's default has it (`passWithNoTests` unset): a
21
22
  // targeted run (`npm test -- <paths>`, scripts/langages/typescript/tests.mjs) plays each path in its package only,
22
23
  // and a path that names no test is a mistake, never a green.
@@ -30,19 +31,17 @@
30
31
  // (GIT_CONFIG_COUNT/KEY/VALUE, git-config(1)), the automatic maintenance and garbage collection
31
32
  // off (maintenance.auto=false, gc.auto=0). This file is the one address of these settings; the
32
33
  // night configuration takes them from here.
33
- // - A time witness is measured with the CPU at rest: a setup file notes the CPU pressure at the
34
+ // - A measure of time is taken with the CPU at rest: a setup file notes the CPU pressure at the
34
35
  // start and at the end of each test (./mesure.setup.mjs), and the duration reporter, beside
35
36
  // Vitest's default one, gives the exit code 75, « à repasser », when every failure depends on a
36
37
  // duration and one took place under load (./duree.reporter.mjs; the signal and its threshold,
37
- // ./pression.mjs). A test that measures time marks itself (`mesurerAuRepos`,
38
+ // scripts/mesure/pression.mjs); a delay past in a day test is a red. A test that measures time marks itself (`mesurerAuRepos`,
38
39
  // `@roomi-fields/grillhouse/vitest-config/mesure`). `mergeConfig` adds the reporters and the setup files of
39
40
  // a configuration that extends this one to these; a reporter named on the command line
40
41
  // (`--reporter`) replaces them, and Vitest's code then stands.
41
42
  // - The machine of a test file is its own: a setup file gives it a lock of the heavy measure of
42
43
  // its own, so that a `npm run verifier` a test plays in a repository of trial neither waits for
43
44
  // the lock of the machine nor holds it (./machine.setup.mjs, scripts/verrou-de-machine.mjs).
44
- // - The time witnesses play alone in `npm run verifier`: the plugin below leaves them out of its
45
- // pass, then plays them in a pass of their own (./cibles.mjs, scripts/langages/typescript/verifier.mjs).
46
45
  // - While a run names its results directory (`GRILLHOUSE_RESULTATS`, ./resultats.mjs), the JSON
47
46
  // reporter writes Vitest's report there too, which the circuit reads (scripts/resultats.mjs); a
48
47
  // setup file gives each test file's processes a results directory of their own, so that a run a
@@ -7,10 +7,9 @@
7
7
  //
8
8
  // - The value is JSON: `arguments`, Vitest's arguments (the paths, absolute, and the options
9
9
  // written `--<name>=<value>`), which Vitest's own parser of its command line (`parseCLI`,
10
- // vitest/node) reads; `rejouer`, the moment of a run that plays the tests for real (`--force`),
11
- // which only moves the hash; `temoins`, the time witnesses of a pass of `npm run verifier`
12
- // (below). The plugin takes the variable out of the environment once read: no
13
- // process the tests start receives it.
10
+ // vitest/node) reads; `rejouer`, the moment of a run that plays the tests for real (`--force`,
11
+ // a complete pass of `npm run verifier`), which only moves the hash. The plugin takes the
12
+ // variable out of the environment once read: no process the tests start receives it.
14
13
  // - A plugin of the base configuration (./base.mjs) reads it once the configuration is merged (its
15
14
  // `config` hook; Vitest reads the test options in `configResolved`, after every `config` hook):
16
15
  // the files played are the test files of the configuration's `include` (Vitest's default when
@@ -19,24 +18,27 @@
19
18
  // A path of another package names none of its files. Each option enters the test configuration
20
19
  // as Vitest merges its command line over it (`exclude` given on the command line is
21
20
  // `cliExclude`, as Vitest's `normalizeCliOptions` names it).
22
- // - A night test or a time budget bench (HORS_DU_JOUR, the day's exclusions of ./base.mjs) plays
23
- // when its own file is named, as Bazel's target tagged `manual` builds when named and never by a
24
- // pattern: the day's exclusions of both lift for that run, the include of the configuration
25
- // notwithstanding (the night's own include is HORS_DU_JOUR), and the measure of time of the base
26
- // configuration applies, its duration reporter giving 75, « à repasser », to a bench that fails
27
- // under load. A directory named leaves them out, as the day does.
28
- // - Without the variable, nothing changes. A run whose paths name no test file plays none, and
29
- // fails: the base configuration keeps Vitest's `passWithNoTests: false`.
30
- // - The time witnesses play alone, as Bazel plays a test tagged `exclusive` after the others, with
31
- // nothing beside it: a time witness is a test file that imports the mark of a measure of time
32
- // (`import { mesurerAuRepos } from '@roomi-fields/grillhouse/vitest-config/mesure'`, a line of its own,
33
- // `estTemoin`). `npm run verifier` (scripts/langages/typescript/verifier.mjs) plays its pass with `temoins: 'hors'`
34
- // in the value, which leaves every witness of the configuration's `include` out, then a pass of
35
- // its own with `temoins: 'seuls'`, which plays the witnesses alone, one file at a time
36
- // (`fileParallelism: false`), and passes without one (`passWithNoTests`); a targeted run sets
37
- // neither, and a witness named plays there as any test. The witnesses are found under the
38
- // configuration's directory (`fichiersTemoins`), node_modules, dist, .git, .turbo and .claude
39
- // left out.
21
+ // - Every measure of time plays at night (grillhouse-bd7), as Bazel leaves a target tagged
22
+ // `manual` out of every pattern and the benchmarks of Chromium and rustc-perf leave the CI of
23
+ // each commit for a machine at rest: a time budget bench (BUDGET) and a time witness, a test
24
+ // file that imports the mark of a measure of time (`import { mesurerAuRepos } from
25
+ // '@roomi-fields/grillhouse/vitest-config/mesure'`, a line of its own, `estTemoin`), are out of
26
+ // the day, as a night test (NUIT) is. The base configuration excludes the patterns HORS_DU_JOUR;
27
+ // the plugin excludes the witnesses found under the configuration's directory
28
+ // (`fichiersTemoins`, node_modules, dist, .git, .turbo and .claude left out), with or without
29
+ // the variable.
30
+ // - A night test, a bench or a witness plays when its own file is named, as Bazel's target tagged
31
+ // `manual` builds when named: the day's exclusions lift for that file, the include of the
32
+ // configuration notwithstanding, and the measure of time of the base configuration applies, its
33
+ // duration reporter giving 75, « à repasser », to a measure that fails under load. A directory
34
+ // named leaves them out, as the day does.
35
+ // - A run whose paths name no test file plays none, and fails: the base configuration keeps
36
+ // Vitest's `passWithNoTests: false`.
37
+ // - The night's configuration (scripts/langages/typescript/vitest.nuit.config.mjs) plays what the
38
+ // day leaves out, through the plugin `nuit`: the night tests, the benches and the witnesses; the
39
+ // variable `GRILLHOUSE_TESTS_DE_NUIT` (NUIT_VARIABLE) chooses `nuit`, the night tests alone, or
40
+ // `mesures`, the benches and the witnesses alone, one file at a time (`fileParallelism: false`),
41
+ // as scripts/langages/typescript/tests-de-nuit.mjs plays them.
40
42
  // - The changes since the last green (`GRILLHOUSE_CHANGEMENTS`, ./changements.mjs) restrict the
41
43
  // files played to those Vitest relates to them, the files named themselves kept, or leave every
42
44
  // test when a change lies out of Vitest's graph.
@@ -54,6 +56,8 @@ export const VARIABLE = 'GRILLHOUSE_TESTS';
54
56
  export const NUIT = '**/*.nuit.{test,spec}.?(c|m)[jt]s?(x)';
55
57
  export const BUDGET = '**/*.budget.{test,spec}.?(c|m)[jt]s?(x)';
56
58
  export const HORS_DU_JOUR = [NUIT, BUDGET];
59
+ /** The variable that chooses the tests of a run of the night's configuration: `nuit` or `mesures`. */
60
+ export const NUIT_VARIABLE = 'GRILLHOUSE_TESTS_DE_NUIT';
57
61
  // Whether <r>, a path relative to the configuration's directory, is a night test or a bench.
58
62
  const horsDuJour = r => HORS_DU_JOUR.some(p => path.matchesGlob(r, p));
59
63
  // Vitest's default `include` (its configDefaults).
@@ -64,19 +68,28 @@ const MARQUE_TEMOIN =
64
68
  /^import\s*\{[^}]*\bmesurerAuRepos\b[^}]*\}\s*from\s*['"][^'"]*vitest-config\/mesure(?:\.mjs)?['"]/m;
65
69
  // Whether the text <texte> of a test file is that of a time witness.
66
70
  const estTemoin = texte => MARQUE_TEMOIN.test(texte);
71
+ const lireTexte = f => {
72
+ try {
73
+ return readFileSync(f, 'utf8');
74
+ } catch {
75
+ return '';
76
+ }
77
+ };
78
+
79
+ /**
80
+ * Whether the test file at <fichier> is out of the day: a night test, a time budget bench or a
81
+ * time witness.
82
+ * @param {string} fichier the path of the file
83
+ */
84
+ export const estHorsDuJour = fichier =>
85
+ HORS_DU_JOUR.some(p => path.matchesGlob(fichier, p)) || estTemoin(lireTexte(fichier));
67
86
  // The directories a search of the witnesses leaves out.
68
87
  const HORS_TEMOINS = new Set(['node_modules', 'dist', '.git', '.turbo', '.claude']);
69
88
 
70
89
  // The time witnesses under <dir>: the test files of <include> (Vitest's default without it), the
71
90
  // day's exclusions left out, that `estTemoin`; each path relative to <dir>, sorted.
72
91
  export function fichiersTemoins(dir, include = INCLUDE) {
73
- const lire = f => {
74
- try {
75
- return readFileSync(path.join(dir, f), 'utf8');
76
- } catch {
77
- return '';
78
- }
79
- };
92
+ const lire = f => lireTexte(path.join(dir, f));
80
93
  return [
81
94
  ...new Set(
82
95
  globSync(include, { cwd: dir, exclude: d => HORS_TEMOINS.has(path.basename(d)) }).map(f =>
@@ -120,7 +133,16 @@ const fusion = (cible, valeur) =>
120
133
  )
121
134
  : valeur;
122
135
 
123
- // The plugin that restricts a run to the tests <env> names in VARIABLE.
136
+ // The time witnesses under the directory of the test options <test> of <config>, each a pattern
137
+ // relative to it that names its file alone.
138
+ const temoinsDe = (config, test) =>
139
+ fichiersTemoins(
140
+ path.resolve(config.root ?? process.cwd(), test.dir ?? ''),
141
+ test.include ?? INCLUDE
142
+ ).map(r => r.replace(SPECIAUX, '\\$&'));
143
+
144
+ // The plugin of the day: the time witnesses out of the run, and the run restricted to the tests
145
+ // <env> names in VARIABLE.
124
146
  export const ciblage = (env = process.env, dire = l => process.stdout.write(`${l}\n`)) => ({
125
147
  name: 'grillhouse:cibles',
126
148
  async config(config) {
@@ -128,14 +150,18 @@ export const ciblage = (env = process.env, dire = l => process.stdout.write(`${l
128
150
  const changements = env[CHANGEMENTS];
129
151
  delete env[VARIABLE];
130
152
  delete env[CHANGEMENTS];
131
- if (!texte && !changements) {
132
- return;
133
- }
134
153
  const test = (config.test ??= {});
154
+ const temoins = temoinsDe(config, test);
135
155
  // The files a targeted run names themselves, absolute.
136
156
  let nommes = [];
137
157
  if (texte) {
138
- nommes = await cibler(config, test, JSON.parse(texte));
158
+ nommes = await cibler(config, test, JSON.parse(texte), new Set(temoins));
159
+ }
160
+ // The witnesses out of the day, but those named themselves (in the include then).
161
+ const joues = new Set(Array.isArray(test.include) ? test.include : []);
162
+ const hors = nommes.length ? temoins.filter(t => !joues.has(t)) : temoins;
163
+ if (hors.length) {
164
+ test.exclude = [...(test.exclude ?? ['**/node_modules/**']), ...hors];
139
165
  }
140
166
  const ch = changements ? lireChangements(changements) : null;
141
167
  // A targeted run whose paths name no test file plays none, and fails, as without the changes.
@@ -145,26 +171,13 @@ export const ciblage = (env = process.env, dire = l => process.stdout.write(`${l
145
171
  },
146
172
  });
147
173
 
148
- // Applies the value <valeur> of VARIABLE to the configuration <config>, its test options <test>:
149
- // the files named themselves, absolute.
150
- async function cibler(config, test, valeur) {
174
+ // Applies the value <valeur> of VARIABLE to the configuration <config>, its test options <test>,
175
+ // <temoins> the time witnesses (patterns relative to its directory): the files named themselves,
176
+ // absolute.
177
+ async function cibler(config, test, valeur, temoins) {
151
178
  const { parseCLI } = await import('vitest/node');
152
179
  const { filter, options } = parseCLI(['vitest', ...(valeur.arguments ?? [])]);
153
180
  let nommes = [];
154
- // The time witnesses: left out of the pass, or played alone in their own.
155
- if (valeur.temoins === 'hors' || valeur.temoins === 'seuls') {
156
- const dir = path.resolve(config.root ?? process.cwd(), test.dir ?? '');
157
- const temoins = fichiersTemoins(dir, test.include ?? INCLUDE).map(r =>
158
- r.replace(SPECIAUX, '\\$&')
159
- );
160
- if (valeur.temoins === 'hors') {
161
- test.exclude = [...(test.exclude ?? ['**/node_modules/**']), ...temoins];
162
- } else {
163
- test.include = temoins.length ? temoins : [`${VARIABLE}-sans-temoin`];
164
- test.passWithNoTests = true;
165
- test.fileParallelism = false;
166
- }
167
- }
168
181
  if (filter.length) {
169
182
  const dir = path.resolve(config.root ?? process.cwd(), test.dir ?? '');
170
183
  const include = test.include ?? INCLUDE;
@@ -179,12 +192,14 @@ async function cibler(config, test, valeur) {
179
192
  if (r.startsWith('../')) {
180
193
  return false;
181
194
  }
182
- return horsDuJour(r) ? seuls.has(f) : include.some(p => path.matchesGlob(r, p));
195
+ return horsDuJour(r) || temoins.has(r.replace(SPECIAUX, '\\$&'))
196
+ ? seuls.has(f)
197
+ : include.some(p => path.matchesGlob(r, p));
183
198
  })
184
199
  .map(relatif)
185
200
  .sort();
186
201
  // A bench or a night test named itself plays: the day's exclusions of both lift, and the
187
- // files under a directory named stay out by the filter above.
202
+ // files under a directory named stay out by the filter above (a witness, by the plugin).
188
203
  if (joues.some(horsDuJour) && Array.isArray(test.exclude)) {
189
204
  test.exclude = test.exclude.filter(p => !HORS_DU_JOUR.includes(p));
190
205
  }
@@ -206,3 +221,27 @@ async function cibler(config, test, valeur) {
206
221
  }
207
222
  return nommes;
208
223
  }
224
+
225
+ /**
226
+ * The plugin of the night's configuration: the night tests, the benches and the time witnesses
227
+ * under its directory, or, as <env> chooses in NUIT_VARIABLE, the night tests alone (`nuit`) or
228
+ * the measures alone, one file at a time (`mesures`), the benches and the witnesses.
229
+ * @param {NodeJS.ProcessEnv} [env] the environment that holds the choice
230
+ */
231
+ export const nuit = (env = process.env) => ({
232
+ name: 'grillhouse:nuit',
233
+ config(config) {
234
+ const choix = env[NUIT_VARIABLE];
235
+ delete env[NUIT_VARIABLE];
236
+ const test = (config.test ??= {});
237
+ const temoins = temoinsDe(config, { ...test, include: INCLUDE });
238
+ if (choix === 'nuit') {
239
+ test.include = [NUIT];
240
+ } else if (choix === 'mesures') {
241
+ test.include = [BUDGET, ...temoins];
242
+ test.fileParallelism = false;
243
+ } else {
244
+ test.include = [...HORS_DU_JOUR, ...temoins];
245
+ }
246
+ },
247
+ });
@@ -3,10 +3,13 @@
3
3
  // (`--reporter=<entry>`, or `reporters` in a configuration; types ./duree.reporter.d.ts). At the end
4
4
  // of a run with failures, it reads each one:
5
5
  //
6
- // - a failure depends on a duration when it is a delay past (an error « Test timed out in <n>ms. »
7
- // or « Hook timed out in <n>ms. », Vitest's own message), a failure of a time budget bench (a
8
- // file `*.budget.test.*`, `*.budget.spec.*`), or of a test marked as a measure of time
9
- // (`mesurerAuRepos`, ./mesure.mjs); every other failure is a real red;
6
+ // - a failure depends on a duration when it is a failure of a time budget bench (a file
7
+ // `*.budget.test.*`, `*.budget.spec.*`), of a test marked as a measure of time (`mesurerAuRepos`,
8
+ // ./mesure.mjs), or a delay past (an error « Test timed out in <n>ms. » or « Hook timed out in
9
+ // <n>ms. », Vitest's own message) in a file out of the day (a night test, a bench, a time
10
+ // witness: `estHorsDuJour` of ./cibles.mjs); every other failure is a real red, a delay past in
11
+ // a day test included: a delay of the day is a safeguard, not a measure, as in Bazel and Vitest
12
+ // (grillhouse-bd7), and one too tight widens, far above the test's usual duration;
10
13
  // - it took place under load when the CPU pressure (./pression.mjs) was at or above the threshold
11
14
  // at the start or at the end of the test (noted by ./mesure.setup.mjs), or, for a hook or a file
12
15
  // that fails outside of a test, at the start or at the end of the run.
@@ -23,6 +26,7 @@ import {
23
26
  lirePression,
24
27
  SEUIL_PRESSION,
25
28
  } from '../../../services-du-noyau.mjs';
29
+ import { estHorsDuJour } from './cibles.mjs';
26
30
 
27
31
  const DELAI = /^(Test|Hook) timed out in \d+ms\./;
28
32
  const BANC = /\.budget\.(test|spec)\.(c|m)?[jt]sx?$/;
@@ -68,7 +72,9 @@ export default class DureeReporter {
68
72
  ? 'mesure de temps'
69
73
  : BANC.test(fichier)
70
74
  ? 'banc de temps'
71
- : erreurs.length > 0 && erreurs.every(e => DELAI.test(e.message ?? ''))
75
+ : erreurs.length > 0 &&
76
+ erreurs.every(e => DELAI.test(e.message ?? '')) &&
77
+ estHorsDuJour(fichier)
72
78
  ? 'délai dépassé'
73
79
  : null;
74
80
  if (!cause) {
@@ -3,7 +3,10 @@
3
3
  // directory named after its process and a token, scripts/verrou-de-machine.mjs), which every
4
4
  // process it starts inherits: a `npm run verifier` or a circuit that a test plays in a repository
5
5
  // of trial neither waits for the lock of the machine nor holds it, and no test writes in the
6
- // user's cache. A lock already named in the environment stays.
6
+ // user's cache. A lock already named in the environment stays. Its heavy passes want no room in
7
+ // the temporary directory (GRILLHOUSE_TEMPORAIRE_LIBRE, 0) nor on the disk of their copy
8
+ // (GRILLHOUSE_COPIE_LIBRE, 0): the room of the machine is the pass's that plays the file, which
9
+ // waited for it.
7
10
  import { randomUUID } from 'node:crypto';
8
11
  import { tmpdir } from 'node:os';
9
12
  import path from 'node:path';
@@ -12,3 +15,5 @@ process.env.GRILLHOUSE_VERROU_MACHINE ||= path.join(
12
15
  tmpdir(),
13
16
  `grillhouse-mesure-${process.pid}-${randomUUID()}.lock`
14
17
  );
18
+ process.env.GRILLHOUSE_TEMPORAIRE_LIBRE ||= '0';
19
+ process.env.GRILLHOUSE_COPIE_LIBRE ||= '0';
@@ -1,12 +1,13 @@
1
1
  // A test that measures time marks itself, so that its failure under load is « à repasser », not a
2
- // red (./duree.reporter.mjs):
2
+ // red (./duree.reporter.mjs), and its file, a time witness, plays at night alone, out of the day
3
+ // (./cibles.mjs, grillhouse-bd7):
3
4
  //
4
5
  // import { mesurerAuRepos } from '@roomi-fields/grillhouse/vitest-config/mesure';
5
6
  // it('rend en moins de 50 ms', ctx => mesurerAuRepos(ctx, () => { … expect(ms).toBeLessThan(50); }));
6
7
  //
7
8
  // `mesurerAuRepos(ctx, fn)` marks the test of the context <ctx> as a measure of time and gives back
8
9
  // what <fn> returns (a promise as it is, for the test to await). A time budget bench
9
- // (`*.budget.test.*`) and a delay past need no mark.
10
+ // (`*.budget.test.*`) needs no mark, nor a delay past in a night test.
10
11
  export function mesurerAuRepos(ctx, fn) {
11
12
  ctx.task.meta.mesureDeTemps = true;
12
13
  return fn();
@@ -1,19 +1,24 @@
1
- // The night tests of a project: the files `*.nuit.test.*` and `*.nuit.spec.*`, too long for the
2
- // day, and its time budget benches (`*.budget.test.*`, `*.budget.spec.*`), whose measures move with
3
- // the load of the day; `npm test`, `npm run verifier` and the integration leave them out (the
4
- // frame's base configuration of the day, the package @roomi-fields/grillhouse/vitest-config, which every day
5
- // configuration extends, excludes both). The night (scripts/nuit.sh, by ./tests-de-nuit.mjs) plays them with this
6
- // configuration, from the root of its copy (`vitest run --root <copy> --config <this file>`),
7
- // after a green full pass (`npm run verifier -- --force`) and before the project's night script.
8
- // It reads no day configuration of the project, whether the project has one at its root or one
9
- // per package; it takes from the base configuration the common environment (git's settings) and
10
- // the measure of time: the setup file that notes the CPU pressure of each test and the duration
11
- // reporter, which gives 75, « à repasser », to a bench that fails under load
12
- // (scripts/langages/typescript/vitest-config/duree.reporter.mjs).
1
+ // What the day leaves out of a project: the night tests (`*.nuit.test.*`, `*.nuit.spec.*`), too
2
+ // long for the day, and the measures of time, the time budget benches (`*.budget.test.*`,
3
+ // `*.budget.spec.*`) and the time witnesses (a test file that imports `mesurerAuRepos`), whose
4
+ // measures move with the load of the day (grillhouse-bd7); `npm test`, `npm run verifier` and the
5
+ // integration leave them out (the frame's base configuration of the day, the package
6
+ // @roomi-fields/grillhouse/vitest-config, which every day configuration extends). The night
7
+ // (scripts/nuit.sh, by ./tests-de-nuit.mjs) plays them with this configuration, from the root of
8
+ // its copy (`vitest run --root <copy> --config <this file>`), after a green full pass (`npm run
9
+ // verifier -- --force`) and before the project's night script: its include names the night tests
10
+ // and the benches, and its plugin adds the witnesses under the root, or chooses the night tests
11
+ // alone or the measures alone, one file at a time (`nuit` of ./vitest-config/cibles.mjs, the
12
+ // variable GRILLHOUSE_TESTS_DE_NUIT). It reads no day configuration of the project, whether the
13
+ // project has one at its root or one per package; it takes from the base configuration the common
14
+ // environment (git's settings) and the measure of time: the setup file that notes the CPU pressure
15
+ // of each test and the duration reporter, which gives 75, « à repasser », to a measure that fails
16
+ // under load (scripts/langages/typescript/vitest-config/duree.reporter.mjs).
13
17
  import base from './vitest-config/base.mjs';
14
- import { HORS_DU_JOUR } from './vitest-config/cibles.mjs';
18
+ import { HORS_DU_JOUR, nuit } from './vitest-config/cibles.mjs';
15
19
 
16
20
  export default {
21
+ plugins: [nuit()],
17
22
  test: {
18
23
  env: base.test.env,
19
24
  environment: base.test.environment,
@@ -0,0 +1,51 @@
1
+ // The readings done once in a scope, as a build of Bazel reads each file once whatever the number
2
+ // of targets that ask it: inside `avecUneLecture`, a reading kept under its key (`luUneFois`) is
3
+ // done at its first call and given again after; out of any scope, it is done at each call. A
4
+ // scope is the time of one gesture of the core that asks a module many questions on a tree that
5
+ // does not move (the sweep of the siblings of HEAD's version, scripts/circuit.mjs); a module of
6
+ // language keeps there what it reads at a cost (cargo's metadata). A reading that throws is not
7
+ // kept. The scope lives on the process under a global symbol, so that every instance of this file
8
+ // shares it: the modules of language are loaded by `require` (./langages.mjs), which a test
9
+ // runner may load apart from the core's imports.
10
+
11
+ const PORTEE = Symbol.for('grillhouse.lecture-unique');
12
+
13
+ /** @returns {Map<string, unknown> | undefined} */
14
+ const portee = () => /** @type {any} */ (globalThis)[PORTEE];
15
+
16
+ /**
17
+ * Runs <faire> in a scope of readings done once, and returns what it returns; inside a scope
18
+ * already open, in that one.
19
+ * @template T
20
+ * @param {() => T} faire
21
+ * @returns {T}
22
+ */
23
+ export function avecUneLecture(faire) {
24
+ if (portee()) {
25
+ return faire();
26
+ }
27
+ /** @type {any} */ (globalThis)[PORTEE] = new Map();
28
+ try {
29
+ return faire();
30
+ } finally {
31
+ delete (/** @type {any} */ (globalThis)[PORTEE]);
32
+ }
33
+ }
34
+
35
+ /**
36
+ * What <lire> returns, read once under <cle> in the scope open, at each call out of any.
37
+ * @template T
38
+ * @param {string} cle
39
+ * @param {() => T} lire
40
+ * @returns {T}
41
+ */
42
+ export function luUneFois(cle, lire) {
43
+ const p = portee();
44
+ if (!p) {
45
+ return lire();
46
+ }
47
+ if (!p.has(cle)) {
48
+ p.set(cle, lire());
49
+ }
50
+ return /** @type {T} */ (p.get(cle));
51
+ }