diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2017-09-12 07:56:07 -0400 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2017-09-12 20:36:17 +0300 |
commit | bed96c800cac49a14957954d9ae8e71ec2c46b9a (patch) | |
tree | 904b4fb71689fcfb9e69e7a642e633a63785c52b /platform | |
parent | 161c5ed4f5a4ab617d26330691a43b7727d41d59 (diff) | |
download | qtlocation-mapboxgl-bed96c800cac49a14957954d9ae8e71ec2c46b9a.tar.gz |
[node] Shuffle seed support
Diffstat (limited to 'platform')
-rw-r--r-- | platform/node/test/render.test.js | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/platform/node/test/render.test.js b/platform/node/test/render.test.js index ce549c1e27..b4933ce59e 100644 --- a/platform/node/test/render.test.js +++ b/platform/node/test/render.test.js @@ -7,6 +7,19 @@ const ignores = require('./ignores.json'); let tests; let shuffle = false; let recycleMap = false; +let seed; + +// https://stackoverflow.com/a/1349426/229714 +function makeHash() { + const array = []; + const possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + + for (let i = 0; i < 10; ++i) + array.push(possible.charAt(Math.floor(Math.random() * possible.length))); + + // join array elements without commas. + return array.join(''); +} function checkParameter(param) { const index = tests.indexOf(param); @@ -16,10 +29,23 @@ function checkParameter(param) { return true; } +function checkValueParameter(defaultValue, param) { + const index = tests.findIndex((elem) => { return String(elem).startsWith(param); }); + if (index === -1) + return defaultValue; + + const split = String(tests.splice(index, 1)).split('='); + if (split.length !== 2) + return defaultValue; + + return split[1]; +} + if (process.argv[1] === __filename && process.argv.length > 2) { tests = process.argv.slice(2).filter((value, index, self) => { return self.indexOf(value) === index; }); shuffle = checkParameter('--shuffle'); + seed = checkValueParameter(makeHash(), '--seed'); recycleMap = checkParameter('--recycle-map'); } -suite.run('native', {tests, ignores, shuffle, recycleMap}, suiteImplementation); +suite.run('native', { tests, ignores, shuffle, seed, recycleMap }, suiteImplementation); |