Skip to content

Commit

Permalink
tests for different languages now run sequentially
Browse files Browse the repository at this point in the history
  • Loading branch information
xpl committed Jul 30, 2017
1 parent 38539f1 commit fb3ded2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
18 changes: 13 additions & 5 deletions run-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ let numMarketsTested = 0

/* ------------------------------------------------------------------------ */

const sequentialMap = async (input, fn) => {

const result = []
for (const item of input) { result.push (await fn (item)) }
return result
}

/* ------------------------------------------------------------------------ */

const testMarket = async (market) => {

const nonce = Date.now ()
Expand All @@ -94,14 +103,13 @@ const testMarket = async (market) => {
const args = [market, ...symbol === 'all' ? [] : symbol]
, allTests = [

{ language: 'JavaScript', key: '--js', exec: ['node', 'test.js', '--nonce=' + (nonce + 1000), ...args, ...keys['--es6'] ? ['--es6'] : []] },
{ language: 'Python', key: '--python', exec: ['python', 'test.py', '--nonce=' + (nonce + 2000), ...args] },
{ language: 'PHP', key: '--php', exec: ['php', '-f', 'test.php', '--nonce=' + (nonce + 3000), ...args] }
{ language: 'JavaScript', key: '--js', exec: ['node', 'test.js', ...args, ...keys['--es6'] ? ['--es6'] : []] },
{ language: 'Python', key: '--python', exec: ['python', 'test.py', ...args] },
{ language: 'PHP', key: '--php', exec: ['php', '-f', 'test.php', ...args] }
]
, selectedTests = allTests.filter (t => keys[t.key])
, scheduledTests = selectedTests.length ? selectedTests : allTests
, completeTests = await Promise.all (scheduledTests.map (test => exec (...test.exec)
.then (result => Object.assign (test, result))))
, 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)

Expand Down
10 changes: 2 additions & 8 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,8 @@
/* ------------------------------------------------------------------------ */

const [processPath, , marketId = null, marketSymbol = null] = process.argv.filter (x => !x.startsWith ('--'))

const ccxtFile = process.argv.includes ('--es6') ? 'ccxt.js' : 'ccxt.es5.js'

const nonceRegex = /--nonce=(\d+)/
, nonceArg = process.argv.find (x => nonceRegex.test (x))

let nonce = nonceArg && Number (nonceArg.match (nonceRegex)[1])

/* ------------------------------------------------------------------------ */

const ccxt = require ('./' + ccxtFile)
Expand All @@ -35,7 +29,7 @@ process.on ('unhandledRejection', e => { log.bright.red.error (e); process.exit

/* ------------------------------------------------------------------------ */

log.bright ('\nTESTING', ccxtFile.magenta, { market: marketId || 'all', symbol: marketSymbol || 'all', nonce: nonce || 'default' }, '\n')
log.bright ('\nTESTING', ccxtFile.magenta, { market: marketId || 'all', symbol: marketSymbol || 'all' }, '\n')

/* ------------------------------------------------------------------------ */

Expand All @@ -49,7 +43,7 @@ let proxies = [

// instantiate all markets
ccxt.markets.forEach (id => {
markets[id] = new (ccxt)[id] (Object.assign ({ verbose: true }, nonce ? { nonce: () => nonce++ } : {}))
markets[id] = new (ccxt)[id] ({ verbose: true })
})

// load api keys from config
Expand Down

0 comments on commit fb3ded2

Please sign in to comment.