Skip to content

Commit

Permalink
run-tests now shows warnings info in interactive output
Browse files Browse the repository at this point in the history
  • Loading branch information
xpl committed Jul 30, 2017
1 parent 16d7063 commit 82c311c
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions run-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,20 @@ const exec = (bin, ...args) =>
const ps = require ('child_process').spawn (bin, args)

let output = ''
let stderr = ''
let hasWarnings = false

ps.stdout.on ('data', data => { output += data.toString () })
ps.stderr.on ('data', data => { output += data.toString (); hasWarnings = true })

ps.on ('exit', code => { return_ ({ failed: code !== 0, output, hasWarnings }) })
ps.stderr.on ('data', data => { output += data.toString (); stderr += data.toString (); hasWarnings = true })

ps.on ('exit', code => {
return_ ({
failed: code !== 0,
output,
hasWarnings,
warnings: ansi.strip (stderr).match (/\[[^\]]+Error\]/g) || []
})
})
})

/* ------------------------------------------------------------------------ */
Expand Down Expand Up @@ -112,6 +120,7 @@ const testMarket = async (market) => {
, completeTests = await sequentialMap (scheduledTests, async test => Object.assign (test, await exec (...test.exec)))
, failed = completeTests.find (test => test.failed)
, hasWarnings = completeTests.find (test => test.hasWarnings)
, warnings = completeTests.reduce ((total, { warnings }) => total.concat (warnings), [])

/* Print interactive log output */

Expand All @@ -120,7 +129,7 @@ const testMarket = async (market) => {
const percentsDone = ((numMarketsTested / markets.length) * 100).toFixed (0) + '%'

log.bright (('[' + percentsDone + ']').dim, 'Testing', market.cyan, (failed ? 'FAIL'.red :
(hasWarnings ? 'WARN'.yellow
(hasWarnings ? (warnings.length ? warnings.join (' ') : 'WARN').yellow
: 'OK'.green)))

/* Return collected data to main loop */
Expand Down

0 comments on commit 82c311c

Please sign in to comment.