@roomi-fields/grillhouse 0.38.0 → 0.38.2

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.
@@ -68,9 +68,7 @@
68
68
  // its end, a failed test included, never `mkdtemp` by hand.
69
69
  // - Python writes its bytecode under one tree at the root, `__pycache__` (PYTHONPYCACHEPREFIX),
70
70
  // which the envelope makes proper to the session (`sorties.propres` of ./index.mjs); uv the
71
- // environment of each package under `.venv/<dossier>` at the root (UV_PROJECT_ENVIRONMENT; the
72
- // tree of HEAD's version of the proof of the red, which `uv run --locked` reconciles with its own
73
- // manifest and lock, reuses the copy's, under the folder `GRILLHOUSE_VENV_DE_LA_COPIE` names), and
71
+ // environment of each package under `.venv/<dossier>` at the root (UV_PROJECT_ENVIRONMENT), and
74
72
  // pytest its cache under `.pytest_cache/<dossier>` (`cache_dir`), where the envelope opens them
75
73
  // in writing, rather than in the package's folder, which a session whose plan does not write the
76
74
  // package could not write; uv its cache under ~/.cache/grillhouse/uv (UV_CACHE_DIR), the frame's
@@ -135,8 +133,6 @@ export const DE_NUIT = '*_nuit_test.py';
135
133
  export const PYCACHE = '__pycache__';
136
134
  /** The environments of uv and the caches of pytest, one per package, at the root. */
137
135
  export const VENV = '.venv';
138
- /** The variable by which a tree of HEAD's version receives the copy's folder of environments. */
139
- export const VENV_DE_LA_COPIE = 'GRILLHOUSE_VENV_DE_LA_COPIE';
140
136
  export const CACHE_DE_PYTEST = '.pytest_cache';
141
137
 
142
138
  /** The guards of the module: each its name and its script beside this one. */
