Template Upload
This commit is contained in:
83
node_modules/concurrently/test/test-functional.js
generated
vendored
Normal file
83
node_modules/concurrently/test/test-functional.js
generated
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
// Test basic usage of cli
|
||||
|
||||
var path = require('path');
|
||||
var assert = require('assert');
|
||||
var run = require('./utils').run;
|
||||
|
||||
// If true, output of commands are shown
|
||||
var DEBUG_TESTS = false;
|
||||
var TEST_DIR = 'dir/';
|
||||
|
||||
// Abs path to test directory
|
||||
var testDir = path.resolve(__dirname);
|
||||
process.chdir(path.join(testDir, '..'));
|
||||
|
||||
describe('concurrently', function() {
|
||||
this.timeout(5000);
|
||||
|
||||
it('help should be successful', function(done) {
|
||||
run('node ./src/main.js --help', {pipe: DEBUG_TESTS})
|
||||
.then(function(exitCode) {
|
||||
// exit code 0 means success
|
||||
assert.strictEqual(exitCode, 0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('version should be successful', function(done) {
|
||||
run('node ./src/main.js -V', {pipe: DEBUG_TESTS})
|
||||
.then(function(exitCode) {
|
||||
assert.strictEqual(exitCode, 0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('two successful commands should exit 0', function(done) {
|
||||
run('node ./src/main.js "echo" "echo"', {pipe: DEBUG_TESTS})
|
||||
.then(function(exitCode) {
|
||||
assert.strictEqual(exitCode, 0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('at least one unsuccessful commands should exit non-zero', function(done) {
|
||||
run('node ./src/main.js "echo" "return 1" "echo"', {pipe: DEBUG_TESTS})
|
||||
.then(function(exitCode) {
|
||||
assert.notStrictEqual(exitCode, 0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('--kill-others should kill other commands if one dies', function(done) {
|
||||
// This test would timeout if kill others option does not work
|
||||
run('node ./src/main.js --kill-others "sleep 1000" "echo" "sleep 1000"', {pipe: DEBUG_TESTS})
|
||||
.then(function(exitCode) {
|
||||
assert.notStrictEqual(exitCode, 0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('--success=first should return first exit code', function(done) {
|
||||
run('node ./src/main.js -k --success first "echo" "sleep 1000" ', {pipe: DEBUG_TESTS})
|
||||
// When killed, sleep returns null exit code
|
||||
.then(function(exitCode) {
|
||||
assert.strictEqual(exitCode, 0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('--success=last should return last exit code', function(done) {
|
||||
// When killed, sleep returns null exit code
|
||||
run('node ./src/main.js -k --success last "echo" "sleep 1000" ', {pipe: DEBUG_TESTS})
|
||||
.then(function(exitCode) {
|
||||
assert.notStrictEqual(exitCode, 0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function resolve(relativePath) {
|
||||
return path.join(testDir, relativePath);
|
||||
}
|
||||
|
44
node_modules/concurrently/test/utils.js
generated
vendored
Normal file
44
node_modules/concurrently/test/utils.js
generated
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
var childProcess = require('child_process');
|
||||
var _ = require('lodash');
|
||||
var Promise = require('bluebird');
|
||||
var shellQuote = require('shell-quote');
|
||||
|
||||
function run(cmd, opts) {
|
||||
opts = _.merge({
|
||||
pipe: true,
|
||||
cwd: undefined,
|
||||
callback: function(child) {
|
||||
// Since we return promise, we need to provide
|
||||
// this callback if one wants to access the child
|
||||
// process reference
|
||||
// Called immediately after successful child process
|
||||
// spawn
|
||||
}
|
||||
}, opts);
|
||||
|
||||
var child;
|
||||
var parts = shellQuote.parse(cmd);
|
||||
try {
|
||||
child = childProcess.spawn(_.head(parts), _.tail(parts), {
|
||||
cwd: opts.cwd,
|
||||
stdio: opts.pipe ? "inherit" : null
|
||||
});
|
||||
} catch (e) {
|
||||
return Promise.reject(e);
|
||||
}
|
||||
opts.callback(child);
|
||||
|
||||
return new Promise(function(resolve, reject) {
|
||||
child.on('error', function(err) {
|
||||
reject(err);
|
||||
});
|
||||
|
||||
child.on('close', function(exitCode) {
|
||||
resolve(exitCode);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
run: run
|
||||
};
|
Reference in New Issue
Block a user