Skip to content

Commit 081a536

Browse files
committed
Update test script, hopefully fixing tests on Travis.
This patch introduces a serial way of running AVA whilst concurrency issues are being ironed out. It also adds the 'test-fast' command which is preferable on the local machine as it is maximally concurrent. Fixes #44.
1 parent 628bd4a commit 081a536

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

batchTests.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env node
2+
3+
var glob = require('glob');
4+
var spawn = require('child_process').spawn;
5+
var files = require('minimist')(process.argv.slice(2))._[0];
6+
7+
function spawnAva (file) {
8+
return new Promise(function (resolve, reject) {
9+
var ps = spawn(process.execPath, ['node_modules/.bin/ava', file]);
10+
11+
ps.stdout.pipe(process.stdout);
12+
ps.stderr.pipe(process.stderr);
13+
14+
ps.on('close', function (code) {
15+
if (code === 0) {
16+
return resolve(code);
17+
}
18+
return reject(code);
19+
});
20+
});
21+
}
22+
23+
glob(files, function (err, tests) {
24+
if (err) {
25+
throw err;
26+
}
27+
return tests.reduce(function (promise, file) {
28+
return promise.then(function () { return spawnAva(file); });
29+
}, Promise.resolve());
30+
});

package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "postcss-selector-parser",
33
"version": "1.3.3",
44
"devDependencies": {
5-
"ava": "git+https://[email protected]/sindresorhus/ava.git#sigabrt",
5+
"ava": "^0.13.0",
66
"babel-cli": "^6.4.0",
77
"babel-core": "^6.4.0",
88
"babel-plugin-add-module-exports": "^0.1.2",
@@ -14,6 +14,8 @@
1414
"del-cli": "^0.2.0",
1515
"eslint": "^2.1.0",
1616
"eslint-config-cssnano": "^2.0.0",
17+
"glob": "^7.0.3",
18+
"minimist": "^1.2.0",
1719
"nyc": "^6.0.0"
1820
},
1921
"main": "dist/index.js",
@@ -27,7 +29,8 @@
2729
"pretest": "eslint src",
2830
"prepublish": "del-cli dist && BABEL_ENV=publish babel src --out-dir dist --ignore /__tests__/",
2931
"report": "nyc report --reporter=html",
30-
"test": "nyc ava --verbose src/__tests__/*.js"
32+
"test": "nyc node batchTests.js 'src/__tests__/*.js'",
33+
"test-fast": "nyc ava src/__tests__/*.js"
3134
},
3235
"dependencies": {
3336
"flatten": "^1.0.2",

0 commit comments

Comments
 (0)