From fb3ded2ee0dfe49375bc9db28a2a3d78e23c836d Mon Sep 17 00:00:00 2001 From: xpl Date: Sun, 30 Jul 2017 11:42:47 +0300 Subject: [PATCH] tests for different languages now run sequentially --- run-tests.js | 18 +++++++++++++----- test.js | 10 ++-------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/run-tests.js b/run-tests.js index 84a13d0f5025..3334d6805281 100644 --- a/run-tests.js +++ b/run-tests.js @@ -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 () @@ -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) diff --git a/test.js b/test.js index 903c49a9de51..6ce819c14038 100644 --- a/test.js +++ b/test.js @@ -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) @@ -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') /* ------------------------------------------------------------------------ */ @@ -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