( worker: Worker & typeof runnerWorker, state: RunnerState, )
| 116 | |
| 117 | // Callback to re-run tests after some change |
| 118 | async function onChange( |
| 119 | worker: Worker & typeof runnerWorker, |
| 120 | state: RunnerState, |
| 121 | ) { |
| 122 | const {compilerVersion, isCompilerBuildValid, mode, filter} = state; |
| 123 | if (isCompilerBuildValid) { |
| 124 | const start = performance.now(); |
| 125 | |
| 126 | // console.clear() only works when stdout is connected to a TTY device. |
| 127 | // we're currently piping stdout (see main.ts), so let's do a 'hack' |
| 128 | console.log('\u001Bc'); |
| 129 | |
| 130 | // we don't clear console after this point, since |
| 131 | // it may contain debug console logging |
| 132 | const results = await runFixtures( |
| 133 | worker, |
| 134 | mode.filter ? filter : null, |
| 135 | compilerVersion, |
| 136 | ); |
| 137 | const end = performance.now(); |
| 138 | if (mode.action === RunnerAction.Update) { |
| 139 | update(results); |
| 140 | state.lastUpdate = end; |
| 141 | } else { |
| 142 | report(results); |
| 143 | } |
| 144 | console.log(`Completed in ${Math.floor(end - start)} ms`); |
| 145 | } else { |
| 146 | console.error( |
| 147 | `${mode}: Found errors in Forget source code, skipping test fixtures.`, |
| 148 | ); |
| 149 | } |
| 150 | console.log( |
| 151 | '\n' + |
| 152 | (mode.filter |
| 153 | ? `Current mode = FILTER, filter test fixtures by "${FILTER_PATH}".` |
| 154 | : 'Current mode = NORMAL, run all test fixtures.') + |
| 155 | '\nWaiting for input or file changes...\n' + |
| 156 | 'u - update all fixtures\n' + |
| 157 | `f - toggle (turn ${mode.filter ? 'off' : 'on'}) filter mode\n` + |
| 158 | 'q - quit\n' + |
| 159 | '[any] - rerun tests\n', |
| 160 | ); |
| 161 | } |
| 162 | |
| 163 | /** |
| 164 | * Runs the compiler in watch or single-execution mode |
no test coverage detected