also looking at this
test: retain bounded browser launch evidence on failure
#70
18 files
+620
-23
| @@ -3,9 +3,9 @@ import { runBoundedHostProcess } from '../../host/process' | ||
| 3 | 3 | |
| 4 | 4 | export const picoSdkRevision = '079c6f39023649b154152db30f1d781e884879bc' |
| 5 | 5 | export interface RuntimeBuildOptions { project?: string, target?: 'host' | 'pico2', sdk?: string, toolchain?: string, watchdogTest?: boolean, sensors?: boolean } |
| 6 | async function run(args: string[], cwd: string, env = process.env) { | |
| 7 | const result = await runBoundedHostProcess(args, { cwd, env, timeoutMs: 120000, stdoutBytes: 2_000_000, stderrBytes: 2_000_000, label: `Runtime build ${args[0]}` }) | |
| 8 | if (result.exitCode !== 0) throw new Error(`${args[0]} exited ${result.exitCode}:\n${(result.stdout + result.stderr).slice(-8000)}`, { cause: result }) | |
| 6 | async function run(stage: string, args: string[], cwd: string, env = process.env) { | |
| 7 | const result = await runBoundedHostProcess(args, { cwd, env, timeoutMs: 120000, stdoutBytes: 2_000_000, stderrBytes: 2_000_000, label: `Runtime build ${stage}` }) | |
| 8 | if (result.exitCode !== 0) throw new Error(`Runtime build ${stage}: ${args[0]} exited ${result.exitCode}:\n${(result.stdout + result.stderr).slice(-8000)}`, { cause: result }) | |
| 9 | 9 | return result.stdout.trim() |
| 10 | 10 | } |
| 11 | 11 | /** Local tools only; no shell interpolation, SDK download, firmware flashing or device access. */ |
| @@ -20,14 +20,14 @@ export async function buildRuntime(options: RuntimeBuildOptions = {}) { | ||
| 20 | 20 | const sdk = options.sdk ?? env.PICO_SDK_PATH |
| 21 | 21 | if (!sdk) throw new Error('Provide --sdk or PICO_SDK_PATH with the pinned Pico SDK 2.3.1 checkout') |
| 22 | 22 | env.PICO_SDK_PATH = resolve(sdk) |
| 23 | if (await run(['git', 'rev-parse', 'HEAD'], env.PICO_SDK_PATH) !== picoSdkRevision) throw new Error('Pico SDK revision does not match the retained build pin') | |
| 23 | if (await run('SDK revision', ['git', 'rev-parse', 'HEAD'], env.PICO_SDK_PATH) !== picoSdkRevision) throw new Error('Pico SDK revision does not match the retained build pin') | |
| 24 | 24 | // A dirty SDK is not a reproducible input. |
| 25 | if (await run(['git', 'status', '--porcelain', '--untracked-files=no'], env.PICO_SDK_PATH)) throw new Error('Pico SDK tracked files must be clean') | |
| 25 | if (await run('SDK worktree', ['git', 'status', '--porcelain', '--untracked-files=no'], env.PICO_SDK_PATH)) throw new Error('Pico SDK tracked files must be clean') | |
| 26 | 26 | if (options.toolchain) env.PICO_TOOLCHAIN_PATH = resolve(options.toolchain) |
| 27 | 27 | } |
| 28 | 28 | else if (options.watchdogTest || options.sensors) throw new Error('Sensor and watchdog firmware profiles are only available for pico2') |
| 29 | await run(['cmake', '-S', join(project, 'firmware/runtime'), '-B', directory, '-DCMAKE_BUILD_TYPE=Release', `-DDRONE_PICO2=${target === 'pico2' ? 'ON' : 'OFF'}`, `-DDRONE_WATCHDOG_TEST=${options.watchdogTest ? 'ON' : 'OFF'}`, `-DDRONE_SENSOR_BENCH=${options.sensors ? 'ON' : 'OFF'}`], project, env) | |
| 30 | await run(['cmake', '--build', directory, '--parallel', '2'], project, env) | |
| 31 | if (target === 'host') await run(['ctest', '--test-dir', directory, '--output-on-failure'], project, env) | |
| 29 | await run(`${target} configure`, ['cmake', '-S', join(project, 'firmware/runtime'), '-B', directory, '-DCMAKE_BUILD_TYPE=Release', `-DDRONE_PICO2=${target === 'pico2' ? 'ON' : 'OFF'}`, `-DDRONE_WATCHDOG_TEST=${options.watchdogTest ? 'ON' : 'OFF'}`, `-DDRONE_SENSOR_BENCH=${options.sensors ? 'ON' : 'OFF'}`], project, env) | |
| 30 | await run(`${target} compile`, ['cmake', '--build', directory, '--parallel', '2'], project, env) | |
| 31 | if (target === 'host') await run('host contracts', ['ctest', '--test-dir', directory, '--output-on-failure'], project, env) | |
| 32 | 32 | return { target, directory, artifact: join(directory, target === 'host' ? `drone_runtime_host${process.platform === 'win32' ? '.exe' : ''}` : 'drone_runtime.uf2'), physicalFlightEnabled: false as const } |
| 33 | 33 | } |