Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only output test logs on failure in CI #27604

Merged
merged 2 commits into from
Jul 29, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ stages:
- job: test_ie11
pool:
vmImage: 'windows-2019'
variables:
BROWSER_NAME: internet explorer
steps:
- checkout: none
- task: NodeTool@0
Expand All @@ -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
Expand Down
25 changes: 22 additions & 3 deletions run-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ async function main() {
}
} catch (err) {
console.log(`Failed to fetch timings data`, err)
process.exit(1)
}
}
}
Expand Down Expand Up @@ -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',
[
Expand All @@ -196,7 +198,7 @@ async function main() {
test,
],
{
stdio: 'inherit',
stdio: ['ignore', 'pipe', 'pipe'],
env: {
JEST_RETRY_TIMES: 0,
...process.env,
Expand All @@ -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)
})
})
Expand All @@ -239,15 +250,19 @@ async function main() {
// concurrent ones
for (const test of nonConcurrentTestNames) {
let passed = false

console.log(test)
ijjk marked this conversation as resolved.
Show resolved Hide resolved
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) {
Expand Down Expand Up @@ -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) {
Expand Down