| 1 | let assert = require('assert');
|
|---|
| 2 | let exec = require('child_process').execSync;
|
|---|
| 3 |
|
|---|
| 4 | const PROJECT_DIR = process.env.PROJECT_DIR;
|
|---|
| 5 | const JAKE_CMD = `${PROJECT_DIR}/bin/cli.js`;
|
|---|
| 6 |
|
|---|
| 7 | suite('concurrent', function () {
|
|---|
| 8 |
|
|---|
| 9 | this.timeout(7000);
|
|---|
| 10 |
|
|---|
| 11 | test(' simple concurrent prerequisites 1', function () {
|
|---|
| 12 | let out = exec(`${JAKE_CMD} -q concurrent:simple1`).toString().trim();
|
|---|
| 13 | assert.equal('Started A\nStarted B\nFinished B\nFinished A', out);
|
|---|
| 14 | });
|
|---|
| 15 |
|
|---|
| 16 | test(' simple concurrent prerequisites 2', function () {
|
|---|
| 17 | let out = exec(`${JAKE_CMD} -q concurrent:simple2`).toString().trim();
|
|---|
| 18 | assert.equal('Started C\nStarted D\nFinished C\nFinished D', out);
|
|---|
| 19 | });
|
|---|
| 20 |
|
|---|
| 21 | test(' sequential concurrent prerequisites', function () {
|
|---|
| 22 | let out = exec(`${JAKE_CMD} -q concurrent:seqconcurrent`).toString().trim();
|
|---|
| 23 | assert.equal('Started A\nStarted B\nFinished B\nFinished A\nStarted C\nStarted D\nFinished C\nFinished D', out);
|
|---|
| 24 | });
|
|---|
| 25 |
|
|---|
| 26 | test(' concurrent concurrent prerequisites', function () {
|
|---|
| 27 | let out = exec(`${JAKE_CMD} -q concurrent:concurrentconcurrent`).toString().trim();
|
|---|
| 28 | assert.equal('Started A\nStarted B\nStarted C\nStarted D\nFinished B\nFinished C\nFinished A\nFinished D', out);
|
|---|
| 29 | });
|
|---|
| 30 |
|
|---|
| 31 | test(' concurrent prerequisites with subdependency', function () {
|
|---|
| 32 | let out = exec(`${JAKE_CMD} -q concurrent:subdep`).toString().trim();
|
|---|
| 33 | assert.equal('Started A\nFinished A\nStarted Ba\nFinished Ba', out);
|
|---|
| 34 | });
|
|---|
| 35 |
|
|---|
| 36 | test(' failing in concurrent prerequisites', function () {
|
|---|
| 37 | try {
|
|---|
| 38 | exec(`${JAKE_CMD} -q concurrent:Cfail`);
|
|---|
| 39 | }
|
|---|
| 40 | catch(err) {
|
|---|
| 41 | assert(err.message.indexOf('Command failed') > -1);
|
|---|
| 42 | }
|
|---|
| 43 | });
|
|---|
| 44 |
|
|---|
| 45 | });
|
|---|