From 8986c179b0397b893173a3ad7c364f581724b12d Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Thu, 29 Jul 2021 08:51:56 -0500 Subject: [PATCH 1/2] Only output test logs on failure in CI --- azure-pipelines.yml | 4 +++- run-tests.js | 25 ++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 38e67f260869a..37fd3bc6bd482 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -72,6 +72,8 @@ stages: - job: test_ie11 pool: vmImage: 'windows-2019' + variables: + BROWSER_NAME: internet explorer steps: - checkout: none - task: NodeTool@0 @@ -86,7 +88,7 @@ stages: path: $(System.DefaultWorkingDirectory) displayName: Cache Build - script: | - yarn testie --forceExit test/integration/production/ test/integration/css-client-nav/ test/integration/rewrites-has-condition/ + node run-tests.js -c 1 test/integration/production/test/index.test.js test/integration/css-client-nav/test/index.test.js test/integration/rewrites-has-condition/test/index.test.js displayName: 'Run tests' - job: test_unit diff --git a/run-tests.js b/run-tests.js index 9509b1aebc79c..765907b4dd91f 100644 --- a/run-tests.js +++ b/run-tests.js @@ -112,6 +112,7 @@ async function main() { } } catch (err) { console.log(`Failed to fetch timings data`, err) + process.exit(1) } } } @@ -183,6 +184,7 @@ async function main() { const runTest = (test = '', usePolling) => new Promise((resolve, reject) => { const start = new Date().getTime() + let outputChunks = [] const child = spawn( 'node', [ @@ -196,7 +198,7 @@ async function main() { test, ], { - stdio: 'inherit', + stdio: ['ignore', 'pipe', 'pipe'], env: { JEST_RETRY_TIMES: 0, ...process.env, @@ -217,10 +219,19 @@ async function main() { }, } ) + child.stdout.on('data', (chunk) => { + outputChunks.push(chunk) + }) + child.stderr.on('data', (chunk) => { + outputChunks.push(chunk) + }) children.add(child) child.on('exit', (code) => { children.delete(child) - if (code) reject(new Error(`failed with code: ${code}`)) + if (code) { + outputChunks.forEach((chunk) => process.stdout.write(chunk)) + reject(new Error(`failed with code: ${code}`)) + } resolve(new Date().getTime() - start) }) }) @@ -239,15 +250,19 @@ async function main() { // concurrent ones for (const test of nonConcurrentTestNames) { let passed = false - + console.log(test) for (let i = 0; i < NUM_RETRIES + 1; i++) { try { + console.log(`Starting ${test} retry ${i}/${NUM_RETRIES}`) const time = await runTest(test, i > 0) timings.push({ file: test, time, }) passed = true + console.log( + `Finished ${test} on retry ${i}/${NUM_RETRIES} in ${time / 1000}s` + ) break } catch (err) { if (i < NUM_RETRIES) { @@ -287,12 +302,16 @@ async function main() { for (let i = 0; i < NUM_RETRIES + 1; i++) { try { + console.log(`Starting ${test} retry ${i}/${NUM_RETRIES}`) const time = await runTest(test, i > 0) timings.push({ file: test, time, }) passed = true + console.log( + `Finished ${test} on retry ${i}/${NUM_RETRIES} in ${time / 1000}s` + ) break } catch (err) { if (i < NUM_RETRIES) { From 9b9170d6b8f4607d9fa68c540b5ac289a5c5cf58 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Thu, 29 Jul 2021 09:55:48 -0500 Subject: [PATCH 2/2] remove extra log --- run-tests.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run-tests.js b/run-tests.js index 765907b4dd91f..e45698eec1231 100644 --- a/run-tests.js +++ b/run-tests.js @@ -250,7 +250,7 @@ async function main() { // concurrent ones for (const test of nonConcurrentTestNames) { let passed = false - console.log(test) + for (let i = 0; i < NUM_RETRIES + 1; i++) { try { console.log(`Starting ${test} retry ${i}/${NUM_RETRIES}`)