Unverified Commit f5ee9ed5 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Only output test logs on failure in CI (#27604)

This updates to only output a test's logs when it fails to reduce the noise in the CI's logs to allow easier investigating a failure. This also updates azure to leverage the `run-tests` script when testing ie11 to allow retrying similar to our other tests. 
parent c63bfbe7
...@@ -72,6 +72,8 @@ stages: ...@@ -72,6 +72,8 @@ stages:
- job: test_ie11 - job: test_ie11
pool: pool:
vmImage: 'windows-2019' vmImage: 'windows-2019'
variables:
BROWSER_NAME: internet explorer
steps: steps:
- checkout: none - checkout: none
- task: NodeTool@0 - task: NodeTool@0
...@@ -86,7 +88,7 @@ stages: ...@@ -86,7 +88,7 @@ stages:
path: $(System.DefaultWorkingDirectory) path: $(System.DefaultWorkingDirectory)
displayName: Cache Build displayName: Cache Build
- script: | - 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' displayName: 'Run tests'
- job: test_unit - job: test_unit
......
...@@ -112,6 +112,7 @@ async function main() { ...@@ -112,6 +112,7 @@ async function main() {
} }
} catch (err) { } catch (err) {
console.log(`Failed to fetch timings data`, err) console.log(`Failed to fetch timings data`, err)
process.exit(1)
} }
} }
} }
...@@ -183,6 +184,7 @@ async function main() { ...@@ -183,6 +184,7 @@ async function main() {
const runTest = (test = '', usePolling) => const runTest = (test = '', usePolling) =>
new Promise((resolve, reject) => { new Promise((resolve, reject) => {
const start = new Date().getTime() const start = new Date().getTime()
let outputChunks = []
const child = spawn( const child = spawn(
'node', 'node',
[ [
...@@ -196,7 +198,7 @@ async function main() { ...@@ -196,7 +198,7 @@ async function main() {
test, test,
], ],
{ {
stdio: 'inherit', stdio: ['ignore', 'pipe', 'pipe'],
env: { env: {
JEST_RETRY_TIMES: 0, JEST_RETRY_TIMES: 0,
...process.env, ...process.env,
...@@ -217,10 +219,19 @@ async function main() { ...@@ -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) children.add(child)
child.on('exit', (code) => { child.on('exit', (code) => {
children.delete(child) 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) resolve(new Date().getTime() - start)
}) })
}) })
...@@ -242,12 +253,16 @@ async function main() { ...@@ -242,12 +253,16 @@ async function main() {
for (let i = 0; i < NUM_RETRIES + 1; i++) { for (let i = 0; i < NUM_RETRIES + 1; i++) {
try { try {
console.log(`Starting ${test} retry ${i}/${NUM_RETRIES}`)
const time = await runTest(test, i > 0) const time = await runTest(test, i > 0)
timings.push({ timings.push({
file: test, file: test,
time, time,
}) })
passed = true passed = true
console.log(
`Finished ${test} on retry ${i}/${NUM_RETRIES} in ${time / 1000}s`
)
break break
} catch (err) { } catch (err) {
if (i < NUM_RETRIES) { if (i < NUM_RETRIES) {
...@@ -287,12 +302,16 @@ async function main() { ...@@ -287,12 +302,16 @@ async function main() {
for (let i = 0; i < NUM_RETRIES + 1; i++) { for (let i = 0; i < NUM_RETRIES + 1; i++) {
try { try {
console.log(`Starting ${test} retry ${i}/${NUM_RETRIES}`)
const time = await runTest(test, i > 0) const time = await runTest(test, i > 0)
timings.push({ timings.push({
file: test, file: test,
time, time,
}) })
passed = true passed = true
console.log(
`Finished ${test} on retry ${i}/${NUM_RETRIES} in ${time / 1000}s`
)
break break
} catch (err) { } catch (err) {
if (i < NUM_RETRIES) { if (i < NUM_RETRIES) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment