Hustler-Stufe: Prüfstand baut mit VITE_HUSTLER_STUFE=6, Notiz zum Hochsetzen beim Livegang von P4 und P6
build.mjs setzt die Stufe über define ein (Standard 6, andere Ziffer 1 bis 9 aus der Umgebung, Ungültiges bricht ab), damit die Szenarien K (Pult P4) und L (Keller) weiter laufen; ein Test baut den Prüfstand mit Standard, 3 und ungültigen Werten. docs/superpowers/hustler-stufe.md erklärt Stufen, Sperren und die Schritte beim Hochsetzen. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
32f4f1d941
commit
2652108e4c
4 files changed
+105
-2
No files matched your search
@@ -1,5 +1,10 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { execFileSync } from 'node:child_process'
|
||||
import fs from 'node:fs'
|
||||
import os from 'node:os'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { loadModule } from './load.mjs'
|
||||
|
||||
// Prüfstand der Hustler-Seite: die Skript-API (gleiche Form wie createWorkersApi) für die manuelle Playwright-Abnahme.
|
||||
@@ -189,3 +194,36 @@ test('Fetch-Weiche hang: die Antwort kommt nie, der API-Client gibt nach der Zei
|
||||
const { api } = wired('hang', { timeoutMs: 40 })
|
||||
await assert.rejects(api.state(), { message: 'Der Hustler-Dienst ist gerade nicht erreichbar.', status: 0 })
|
||||
})
|
||||
|
||||
// ---------- Stufen-Sperre (hustlerStufe.js): der Prüfstand baut mit Stufe 6 ----------
|
||||
|
||||
test('Prüfstand: build.mjs baut standardmäßig mit Stufe 6, nimmt eine andere Stufe 1..9 aus VITE_HUSTLER_STUFE und lehnt Ungültiges ab', () => {
|
||||
const tmp = fs.realpathSync(os.tmpdir())
|
||||
const build = fileURLToPath(new URL('../../scripts/workers-harness/build.mjs', import.meta.url))
|
||||
const lauf = (wert) => {
|
||||
const dir = fs.mkdtempSync(path.join(tmp, 'hk-stufe-'))
|
||||
assert.ok(dir.startsWith(tmp + path.sep))
|
||||
try {
|
||||
const env = { ...process.env, TMPDIR: tmp }
|
||||
delete env.VITE_HUSTLER_STUFE
|
||||
if (wert !== undefined) env.VITE_HUSTLER_STUFE = wert
|
||||
let ausgabe = ''; let code = 0
|
||||
try {
|
||||
ausgabe = execFileSync(process.execPath, ['--max-old-space-size=512', build, dir], { env, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], timeout: 120000 })
|
||||
} catch (err) {
|
||||
code = err.status ?? 1
|
||||
}
|
||||
return { code, ausgabe, js: fs.existsSync(path.join(dir, 'harness.js')) ? fs.readFileSync(path.join(dir, 'harness.js'), 'utf8') : '' }
|
||||
} finally {
|
||||
fs.rmSync(dir, { recursive: true, force: true })
|
||||
}
|
||||
}
|
||||
const standard = lauf(undefined)
|
||||
assert.equal(standard.code, 0); assert.match(standard.ausgabe, /\(Stufe 6\)/); assert.match(standard.js, /function buildWert\(\) \{\s*try \{\s*return "6";/, 'Stufe 6 ist in den Prüfstand eingesetzt')
|
||||
const produktion = lauf('3')
|
||||
assert.equal(produktion.code, 0); assert.match(produktion.ausgabe, /\(Stufe 3\)/); assert.match(produktion.js, /function buildWert\(\) \{\s*try \{\s*return "3";/)
|
||||
for (const ungueltig of ['0', '10', 'abc', '']) {
|
||||
const r = lauf(ungueltig)
|
||||
assert.equal(r.code, 2, `VITE_HUSTLER_STUFE=${JSON.stringify(ungueltig)}`); assert.equal(r.js, '')
|
||||
}
|
||||
})
|
||||
Reference in new issue
Block a user