summaryrefslogtreecommitdiff
path: root/node_modules/jake/test/integration/task_base.js
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2022-01-21 14:39:46 +0100
committerMinteck <contact@minteck.org>2022-01-21 14:39:46 +0100
commit3a04cb197f152f171fba679663a91a9bb61d710e (patch)
tree825d8f9b0daab3e434d85704144ca87492da9b92 /node_modules/jake/test/integration/task_base.js
parentc2aa7bf38fb30de2d04f87f8e7780e4c768ae6b1 (diff)
downloadcobalt-3a04cb197f152f171fba679663a91a9bb61d710e.tar.gz
cobalt-3a04cb197f152f171fba679663a91a9bb61d710e.tar.bz2
cobalt-3a04cb197f152f171fba679663a91a9bb61d710e.zip
Add config management
Diffstat (limited to 'node_modules/jake/test/integration/task_base.js')
-rw-r--r--node_modules/jake/test/integration/task_base.js164
1 files changed, 164 insertions, 0 deletions
diff --git a/node_modules/jake/test/integration/task_base.js b/node_modules/jake/test/integration/task_base.js
new file mode 100644
index 0000000..36e20e8
--- /dev/null
+++ b/node_modules/jake/test/integration/task_base.js
@@ -0,0 +1,164 @@
+let assert = require('assert');
+let h = require('./helpers');
+let exec = require('child_process').execSync;
+
+suite('taskBase', function () {
+
+ this.timeout(7000);
+
+ test('default task', function () {
+ let out;
+ out = exec('./node_modules/.bin/jake -q').toString().trim();
+ assert.equal(out, 'default task');
+ out = exec('./node_modules/.bin/jake -q default').toString().trim();
+ assert.equal(out, 'default task');
+ });
+
+ test('task with no action', function () {
+ let out = exec('./node_modules/.bin/jake -q noAction').toString().trim();
+ assert.equal(out, 'default task');
+ });
+
+ test('a task with no action and no prereqs', function () {
+ exec('./node_modules/.bin/jake noActionNoPrereqs');
+ });
+
+ test('a task that exists at the top-level, and not in the specified namespace, should error', function () {
+ let res = require('child_process').spawnSync('./node_modules/.bin/jake',
+ ['asdfasdfasdf:zerbofrangazoomy']);
+ let err = res.stderr.toString();
+ assert.ok(err.indexOf('Unknown task' > -1));
+ });
+
+ test('passing args to a task', function () {
+ let out = exec('./node_modules/.bin/jake -q argsEnvVars[foo,bar]').toString().trim();
+ let parsed = h.parse(out);
+ let args = parsed.args;
+ assert.equal(args[0], 'foo');
+ assert.equal(args[1], 'bar');
+ });
+
+ test('a task with environment vars', function () {
+ let out = exec('./node_modules/.bin/jake -q argsEnvVars foo=bar baz=qux').toString().trim();
+ let parsed = h.parse(out);
+ let env = parsed.env;
+ assert.equal(env.foo, 'bar');
+ assert.equal(env.baz, 'qux');
+ });
+
+ test('passing args and using environment vars', function () {
+ let out = exec('./node_modules/.bin/jake -q argsEnvVars[foo,bar] foo=bar baz=qux').toString().trim();
+ let parsed = h.parse(out);
+ let args = parsed.args;
+ let env = parsed.env;
+ assert.equal(args[0], 'foo');
+ assert.equal(args[1], 'bar');
+ assert.equal(env.foo, 'bar');
+ assert.equal(env.baz, 'qux');
+ });
+
+ test('a simple prereq', function () {
+ let out = exec('./node_modules/.bin/jake -q foo:baz').toString().trim();
+ assert.equal(out, 'foo:bar task\nfoo:baz task');
+ });
+
+ test('a duplicate prereq only runs once', function () {
+ let out = exec('./node_modules/.bin/jake -q foo:asdf').toString().trim();
+ assert.equal(out, 'foo:bar task\nfoo:baz task\nfoo:asdf task');
+ });
+
+ test('a prereq with command-line args', function () {
+ let out = exec('./node_modules/.bin/jake -q foo:qux').toString().trim();
+ assert.equal(out, 'foo:bar[asdf,qwer] task\nfoo:qux task');
+ });
+
+ test('a prereq with args via invoke', function () {
+ let out = exec('./node_modules/.bin/jake -q foo:frang[zxcv,uiop]').toString().trim();
+ assert.equal(out, 'foo:bar[zxcv,uiop] task\nfoo:frang task');
+ });
+
+ test('a prereq with args via execute', function () {
+ let out = exec('./node_modules/.bin/jake -q foo:zerb[zxcv,uiop]').toString().trim();
+ assert.equal(out, 'foo:bar[zxcv,uiop] task\nfoo:zerb task');
+ });
+
+ test('repeating the task via execute', function () {
+ let out = exec('./node_modules/.bin/jake -q foo:voom').toString().trim();
+ assert.equal(out, 'foo:bar task\nfoo:bar task\ncomplete\ncomplete');
+ });
+
+ test('prereq execution-order', function () {
+ let out = exec('./node_modules/.bin/jake -q hoge:fuga').toString().trim();
+ assert.equal(out, 'hoge:hoge task\nhoge:piyo task\nhoge:fuga task');
+ });
+
+ test('basic async task', function () {
+ let out = exec('./node_modules/.bin/jake -q bar:bar').toString().trim();
+ assert.equal(out, 'bar:foo task\nbar:bar task');
+ });
+
+ test('promise async task', function () {
+ let out = exec('./node_modules/.bin/jake -q bar:dependOnpromise').toString().trim();
+ assert.equal(out, 'bar:promise task\nbar:dependOnpromise task saw value 123654');
+ });
+
+ test('failing promise async task', function () {
+ try {
+ exec('./node_modules/.bin/jake -q bar:brokenPromise');
+ }
+ catch(e) {
+ assert(e.message.indexOf('Command failed') > -1);
+ }
+ });
+
+ test('that current-prereq index gets reset', function () {
+ let out = exec('./node_modules/.bin/jake -q hoge:kira').toString().trim();
+ assert.equal(out, 'hoge:hoge task\nhoge:piyo task\nhoge:fuga task\n' +
+ 'hoge:charan task\nhoge:gero task\nhoge:kira task');
+ });
+
+ test('modifying a task by adding prereq during execution', function () {
+ let out = exec('./node_modules/.bin/jake -q voom').toString().trim();
+ assert.equal(out, 2);
+ });
+
+ test('listening for task error-event', function () {
+ try {
+ exec('./node_modules/.bin/jake -q vronk:groo').toString().trim();
+ }
+ catch(e) {
+ assert(e.message.indexOf('OMFGZONG') > -1);
+ }
+ });
+
+ test('listening for jake error-event', function () {
+ let out = exec('./node_modules/.bin/jake -q throwy').toString().trim();
+ assert(out.indexOf('Emitted\nError: I am bad') > -1);
+ });
+
+ test('listening for jake unhandledRejection-event', function () {
+ let out = exec('./node_modules/.bin/jake -q promiseRejecter').toString().trim();
+ assert.equal(out, '<promise rejected on purpose>');
+ });
+
+ test('large number of same prereqs', function () {
+ let out = exec('./node_modules/.bin/jake -q large:same').toString().trim();
+ assert.equal(out, 'large:leaf\nlarge:same');
+ });
+
+ test('large number of different prereqs', function () {
+ let out = exec('./node_modules/.bin/jake -q large:different').toString().trim();
+ assert.equal(out, 'leaf-12\nleaf-123\nlarge:different');
+ });
+
+ test('large number of different prereqs', function () {
+ let out = exec('./node_modules/.bin/jake -q usingRequire:test').toString().trim();
+ assert.equal(out, 'howdy test');
+ });
+
+ test('modifying a namespace by adding a new task', function () {
+ let out = exec('./node_modules/.bin/jake -q one:two').toString().trim();
+ assert.equal('one:one\none:two', out);
+ });
+
+});