diff --git a/run-tests.js b/run-tests.js index 93547d3c0f0d6..a8745665593a5 100644 --- a/run-tests.js +++ b/run-tests.js @@ -420,26 +420,11 @@ async function main() { } } } + if (!passed) { console.error(`${test} failed to pass within ${numRetries} retries`) children.forEach((child) => child.kill()) - if (isTestJob) { - try { - const testsOutput = await fs.readFile( - `${test}${RESULTS_EXT}`, - 'utf8' - ) - console.log( - `--test output start--`, - testsOutput, - `--test output end--` - ) - } catch (err) { - console.log(`Failed to load test output`, err) - } - } - if (!shouldContinueTestsOnError) { cleanUpAndExit(1) } else { @@ -448,6 +433,21 @@ async function main() { ) } } + + // Emit test output if test failed or if we're continuing tests on error + if ((!passed || shouldContinueTestsOnError) && isTestJob) { + try { + const testsOutput = await fs.readFile(`${test}${RESULTS_EXT}`, 'utf8') + console.log( + `--test output start--`, + testsOutput, + `--test output end--` + ) + } catch (err) { + console.log(`Failed to load test output`, err) + } + } + sema.release() dirSema.release() }) diff --git a/test/lib/e2e-utils.ts b/test/lib/e2e-utils.ts index 08eff34a2866f..e5281405770e0 100644 --- a/test/lib/e2e-utils.ts +++ b/test/lib/e2e-utils.ts @@ -11,7 +11,19 @@ import { shouldRunTurboDevTest } from './next-test-utils' export type { NextInstance } // increase timeout to account for yarn install time -jest.setTimeout(240 * 1000) +// if either test runs for the --turbo or have a custom timeout, set reduced timeout instead. +// this is due to current --turbo test have a lot of tests fails with timeouts, ends up the whole +// test job exceeds the 6 hours limit. +let testTimeout = shouldRunTurboDevTest() ? (240 * 1000) / 4 : 240 * 1000 +if (process.env.NEXT_E2E_TEST_TIMEOUT) { + try { + testTimeout = parseInt(process.env.NEXT_E2E_TEST_TIMEOUT, 10) + } catch (_) { + // ignore + } +} + +jest.setTimeout(testTimeout) const testsFolder = path.join(__dirname, '..')