()
| 13 | const initialStatusRegex = /Running (\d+) tests/; |
| 14 | |
| 15 | async function main() { |
| 16 | const [runfilesDir, targetName, ...testArgs] = process.argv.slice(2); |
| 17 | const testEntrypoint = path.resolve(runfilesDir, '../', targetName); |
| 18 | const testWorkingDir = path.resolve(runfilesDir, '_main'); |
| 19 | const tasks = []; |
| 20 | const progress = {}; |
| 21 | |
| 22 | tasks.push( |
| 23 | spawnTest( |
| 24 | 'bash', |
| 25 | [testEntrypoint, ...testArgs], |
| 26 | { |
| 27 | cwd: testWorkingDir, |
| 28 | env: { |
| 29 | // Try to construct a pretty hermetic environment, as within Bazel. |
| 30 | PATH: process.env.PATH, |
| 31 | E2E_SHARD_TOTAL: process.env.E2E_SHARD_TOTAL, |
| 32 | E2E_SHARD_INDEX: process.env.E2E_SHARD_INDEX, |
| 33 | FORCE_COLOR: '0', |
| 34 | // Needed by `rules_js` |
| 35 | BAZEL_BINDIR: '.', |
| 36 | // Needed to run the E2E in a different temp path. |
| 37 | E2E_TEMP: process.env.E2E_TEMP, |
| 38 | // Using the `--glob` causes a bunch of issues due to path expansion in nested bash scripts. |
| 39 | TESTBRIDGE_TEST_ONLY: process.env.TESTBRIDGE_TEST_ONLY, |
| 40 | }, |
| 41 | }, |
| 42 | (s) => (progress[0] = s), |
| 43 | ), |
| 44 | ); |
| 45 | |
| 46 | const printUpdate = () => { |
| 47 | console.error(`----`); |
| 48 | for (const [taskId, status] of Object.entries(progress)) { |
| 49 | const durationInMin = (Date.now() - status.startTime) / 1000 / 60; |
| 50 | console.error( |
| 51 | `Shard #${taskId}: stage ${status.state} | ` + |
| 52 | `${status.current}/${status.max} tests completed (${durationInMin.toFixed(2)}min)`, |
| 53 | ); |
| 54 | } |
| 55 | }; |
| 56 | |
| 57 | const progressInterval = setInterval(printUpdate, 4000); |
| 58 | |
| 59 | try { |
| 60 | const outputs = await Promise.all(tasks); |
| 61 | printUpdate(); |
| 62 | |
| 63 | for (const [idx, text] of outputs.entries()) { |
| 64 | console.log(`---------- ${idx} -----------`); |
| 65 | console.log(text); |
| 66 | } |
| 67 | |
| 68 | console.error(''); |
| 69 | console.error('Done! Passing'); |
| 70 | } catch (e) { |
| 71 | if (e instanceof TestSpawnError) { |
| 72 | console.error(e.output); |
no test coverage detected