Add exit code expectations and fix @setup validation
This commit is contained in:
parent
0a1100aaf7
commit
aeef6041ec
|
|
@ -142,11 +142,22 @@ $ true
|
|||
// Check setup commands for failures
|
||||
for (let i = 0; i < setupCommands.length; i++) {
|
||||
const r = fileResult.results[i]
|
||||
if (r && r.exitCode !== 0) {
|
||||
const expected = setupCommands[i]!.exitCode
|
||||
const ok = expected === null
|
||||
? r?.exitCode === 0
|
||||
: expected === "*"
|
||||
? r?.exitCode !== 0
|
||||
: r?.exitCode === expected
|
||||
if (!ok) {
|
||||
if (opts.keep) {
|
||||
process.stderr.write(`${fileResult.tmpDir}\n`)
|
||||
} else {
|
||||
await cleanupTmpDir(fileResult.tmpDir)
|
||||
}
|
||||
return evaluateFile(
|
||||
parsed.path,
|
||||
[],
|
||||
`setup command failed (exit ${r.exitCode}): $ ${setupCommands[i]!.command}`,
|
||||
`setup command failed (exit ${r?.exitCode ?? "?"}): $ ${setupCommands[i]!.command}`,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,11 @@ export function parse(path: string, content: string): ShoutFile {
|
|||
|
||||
if (!seenCommand && line.startsWith("@")) {
|
||||
if (line.startsWith("@setup ")) {
|
||||
directives.push({ type: "setup", path: line.slice(7).trim(), line: i + 1 })
|
||||
const setupPath = line.slice(7).trim()
|
||||
if (!setupPath) {
|
||||
throw new Error(`${path}:${i + 1}: @setup requires a file path`)
|
||||
}
|
||||
directives.push({ type: "setup", path: setupPath, line: i + 1 })
|
||||
} else if (line.startsWith("@env ")) {
|
||||
const rest = line.slice(5).trim()
|
||||
const eq = rest.indexOf("=")
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user