@@ -208,12 +204,7 @@ function passe(racine, env) {
208
204
  // <vert>, the codes that count green beside 0.
209
205
  jouer({ t, args, cwd, programme }, vert = []) {
210
206
  // The environment of uv of the package, at the root (`sorties` of ./index.mjs).
211
- // A tree of HEAD's version receives the copy's folder of environments (`GRILLHOUSE_VENV_DE_LA_COPIE`)
212
- // and reuses its environment of the package.
213
- const venv = path.join(
214
- environnement[VENV_DE_LA_COPIE] || path.join(racine, VENV),
215
- path.relative(racine, cwd)
216
- );
207
+ const venv = path.join(racine, VENV, path.relative(racine, cwd));
217
208
  const r = spawnSync(programme, args, {
218
209
  cwd,
219
210
  env: { ...environnement, UV_PROJECT_ENVIRONMENT: venv },
@@ -1,6 +1,6 @@
1
1
  // The components of a project of Python, as uv finds a project (PEP 621, `pyproject.toml`): the
2
2
  // packages the module python answers the join with (scripts/jointure.d.ts, `composants`,
3
- // `composantDe`, `matieres`, `joueDesTests`, `lecteurs`, `estUnTest`, `arbreDAvant`, `manifestes`,
3
+ // `composantDe`, `matieres`, `joueDesTests`, `lecteurs`, `estUnTest`, `manifestes`,
4
4
  // `entreesDeLIndex`).
5
5
  //
6
6
  // - A component is a folder that holds a pyproject.toml, found under the root, the folders whose
@@ -19,9 +19,7 @@
19
19
  // any file under a folder `tests/` of a component, his helpers and his data. Of the manifests
20
20
  // (`manifestes`): the group `test` of the table `[dependency-groups]` of a pyproject.toml (PEP
21
21
  // 735), what the tests depend on, and the uv.lock of a component, which uv brings in line with
22
- // it; a change of any other part of a pyproject.toml is named by it. HEAD's version of a test
23
- // file (`arbreDAvant`) plays in a tree of its own, under the file's name, which the proof of the
24
- // red builds. The pyproject.toml is read
22
+ // it; a change of any other part of a pyproject.toml is named by it. The pyproject.toml is read
25
23
  // with smol-toml, a tool of this module (`outils`), an optional peer of the package loaded when a
26
24
  // manifest is judged.
27
25
  // - The readers of a package: none read by the module (a dependency between two packages of
@@ -146,15 +144,6 @@ export function estUnTest(chemin, racine) {
146
144
  return null;
147
145
  }
148
146
 
149
- /**
150
- * Whether HEAD's version of the test file <chemin> (from <racine>) plays in a tree of its own,
151
- * under the file's own name, so that its tests are named in its report as the file's, of its
152
- * kind (day, night); false for a file pytest does not play.
153
- */
154
- export function arbreDAvant(chemin, racine) {
155
- return Boolean(estUnTest(chemin, racine)?.joue);
156
- }
157
-
158
147
  // The parts of the parsed manifests <a> and <b> that differ, out of the group of the tests: each
159
148
  // `[<table>]`, a group of `[dependency-groups]` as `[dependency-groups].<groupe>`, a key out of
160
149
  // every table bare.
@@ -217,25 +217,6 @@ export default {
217
217
  'site/tests/donnees.json : test',
218
218
  ],
219
219
  },
220
- versionDeHead: {
221
- valide: [
222
- 'site/pages/generer.py',
223
- 'site/conftest.py',
224
- 'site/tests/donnees.json',
225
- 'README.md',
226
- ],
227
- // A test file plays in a tree, under its own name, a night test as a night test.
228
- invalide: [
229
- 'site/pages/test_pages.py',
230
- 'site/pages/pages_test.py',
231
- 'site/pages/site_nuit_test.py',
232
- ],
233
- attendu: [
234
- 'site/pages/test_pages.py → un arbre',
235
- 'site/pages/pages_test.py → un arbre',
236
- 'site/pages/site_nuit_test.py → un arbre',
237
- ],
238
- },
239
220
  fichiersEngendres: {
240
221
  valide: aJour,
241
222
  invalide: enRetard,
@@ -10,8 +10,7 @@
10
10
  // version (`binaires`, ./binaires.json). What uv, pytest and Python write in a project: `.venv`,
11
11
  // `.pytest_cache`, `__pycache__` (`ignorer`).
12
12
  // - Where they write, which the envelope opens to a session (`sorties`): in writing, `.venv` and
13
- // `.pytest_cache` at the root (the tree of HEAD's version of the proof of the red reuses the uv
14
- // environment of the copy, `GRILLHOUSE_VENV_DE_LA_COPIE`, `envDArbre`), where the commands make uv and pytest write for each package
13
+ // `.pytest_cache` at the root, where the commands make uv and pytest write for each package
15
14
  // (./commandes.mjs), and uv's cache, `~/.cache/grillhouse/uv` (UV_CACHE_DIR, ./commandes.mjs: the
16
15
  // frame's caches of compilation, never in the temporary directory); proper to the session, the
17
16
  // tree of the bytecode at the root, `__pycache__` (PYTHONPYCACHEPREFIX, ./commandes.mjs); read,
@@ -35,14 +34,13 @@ import { readFileSync } from 'node:fs';
35
34
  import path from 'node:path';
36
35
  import { fileURLToPath } from 'node:url';
37
36
  import { avecLeFichierDuPoste, empreintesDesTaches } from '../../services-du-noyau.mjs';
38
- import { commandes, GARDES, PYCACHE, VENV, VENV_DE_LA_COPIE } from './commandes.mjs';
37
+ import { commandes, GARDES, PYCACHE } from './commandes.mjs';
39
38
  import {
40
39
  composantDans,
41
40
  composants,
42
41
  entreesDeLIndex,
43
42
  estDeNuit,
44
43
  estUnTest,
45
- arbreDAvant,
46
44
  joueDesTests,
47
45
  lecteurs,
48
46
  liensDuManifeste,
@@ -113,16 +111,6 @@ export default {
113
111
  estUnTest,
114
112
  // A night test, `*_nuit_test.py` (`estDeNuit`).
115
113
  horsDuJour: chemin => estDeNuit(path.basename(chemin)),
116
- arbreDAvant,
117
- // Its tree reuses the uv environment of the copy: the folder of the environments, `<copie>/.venv`,
118
- // under `GRILLHOUSE_VENV_DE_LA_COPIE`, the same for every file of a package (uv reconciles it with
119
- // the manifest and lock of the tree, `uv run --locked`); a file out of every package gets none.
120
- envDArbre: (chemin, racine) =>
121
- composantDans(composants(racine), racine, chemin)
122
- ? { [VENV_DE_LA_COPIE]: path.join(racine, VENV) }
123
- : {},
124
- // Its tool plays HEAD's version of each test file in a tree (`arbreDAvant`): no name to read.
125
- testsDeHead: () => null,
126
114
  manifestes,
127
115
  fichiersEngendres: () => [
128
116
  {
@@ -227,22 +227,6 @@ export default {
227
227
  'packages/m/src/index.ts : matiere',
228
228
  ],
229
229
  },
230
- versionDeHead: {
231
- valide: ['packages/a/src/index.ts', 'packages/a/tests/aide.ts', 'README.md'],
232
- // A night test and a bench keep their mark, so that their sibling plays as they do.
233
- invalide: [
234
- 'packages/a/src/index.test.ts',
235
- 'packages/a/src/index.spec.mjs',
236
- 'packages/a/tests/tout.nuit.test.ts',
237
- 'packages/a/tests/vitesse.budget.test.ts',
238
- ],
239
- attendu: [
240
- 'packages/a/src/index.test.ts → packages/a/src/index.circuit-avant.test.ts',
241
- 'packages/a/src/index.spec.mjs → packages/a/src/index.circuit-avant.spec.mjs',
242
- 'packages/a/tests/tout.nuit.test.ts → packages/a/tests/tout.circuit-avant.nuit.test.ts',
243
- 'packages/a/tests/vitesse.budget.test.ts → packages/a/tests/vitesse.circuit-avant.budget.test.ts',
244
- ],
245
- },
246
230
  fichiersEngendres: {
247
231
  valide: aJour,
248
232
  invalide: enRetard,
@@ -50,7 +50,7 @@ import { composants as lesComposants, matieres } from './consommateurs.mjs';
50
50
  import { elementsDuLot } from './elements-du-lot.mjs';
51
51
  import { estNoteDeDette, lireSarif, RESULTATS } from '../../resultats.mjs';
52
52
  import { lecteurs } from './lecteurs.mjs';
53
- import { estUnTest, manifestes, soeurDAvant } from './regle-des-tests.mjs';
53
+ import { estUnTest, manifestes } from './regle-des-tests.mjs';
54
54
  import {
55
55
  avecLeFichierDuPoste,
56
56
  empreintesDesTaches,
@@ -273,16 +273,10 @@ export default {
273
273
  estUnTest,
274
274
  // A night test, a bench or a time witness (./vitest-config/cibles.mjs, `estHorsDuJour`).
275
275
  horsDuJour: (chemin, racine) => estHorsDuJour(path.resolve(racine, chemin)),
276
- soeurDAvant,
277
276
  // The summary of a run of Turborepo, which the core serves to the other modules.
278
277
  resumesDuLancement,
279
278
  garderLesResumes,
280
279
  lireLesResumes,
281
- // Its tool plays HEAD's version of each test file beside it (`soeurDAvant`): no tree, no name
282
- // to read.
283
- arbreDAvant: () => false,
284
- envDArbre: () => ({}),
285
- testsDeHead: () => null,
286
280
  manifestes,
287
281
  fichiersEngendres: () => [
288
282
  engendre(
@@ -11,10 +11,6 @@
11
11
  //
12
12
  // Any other file is none of them: null.
13
13
  //
14
- // The sibling of HEAD's version of a test file Vitest plays (`soeurDAvant`), which the proof of
15
- // the red plays beside it: `<nom>.circuit-avant.<test|spec>.<ext>`, the mark of a night test or of
16
- // a bench kept before it (`<nom>.circuit-avant.nuit.test.<ext>`), so that it plays as its file.
17
- //
18
14
  // What the testwriter writes of the manifests (`manifestes`): the field that declares what the
19
15
  // tests of a package depend on, `devDependencies` of its package.json (npm's docs,
20
16
  // « devDependencies »), as the author of a test of Bazel declares the deps of its target; and
@@ -50,17 +46,6 @@ export function estUnTest(chemin, racine) {
50
46
  return joue || test || matiere ? { joue, test, matiere } : null;
51
47
  }
52
48
 
53
- // The sibling of HEAD's version of the test file <chemin> (from the root <racine>), which Vitest
54
- // plays in the same run: `<nom>.circuit-avant.<test|spec>.<ext>` beside it, a name of NOM_DE_TEST,
55
- // of its file's kind (`.nuit` or `.budget` kept before `.test`);
56
- // null for a file Vitest does not play.
57
- export function soeurDAvant(chemin, racine) {
58
- if (!estUnTest(chemin, racine)?.joue) {
59
- return null;
60
- }
61
- return chemin.replace(/((?:\.nuit|\.budget)?\.(?:test|spec)\.[cm]?[jt]sx?)$/, '.circuit-avant$1');
62
- }
63
-
64
49
  // The field of a manifest that declares what its tests depend on.
65
50
  const DES_TESTS = 'devDependencies';
66
51
 
@@ -111,10 +111,14 @@ import {
111
111
  avecLaMachineEtUnePlace,
112
112
  BASE_DU_LOT,
113
113
  CHANGEMENTS,
114
+ consignerLesRegressions,
115
+ garderLeRegistre,
114
116
  garderLeTotal,
115
117
  garderLeVert,
116
118
  LA_FORME,
119
+ langageDe,
117
120
  lireLaTranche,
121
+ lireLeRegistre,
118
122
  mesure,
119
123
  nommerLAvancement,
120
124
  ouvrirAvancement,
@@ -126,6 +130,7 @@ import {
126
130
  testsCibles,
127
131
  } from '../../services-du-noyau.mjs';
128
132
  import { paquets, TYPAGE } from '../../paquets.mjs';
133
+ import { RESULTATS } from '../../resultats.mjs';
129
134
  import { fichiersDeLaTranche, RAPPORTS } from './tranches.mjs';
130
135
  import { garderLesResumes } from './resume-du-lanceur.mjs';
131
136
  import { controlesDuDepot, planifier } from './turbo-des-paquets.mjs';
@@ -341,6 +346,12 @@ function passe({ racine, demandes, env, dire, coeurs }) {
341
346
  if (m) {
342
347
  dire(m.ligne);
343
348
  }
349
+ // A complete pass plays every test for real: when its caller names a results directory
350
+ // (`GRILLHOUSE_RESULTATS`, which the night sets for its pass, scripts/nuit.sh), it keeps the
351
+ // registry of results test by test besides the last green, which the proof of the red reads
352
+ // (scripts/registre-des-resultats.mjs); a pass that names none writes no registry, so the pass
353
+ // itself opens none and its environment is unchanged.
354
+ const complet = tout && !gardesSeules && !sansTests && !tranche && !filtre(args);
344
355
  const taches = new Set();
345
356
  try {
346
357
  // A tranche writes its reports anew.
@@ -372,6 +383,25 @@ function passe({ racine, demandes, env, dire, coeurs }) {
372
383
  garder: garderLeVert,
373
384
  partielle: Boolean(tranche) || sansTests,
374
385
  });
386
+ // The registry of a complete pass whose caller named a results directory, from the reports of
387
+ // every language: green, it keeps the passed tests of its branch; red on main's own branch (the
388
+ // night, or a complete pass on main), it records as regressions the tests the registry held
389
+ // green that turned red, with the moment they did. A red pass on a ticket's branch records none:
390
+ // its reds are the ticket's work.
391
+ if (complet && env[RESULTATS] && m?.etat) {
392
+ const rapports = langageDe(racine).verdict(env[RESULTATS]).rapports;
393
+ if (code === 0) {
394
+ garderLeRegistre(m.etat, rapports);
395
+ } else if (!m.etat.branche || m.etat.branche === m.etat.main) {
396
+ const rouges = rapports.flatMap(r =>
397
+ (r.tests ?? [])
398
+ .filter(t => t.etat === 'failed')
399
+ .map(t => ({ fichier: path.relative(racine, r.fichier), nom: t.nom }))
400
+ );
401
+ const quand = env.GRILLHOUSE_VERIFICATION_SORTE === 'Nuit' ? 'nuit' : 'jour';
402
+ consignerLesRegressions(m.etat, rouges, lireLeRegistre(racine), quand);
403
+ }
404
+ }
375
405
  return code;
376
406
  } finally {
377
407
  m?.retirer();
package/scripts/nuit.sh CHANGED
@@ -149,6 +149,12 @@ journal="$dossier/$(date +%Y-%m-%d).log"
149
149
  # The red tasks of the full pass, written by the verification of the module of the language.
150
150
  rouges="$dossier/rouges"
151
151
  rm -f "$rouges"
152
+ # The results directory of the full pass: each language writes its reports there, and the pass reads
153
+ # them to keep the registry of results (scripts/registre-des-resultats.mjs), which the proof of the
154
+ # red reads to tell a test main holds green from a new one.
155
+ resultats="$dossier/resultats"
156
+ rm -rf "$resultats"
157
+ mkdir -p "$resultats"
152
158
 
153
159
  tete="$(git -C "$racine" rev-parse HEAD)"
154
160
  copie="$racine/.claude/worktrees/nuit"
@@ -282,7 +288,7 @@ process.exit(paquets(process.argv[2]).some(p => p.pkg.name === "@roomi-fields/gr
282
288
  # The full pass, played for real: the night replays no log of the cache. Each step plays even
283
289
  # when one before it is red; a step à repasser ends the night there, red if a step before it is.
284
290
  local code tache avant
285
- GRILLHOUSE_ROUGES="$rouges" GRILLHOUSE_VERIFICATION_SORTE=Nuit monter npm --prefix "$copie" run verifier -- --force
291
+ GRILLHOUSE_ROUGES="$rouges" GRILLHOUSE_RESULTATS="$resultats" GRILLHOUSE_VERIFICATION_SORTE=Nuit monter npm --prefix "$copie" run verifier -- --force
286
292
  code=$?
287
293
  if [ "$code" -eq 75 ]; then
288
294
  echo "⏱ la passe complète est à repasser (code 75) : l'attente de la machine a atteint sa borne."
@@ -0,0 +1,119 @@
1
+ // The registry of test results, by branch, of a repository: what the last green pass of
2
+ // `npm run verifier` (scripts/langages/typescript/verifier.mjs) holds, test by test. As Chromium's
3
+ // ResultDB and Mozilla's Treeherder keep the result of each test by version of the main branch, and
4
+ // as `.pytest_cache` keeps the last run's tests, the proof of the red reads here which tests main
5
+ // already holds green, instead of compiling and playing HEAD's version of each test file.
6
+ //
7
+ // - It lives in `<git common dir>/grillhouse/resultats/<branche>.json`, one per branch, beside the
8
+ // last green (scripts/dernier-vert.mjs), written by the same green pass under the same conditions
9
+ // (`poserLeVert`): `{ commit, tests: { "<fichier depuis la racine>": { "<nom complet>":
10
+ // "passed" } } }`, HEAD at that pass and the passed tests of each file.
11
+ // - A pass in a copy reads the registry of its branch when it counts (its commit an ancestor of
12
+ // HEAD), else main's, as `dernier-vert` measures the last green: the proof of a ticket's copy
13
+ // thus reads what main holds green.
14
+ // - A test of the lot whose full name is in the registry of <fichier> existed before the ticket
15
+ // (its green is accepted); one absent is new (a test named in `portent_le_travail` must be red).
16
+ // - A regression is a test the registry held green that a pass of the day (`verifier`) or of the
17
+ // night turns red: it is recorded in `<git common dir>/grillhouse/regressions/<branche>.json`
18
+ // with the moment it turned red — its last green commit and its first red HEAD — for the night to
19
+ // classify and correct (the charter, « Main reste vert »).
20
+ import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
21
+ import path from 'node:path';
22
+ import { etatDuDepot, fichierSous, git, SHA } from './etat-du-depot.mjs';
23
+
24
+ // Keeps <etat> (etatDuDepot) and the passed tests of the reports <rapports> (`verdict` of the join,
25
+ // each `{ fichier, tests: [{ nom, etat }] }`, `fichier` absolute) as the registry of its branch,
26
+ // of main when HEAD is detached. Only the passed tests, since a green pass holds no other.
27
+ export function garderLeRegistre(etat, rapports) {
28
+ const branche = etat.branche ?? etat.main;
29
+ const f = branche ? fichierSous(etat.racine, 'resultats', branche) : null;
30
+ if (!f) {
31
+ return;
32
+ }
33
+ const tests = {};
34
+ for (const r of rapports) {
35
+ const rel = path.relative(etat.racine, r.fichier);
36
+ for (const t of r.tests ?? []) {
37
+ if (t.etat === 'passed') {
38
+ (tests[rel] ??= {})[t.nom] = 'passed';
39
+ }
40
+ }
41
+ }
42
+ mkdirSync(path.dirname(f), { recursive: true });
43
+ writeFileSync(f, `${JSON.stringify({ commit: etat.commit, tests }, null, 2)}\n`);
44
+ }
45
+
46
+ // The registry that counts for a pass in the repository at <racine>: its branch's when its commit
47
+ // is an ancestor of HEAD, else main's, as `dernier-vert` reads the last green. `{ commit, tests,
48
+ // branche }`, or null when none counts (out of git, or no registry whose commit is an ancestor).
49
+ export function lireLeRegistre(racine) {
50
+ const etat = etatDuDepot(racine);
51
+ if (etat.raison) {
52
+ return null;
53
+ }
54
+ for (const branche of [...new Set([etat.branche, etat.main].filter(Boolean))]) {
55
+ const f = fichierSous(racine, 'resultats', branche);
56
+ let v = null;
57
+ try {
58
+ v = JSON.parse(readFileSync(f, 'utf8'));
59
+ } catch {
60
+ continue;
61
+ }
62
+ if (!SHA.test(v?.commit ?? '') || typeof v.tests !== 'object' || v.tests === null) {
63
+ continue;
64
+ }
65
+ if (git(racine, ['merge-base', '--is-ancestor', v.commit, etat.commit]).status !== 0) {
66
+ continue;
67
+ }
68
+ return { commit: v.commit, tests: v.tests, branche };
69
+ }
70
+ return null;
71
+ }
72
+
73
+ // The green tests of the file <fichier> (from the racine) that the registry <registre> holds, by
74
+ // their full name; an empty set for a file the registry does not hold (a new file of the lot).
75
+ export function vertsDuRegistre(registre, fichier) {
76
+ const t = registre?.tests?.[fichier] ?? {};
77
+ return new Set(Object.keys(t).filter(nom => t[nom] === 'passed'));
78
+ }
79
+
80
+ // Records as regressions, in `regressions/<branche>.json` of <etat>'s branch (of main detached),
81
+ // the red tests <rouges> (`{ fichier, nom }`, `fichier` from the racine) that the registry
82
+ // <registre> held green, from a pass of <quand> ('jour' | 'nuit'): `{ fichier, nom, dernierVert,
83
+ // premierRouge, quand, vu }`, the moment a green test turned red. A regression already recorded
84
+ // for the same test is not duplicated (its first red stays its first).
85
+ export function consignerLesRegressions(etat, rouges, registre, quand) {
86
+ const branche = etat.branche ?? etat.main;
87
+ const f = branche ? fichierSous(etat.racine, 'regressions', branche) : null;
88
+ if (!f || !registre) {
89
+ return;
90
+ }
91
+ let liste = [];
92
+ try {
93
+ const v = JSON.parse(readFileSync(f, 'utf8'));
94
+ liste = Array.isArray(v) ? v : [];
95
+ } catch {
96
+ liste = [];
97
+ }
98
+ const connu = new Set(liste.map(r => `${r.fichier}\t${r.nom}`));
99
+ let change = false;
100
+ for (const { fichier, nom } of rouges) {
101
+ if (registre.tests?.[fichier]?.[nom] !== 'passed' || connu.has(`${fichier}\t${nom}`)) {
102
+ continue;
103
+ }
104
+ liste.push({
105
+ fichier,
106
+ nom,
107
+ dernierVert: registre.commit,
108
+ premierRouge: etat.commit,
109
+ quand,
110
+ vu: new Date().toISOString(),
111
+ });
112
+ connu.add(`${fichier}\t${nom}`);
113
+ change = true;
114
+ }
115
+ if (change) {
116
+ mkdirSync(path.dirname(f), { recursive: true });
117
+ writeFileSync(f, `${JSON.stringify(liste, null, 2)}\n`);
118
+ }
119
+ }
@@ -41,6 +41,12 @@ export {
41
41
  export { luUneFois } from './lecture-unique.mjs';
42
42
  export { avecLeFichierDuPoste } from './fichier-du-poste.mjs';
43
43
  export { BASE_DU_LOT, CHANGEMENTS, DEPUIS_LE_VERT, garderLeVert, mesure } from './dernier-vert.mjs';
44
+ export {
45
+ consignerLesRegressions,
46
+ garderLeRegistre,
47
+ lireLeRegistre,
48
+ vertsDuRegistre,
49
+ } from './registre-des-resultats.mjs';
44
50
  export { lireLaListe, paquetsDeLEnveloppe } from './enveloppe/paquets-du-plan.mjs';
45
51
  export { AVANCEMENT, ecrireTache } from './mesure/avancement.mjs';
46
52
  export {
@@ -1,178 +0,0 @@
1
- // The names of the tests of HEAD's version of a test file of Rust that cargo cannot play twice in
2
- // one run, read without playing them (the join, `testsDeHead`; the owner's decision on
3
- // grillhouse-3e2): a unit test file of `src/` (`src/**/tests.rs`, a file of a folder `tests/` under
4
- // `src/`), compiled as a module of its crate, and each file of a test target
5
- // `tests/<dossier>/main.rs`, its root or one of its modules (`tests/it/foo.rs`, grillhouse-pkl.9);
6
- // and a target `tests/<nom>.rs` whose sibling no longer compiles, read with its modules beside it
7
- // (grillhouse-3e2.2). The proof of the red holds each name for a green HEAD already holds.
8
- //
9
- // - A name is the one the verdict gives (./verdict.mjs), the path nextest reports: the module path
10
- // of the test in its binary, `<module>::…::<fn>` (tried on 2026-11-02:
11
- // `access::engines::tests::groupe::interne` for `src/access/engines/tests.rs`, `m::dedans` and
12
- // `aide::aidant` for `tests/scenario/main.rs` and its `mod aide;`).
13
- // - A test is a function under an attribute `#[test]`, or `#[<chemin>::test]` (`#[tokio::test]`),
14
- // in the inline modules that hold it (`mod <nom> { … }`); comments, strings and character
15
- // literals are read as blanks, so that their braces do not count.
16
- // - A unit test file of `src/`: its module path is its path under `src/` (`mod.rs` its folder's);
17
- // the verdict gives each of its out-of-line modules (`mod <nom>;`) to its own file, so they are
18
- // not read here. A file of a target `tests/<dossier>/main.rs` likewise: its module path is its
19
- // path under `tests/<dossier>/` (`main.rs` none, `mod.rs` its folder's). A target
20
- // `tests/<nom>.rs`: the verdict gives it all its binary's tests, so its out-of-line modules are
21
- // read too, as rustc finds them (`<nom>.rs` beside it or `<nom>/mod.rs`, a module of `<f>.rs`
22
- // under `<f>/`).
23
- import path from 'node:path';
24
-
25
- // The text <t> with its comments, strings and character literals read as blanks.
26
- export function sansLitteraux(t) {
27
- let out = '';
28
- let i = 0;
29
- while (i < t.length) {
30
- if (t.startsWith('//', i)) {
31
- const fin = t.indexOf('\n', i);
32
- i = fin < 0 ? t.length : fin;
33
- continue;
34
- }
35
- if (t.startsWith('/*', i)) {
36
- let profondeur = 0;
37
- do {
38
- if (t.startsWith('/*', i)) {
39
- profondeur++;
40
- i += 2;
41
- } else if (t.startsWith('*/', i)) {
42
- profondeur--;
43
- i += 2;
44
- } else {
45
- i++;
46
- }
47
- } while (profondeur > 0 && i < t.length);
48
- out += ' ';
49
- continue;
50
- }
51
- const brute = /^b?r(#*)"/.exec(t.slice(i, i + 260));
52
- if (brute && !/\w/.test(t[i - 1] ?? '')) {
53
- const fin = t.indexOf(`"${brute[1]}`, i + brute[0].length);
54
- i = fin < 0 ? t.length : fin + 1 + brute[1].length;
55
- out += ' ';
56
- continue;
57
- }
58
- if (t[i] === '"') {
59
- i++;
60
- while (i < t.length && t[i] !== '"') {
61
- i += t[i] === '\\' ? 2 : 1;
62
- }
63
- i++;
64
- out += ' ';
65
- continue;
66
- }
67
- if (t[i] === "'") {
68
- const car = /^'(?:\\(?:u\{[0-9a-fA-F]+\}|x[0-9a-fA-F]{2}|.)|[^\\'])'/.exec(
69
- t.slice(i, i + 16)
70
- );
71
- if (car) {
72
- i += car[0].length;
73
- out += ' ';
74
- continue;
75
- }
76
- }
77
- out += t[i];
78
- i++;
79
- }
80
- return out;
81
- }
82
-
83
- // What the text <texte> of a file of Rust holds: `tests`, each test's module path within the
84
- // file and its name, and `externes`, each out-of-line module's path within the file.
85
- export function lireLeFichier(texte) {
86
- const t = sansLitteraux(texte);
87
- const tests = [];
88
- const externes = [];
89
- const pile = [];
90
- let marque = false;
91
- const jeton = /#!?\s*\[|\bmod\s+([A-Za-z_]\w*)\s*([{;])|\bfn\s+([A-Za-z_]\w*)|[{}]/g;
92
- const ici = () => pile.filter(Boolean);
93
- let m;
94
- while ((m = jeton.exec(t))) {
95
- const j = m[0];
96
- if (j.startsWith('#')) {
97
- let profondeur = 1;
98
- let k = jeton.lastIndex;
99
- while (k < t.length && profondeur > 0) {
100
- if (t[k] === '[') {
101
- profondeur++;
102
- } else if (t[k] === ']') {
103
- profondeur--;
104
- }
105
- k++;
106
- }
107
- const attribut = t.slice(jeton.lastIndex, k - 1).trim();
108
- if (/^(?:\w+\s*::\s*)*test$/.test(attribut)) {
109
- marque = true;
110
- }
111
- jeton.lastIndex = k;
112
- } else if (m[1]) {
113
- if (m[2] === '{') {
114
- pile.push(m[1]);
115
- } else {
116
- externes.push([...ici(), m[1]]);
117
- }
118
- marque = false;
119
- } else if (m[3]) {
120
- if (marque) {
121
- tests.push([...ici(), m[3]]);
122
- }
123
- marque = false;
124
- } else if (j === '{') {
125
- pile.push(null);
126
- } else {
127
- pile.pop();
128
- }
129
- }
130
- return { tests, externes };
131
- }
132
-
133
- /**
134
- * The names of the tests of HEAD's version of the test file <chemin> (from the root), as the
135
- * verdict names them: with <module>, a unit test file of `src/` or a file of a target
136
- * `tests/<dossier>/main.rs`, its module path; without (null), a target `tests/<nom>.rs`, its
137
- * out-of-line modules read too. <lire>
138
- * gives HEAD's text of a file from the root, null for none. Null when HEAD does not hold <chemin>.
139
- * @param {string} chemin
140
- * @param {string[] | null} module
141
- * @param {(f: string) => string | null} lire
142
- * @returns {string[] | null}
143
- */
144
- export function nomsDeHead(chemin, module, lire) {
145
- const texte = lire(chemin);
146
- if (texte === null) {
147
- return null;
148
- }
149
- if (module) {
150
- return lireLeFichier(texte).tests.map(t => [...module, ...t].join('::'));
151
- }
152
- const noms = [];
153
- const vus = new Set();
154
- // The file <f> of text <tx>, its modules under <dossier>, its tests under <prefixe>.
155
- const parcourir = (f, tx, dossier, prefixe) => {
156
- if (vus.has(f)) {
157
- return;
158
- }
159
- vus.add(f);
160
- const { tests, externes } = lireLeFichier(tx);
161
- noms.push(...tests.map(t => [...prefixe, ...t].join('::')));
162
- for (const e of externes) {
163
- const base = path.posix.join(dossier, ...e);
164
- for (const [g, sous] of [
165
- [`${base}.rs`, base],
166
- [path.posix.join(base, 'mod.rs'), base],
167
- ]) {
168
- const txg = lire(g);
169
- if (txg !== null) {
170
- parcourir(g, txg, sous, [...prefixe, ...e]);
171
- break;
172
- }
173
- }
174
- }
175
- };
176
- parcourir(chemin, texte, path.posix.dirname(chemin), []);
177
- return noms;
178
- }