| 505 | // Without --build it builds a throwaway snapshot of the working tree and removes it |
| 506 | // afterward; the results directory is kept either way. |
| 507 | export async function smoke(options) { |
| 508 | let begin = Date.now(); |
| 509 | let name = options.base; |
| 510 | let temporary = !name; |
| 511 | if (temporary) { |
| 512 | name = `smoke-${new Date().toISOString().replaceAll(/[:.]/g, '-')}`; |
| 513 | await build(name); |
| 514 | } |
| 515 | try { |
| 516 | let {result, dir} = await run({...options, base: name, candidate: name, quiet: true}); |
| 517 | let count = result.scenarios.length; |
| 518 | console.log( |
| 519 | `\nSmoke test passed: ${count} scenario${count === 1 ? '' : 's'}, ${options.blocks} launches, ${Math.round((Date.now() - begin) / 1000)} s. Report: ${path.join(dir, 'report.md')}` |
| 520 | ); |
| 521 | } finally { |
| 522 | if (temporary) { |
| 523 | await fs.rm(buildPath(name), {recursive: true, force: true}); |
| 524 | } |
| 525 | } |
| 526 | } |