summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Núñez <pablonete@gmail.com>2019-04-08 00:25:07 +0200
committerAlex Early <alexander.early@gmail.com>2019-04-07 15:25:07 -0700
commit4330d536c106592139fa82062494c9dba0da1fdb (patch)
tree6c1120c134349b1375d7bb33ce558fae909e18ec
parenta4c00358cf3c638398735f4006b65e3a82d80ca9 (diff)
downloadasync-4330d536c106592139fa82062494c9dba0da1fdb.tar.gz
chore: Add Azure Pipelines for CI (Windows, Linux, Mac) (#1630), Fix async function serialization in Safari.
* Add azure pipelines CI. * Publish test results. * Enable coveralls * Use Safari for OSX browser tests. * Adding missing lib files to karma (only Safari complained). * Rename with dot so it gets better placed in order. * Use ci instead of install, so we stick with package-lock.json * Use npm test instead of mocha directly. It just needed a double -- escape. * Move DISPLAY to Linux only, with value set just once. * Use variables for DISPLAY, browser tests and coveralls. * Simplify steps with a browser name variable. * Run junit reporter on CI only. * DISPLAY should be already an environment variable. * Use vmImage for consistency with other OS. * Don't use verbose npm@1 task. * No need to setTimeout, let's `done` on the callback. * Don't resume twice. Check queue length on callback for safety, setTimeout may be delayed. * Avoid time dependency, act on events instead. * Avoid dependency on timing to final assertion. * Rewrite test to avoid setTimeout * Fix formatting. * Make diff more significant (125+50 ~= 200) * Make diff more significant to avoid race conditions. * Wait a bit more so default 5 retries did happen. * Make delays shorter to avoid "Timeout of 250ms exceeded" * Shorten delay to avoid 200ms test timeout in browser tests. * Shorten timeout to mitigate 200ms test timeout. * Add more diff on delays to enforce test behavior. * Make delays more significant to avoid race conditions. * Stop using setTimeout and rely on events to push new items, so order is enforced. * Fix async function serialization in Safari. * Add more delay so 4 never completes before 3. * Ensure 3 never completes before 4. * Use drain instead of task count. Trying to ensure done is called from Windows browser tests that fail frequently. * Ensure 2 starts before 3 arrives.Avoid expected 'process 2 3' to equal 'process 2' * Add retries to browser tests. * Don't fail all on Mac & Windows browser tests. * Ensure 3 happens before 2, it fails sparely on OSX. AssertionError: expected [ 1, 2, 3 ] to deeply equal [ 1, 3, 2 ] * Avoid unnecessary multilines. * Use Edge for Windows browser tests.
-rw-r--r--.azure-pipelines-steps.yml43
-rw-r--r--.azure-pipelines.yml73
-rw-r--r--.gitignore3
-rw-r--r--karma.conf.js11
-rw-r--r--lib/autoInject.js2
-rw-r--r--package-lock.json107
-rw-r--r--package.json4
-rw-r--r--test/cargo.js23
-rw-r--r--test/cargoQueue.js64
-rw-r--r--test/concat.js2
-rw-r--r--test/detect.js10
-rw-r--r--test/es2017/asyncFunctions.js8
-rw-r--r--test/es2017/asyncGenerators.js4
-rw-r--r--test/parallel.js6
-rw-r--r--test/priorityQueue.js4
-rw-r--r--test/queue.js20
-rw-r--r--test/retry.js2
-rw-r--r--test/support/get_function_object.js2
-rw-r--r--test/timeout.js10
19 files changed, 315 insertions, 83 deletions
diff --git a/.azure-pipelines-steps.yml b/.azure-pipelines-steps.yml
new file mode 100644
index 0000000..2580054
--- /dev/null
+++ b/.azure-pipelines-steps.yml
@@ -0,0 +1,43 @@
+# Build steps common to all platforms
+
+steps:
+- task: NodeTool@0
+ inputs:
+ versionSpec: $(node_version)
+ displayName: 'Install Node.js'
+
+- task: Npm@1
+ inputs:
+ command: custom
+ customCommand: install -g npm
+ displayName: 'Update npm'
+ condition: eq(variables['node_version'], '6.x')
+
+- script: npm ci
+ displayName: 'Install dependencies'
+
+- bash: npm test -- -- --reporter mocha-junit-reporter --reporter-options mochaFile=./test-results.xml
+ displayName: 'Run tests'
+
+- task: PublishTestResults@2
+ inputs:
+ testResultsFiles: '**/test-results.xml'
+ testRunTitle: $(os_name) Node $(node_version)
+ displayName: 'Publishing the test results'
+ condition: always()
+
+- bash: npm run mocha-browser-test -- --browsers $(browser_name) --reporters junit
+ displayName: 'Run browser tests'
+ condition: variables.run_browser_tests
+ continueOnError: true
+
+- task: PublishTestResults@2
+ inputs:
+ testResultsFiles: '**/browser-test-results.xml'
+ testRunTitle: $(os_name) Node $(node_version) Browser tests
+ displayName: 'Publishing the browser test results'
+ condition: variables.run_browser_tests
+
+- bash: npm run coveralls
+ displayName: 'Run coveralls'
+ condition: variables.run_coveralls
diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
new file mode 100644
index 0000000..88eaa9f
--- /dev/null
+++ b/.azure-pipelines.yml
@@ -0,0 +1,73 @@
+jobs:
+
+- job: Windows
+ pool:
+ vmImage: vs2017-win2016
+
+ variables:
+ os_name: Windows
+
+ strategy:
+ matrix:
+ node_6_x:
+ node_version: 6.x
+ node_8_x:
+ node_version: 8.x
+ node_10_x:
+ node_version: 10.x
+ run_browser_tests: true
+ browser_name: Edge
+ run_coveralls: true
+
+ steps:
+ - template: .azure-pipelines-steps.yml
+
+- job: Linux
+ pool:
+ vmImage: 'Ubuntu 16.04'
+
+ variables:
+ os_name: Linux
+
+ strategy:
+ matrix:
+ node_6_x:
+ node_version: 6.x
+ node_8_x:
+ node_version: 8.x
+ node_10_x:
+ node_version: 10.x
+ DISPLAY: :99.0
+ run_browser_tests: true
+ browser_name: Firefox
+ run_coveralls: true
+
+ steps:
+ - script: |
+ /usr/bin/Xvfb $(DISPLAY) -ac >> /tmp/xvfb.out 2>&1 &
+ disown -ar
+ displayName: 'Start xvfb'
+ condition: variables.run_browser_tests
+
+ - template: .azure-pipelines-steps.yml
+
+- job: OSX
+ pool:
+ vmImage: 'macOS 10.13'
+
+ variables:
+ os_name: OSX
+
+ strategy:
+ matrix:
+ node_6_x:
+ node_version: 6.x
+ node_8_x:
+ node_version: 8.x
+ node_10_x:
+ node_version: 10.x
+ run_browser_tests: true
+ browser_name: Safari
+
+ steps:
+ - template: .azure-pipelines-steps.yml
diff --git a/.gitignore b/.gitignore
index 6faca0f..024ca36 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,4 +10,5 @@ tmp
build
build-es
.idea
-docs \ No newline at end of file
+docs
+*test-results.xml \ No newline at end of file
diff --git a/karma.conf.js b/karma.conf.js
index 20f85d3..809a634 100644
--- a/karma.conf.js
+++ b/karma.conf.js
@@ -7,12 +7,19 @@ module.exports = function(config) {
'karma-browserify',
'karma-mocha',
'karma-mocha-reporter',
- 'karma-firefox-launcher'
+ 'karma-junit-reporter',
+ 'karma-edge-launcher',
+ 'karma-firefox-launcher',
+ 'karma-safari-launcher'
],
preprocessors: {
- 'test/*.js': ['browserify']
+ 'test/*.js': ['browserify'],
+ 'lib/*.js': ['browserify']
},
reporters: ['mocha'],
+ junitReporter: {
+ outputFile: 'browser-test-results.xml'
+ },
singleRun: true,
browserify: {
diff --git a/lib/autoInject.js b/lib/autoInject.js
index 996fceb..03f534e 100644
--- a/lib/autoInject.js
+++ b/lib/autoInject.js
@@ -3,7 +3,7 @@ import wrapAsync from './internal/wrapAsync';
import { isAsync } from './internal/wrapAsync';
var FN_ARGS = /^(?:async\s+)?(?:function)?\s*[^(]*\(\s*([^)]+)\s*\)(?:\s*{)/m;
-var ARROW_FN_ARGS = /^(?:async\s+)?\(?\s*([^)^=]+)\s*\)?(?:\s*=>)/m;
+var ARROW_FN_ARGS = /^(?:async\s+)?(?:function\s+)?\(?\s*([^)^=]+)\s*\)?(?:\s*=>)/m;
var FN_ARG_SPLIT = /,/;
var FN_ARG = /(=.+)?(\s*)$/;
var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
diff --git a/package-lock.json b/package-lock.json
index 531ad37..a3ded18 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "async",
- "version": "3.0.0",
+ "version": "3.0.1-0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -3133,6 +3133,12 @@
"integrity": "sha1-tUc7M9yXxCTl2Y3IfVXU2KKci/I=",
"dev": true
},
+ "charenc": {
+ "version": "0.0.2",
+ "resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz",
+ "integrity": "sha1-wKHS86cJLgN3S/qD8UwPxXkKhmc=",
+ "dev": true
+ },
"check-error": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz",
@@ -3733,6 +3739,12 @@
}
}
},
+ "crypt": {
+ "version": "0.0.2",
+ "resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz",
+ "integrity": "sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs=",
+ "dev": true
+ },
"cryptiles": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-3.1.2.tgz",
@@ -4111,6 +4123,12 @@
"jsbn": "~0.1.0"
}
},
+ "edge-launcher": {
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/edge-launcher/-/edge-launcher-1.2.2.tgz",
+ "integrity": "sha1-60Cq+9Bnpup27/+rBke81VCbN7I=",
+ "dev": true
+ },
"ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
@@ -6835,12 +6853,31 @@
"os-shim": "^0.1.3"
}
},
+ "karma-edge-launcher": {
+ "version": "0.4.2",
+ "resolved": "https://registry.npmjs.org/karma-edge-launcher/-/karma-edge-launcher-0.4.2.tgz",
+ "integrity": "sha512-YAJZb1fmRcxNhMIWYsjLuxwODBjh2cSHgTW/jkVmdpGguJjLbs9ZgIK/tEJsMQcBLUkO+yO4LBbqYxqgGW2HIw==",
+ "dev": true,
+ "requires": {
+ "edge-launcher": "1.2.2"
+ }
+ },
"karma-firefox-launcher": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/karma-firefox-launcher/-/karma-firefox-launcher-1.1.0.tgz",
"integrity": "sha512-LbZ5/XlIXLeQ3cqnCbYLn+rOVhuMIK9aZwlP6eOLGzWdo1UVp7t6CN3DP4SafiRLjexKwHeKHDm0c38Mtd3VxA==",
"dev": true
},
+ "karma-junit-reporter": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/karma-junit-reporter/-/karma-junit-reporter-1.2.0.tgz",
+ "integrity": "sha1-T5xAzt+xo5X4rvh2q/lhiZF8Y5Y=",
+ "dev": true,
+ "requires": {
+ "path-is-absolute": "^1.0.0",
+ "xmlbuilder": "8.2.2"
+ }
+ },
"karma-mocha": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/karma-mocha/-/karma-mocha-1.3.0.tgz",
@@ -6915,6 +6952,12 @@
}
}
},
+ "karma-safari-launcher": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/karma-safari-launcher/-/karma-safari-launcher-1.0.0.tgz",
+ "integrity": "sha1-lpgqLMR9BmquccVTursoMZEVos4=",
+ "dev": true
+ },
"kind-of": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz",
@@ -7390,6 +7433,17 @@
"integrity": "sha1-izqsWIuKZuSXXjzepn97sylgH6w=",
"dev": true
},
+ "md5": {
+ "version": "2.2.1",
+ "resolved": "https://registry.npmjs.org/md5/-/md5-2.2.1.tgz",
+ "integrity": "sha1-U6s41f48iJG6RlMp6iP6wFQBJvk=",
+ "dev": true,
+ "requires": {
+ "charenc": "~0.0.1",
+ "crypt": "~0.0.1",
+ "is-buffer": "~1.1.1"
+ }
+ },
"md5.js": {
"version": "1.3.4",
"resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.4.tgz",
@@ -7598,6 +7652,45 @@
}
}
},
+ "mocha-junit-reporter": {
+ "version": "1.18.0",
+ "resolved": "https://registry.npmjs.org/mocha-junit-reporter/-/mocha-junit-reporter-1.18.0.tgz",
+ "integrity": "sha512-y3XuqKa2+HRYtg0wYyhW/XsLm2Ps+pqf9HaTAt7+MVUAKFJaNAHOrNseTZo9KCxjfIbxUWwckP5qCDDPUmjSWA==",
+ "dev": true,
+ "requires": {
+ "debug": "^2.2.0",
+ "md5": "^2.1.0",
+ "mkdirp": "~0.5.1",
+ "strip-ansi": "^4.0.0",
+ "xml": "^1.0.0"
+ },
+ "dependencies": {
+ "ansi-regex": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz",
+ "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=",
+ "dev": true
+ },
+ "debug": {
+ "version": "2.6.9",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
+ "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
+ "dev": true,
+ "requires": {
+ "ms": "2.0.0"
+ }
+ },
+ "strip-ansi": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz",
+ "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=",
+ "dev": true,
+ "requires": {
+ "ansi-regex": "^3.0.0"
+ }
+ }
+ }
+ },
"module-deps": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/module-deps/-/module-deps-6.1.0.tgz",
@@ -12947,6 +13040,18 @@
"ultron": "~1.1.0"
}
},
+ "xml": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/xml/-/xml-1.0.1.tgz",
+ "integrity": "sha1-eLpyAgApxbyHuKgaPPzXS0ovweU=",
+ "dev": true
+ },
+ "xmlbuilder": {
+ "version": "8.2.2",
+ "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-8.2.2.tgz",
+ "integrity": "sha1-aSSGc0ELS6QuGmE2VR0pIjNap3M=",
+ "dev": true
+ },
"xmlcreate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/xmlcreate/-/xmlcreate-1.0.2.tgz",
diff --git a/package.json b/package.json
index d72c7b9..1b5ced1 100644
--- a/package.json
+++ b/package.json
@@ -45,10 +45,14 @@
"jsdoc": "^3.4.0",
"karma": "^2.0.5",
"karma-browserify": "^5.3.0",
+ "karma-edge-launcher": "^0.4.2",
"karma-firefox-launcher": "^1.1.0",
+ "karma-junit-reporter": "^1.2.0",
"karma-mocha": "^1.2.0",
"karma-mocha-reporter": "^2.2.0",
+ "karma-safari-launcher": "^1.0.0",
"mocha": "^5.2.0",
+ "mocha-junit-reporter": "^1.18.0",
"native-promise-only": "^0.8.0-a",
"nyc": "^11.8.0",
"rimraf": "^2.5.0",
diff --git a/test/cargo.js b/test/cargo.js
index fc377fe..2191eb8 100644
--- a/test/cargo.js
+++ b/test/cargo.js
@@ -72,7 +72,7 @@ describe('cargo', () => {
it('without callback', (done) => {
var call_order = [],
- delays = [40,20,60,20];
+ delays = [40,60,60,20];
// worker: --1-2---34-5-
// order of completion: 1,2,3,4,5
@@ -88,14 +88,14 @@ describe('cargo', () => {
setTimeout(() => {
c.push(2);
- }, 30);
+ }, 20);
setTimeout(() => {
c.push(3);
c.push(4);
c.push(5);
- }, 50);
+ }, 80);
- setTimeout(() => {
+ c.drain = function() {
expect(call_order).to.eql([
'process 1',
'process 2',
@@ -103,7 +103,7 @@ describe('cargo', () => {
'process 5'
]);
done();
- }, 200);
+ }
});
it('bulk task', (done) => {
@@ -174,15 +174,16 @@ describe('cargo', () => {
var drainCounter = 0;
c.drain = function () {
drainCounter++;
+
+ if (drainCounter === 1) {
+ loadCargo();
+ } else {
+ expect(drainCounter).to.equal(2);
+ done();
+ }
};
loadCargo();
- setTimeout(loadCargo, 50);
-
- setTimeout(() => {
- expect(drainCounter).to.equal(2);
- done();
- }, 100);
});
it('events', (done) => {
diff --git a/test/cargoQueue.js b/test/cargoQueue.js
index 3ff7f18..517422c 100644
--- a/test/cargoQueue.js
+++ b/test/cargoQueue.js
@@ -11,12 +11,35 @@ describe('cargoQueue', () => {
it('cargoQueue', (done) => {
var call_order = [],
- delays = [40, 40, 20];
+ delays = [50, 50, 50];
// worker: --12--34--5-
// order of completion: 1,2,3,4,5
var c = async.cargoQueue((tasks, callback) => {
+ if (tasks[0] === 1) {
+ c.push(3, (err, arg) => {
+ expect(err).to.equal('error');
+ expect(arg).to.equal('arg');
+ expect(c.length()).to.equal(0);
+ call_order.push('callback ' + 3);
+ });
+ } else if (tasks[0] === 3) {
+ c.push(4, (err, arg) => {
+ expect(err).to.equal('error');
+ expect(arg).to.equal('arg');
+ expect(c.length()).to.equal(0);
+ call_order.push('callback ' + 4);
+ });
+ expect(c.length()).to.equal(1);
+ c.push(5, (err, arg) => {
+ expect(err).to.equal('error');
+ expect(arg).to.equal('arg');
+ expect(c.length()).to.equal(0);
+ call_order.push('callback ' + 5);
+ });
+ }
+
setTimeout(() => {
call_order.push('process ' + tasks.join(' '));
callback('error', 'arg');
@@ -38,32 +61,6 @@ describe('cargoQueue', () => {
expect(c.length()).to.equal(2);
- // async push
- setTimeout(() => {
- c.push(3, (err, arg) => {
- expect(err).to.equal('error');
- expect(arg).to.equal('arg');
- expect(c.length()).to.equal(0);
- call_order.push('callback ' + 3);
- });
- }, 15);
- setTimeout(() => {
- c.push(4, (err, arg) => {
- expect(err).to.equal('error');
- expect(arg).to.equal('arg');
- expect(c.length()).to.equal(0);
- call_order.push('callback ' + 4);
- });
- expect(c.length()).to.equal(1);
- c.push(5, (err, arg) => {
- expect(err).to.equal('error');
- expect(arg).to.equal('arg');
- expect(c.length()).to.equal(0);
- call_order.push('callback ' + 5);
- });
- }, 30);
-
-
c.drain = function () {
expect(call_order).to.eql([
'process 1 2', 'callback 1', 'callback 2',
@@ -167,15 +164,16 @@ describe('cargoQueue', () => {
var drainCounter = 0;
c.drain = function () {
drainCounter++;
+
+ if (drainCounter === 1) {
+ loadCargo();
+ } else {
+ expect(drainCounter).to.equal(2);
+ done();
+ }
};
loadCargo();
- setTimeout(loadCargo, 50);
-
- setTimeout(() => {
- expect(drainCounter).to.equal(2);
- done();
- }, 100);
});
it('events', (done) => {
diff --git a/test/concat.js b/test/concat.js
index e42344b..bca05d7 100644
--- a/test/concat.js
+++ b/test/concat.js
@@ -387,7 +387,7 @@ describe('concat', function() {
x--;
}
cb(null, r);
- }, x*25);
+ }, x*10);
};
async.concatSeries([1,3,2], iteratee, (err, results) => {
expect(results).to.eql([1,3,2,1,2,1]);
diff --git a/test/detect.js b/test/detect.js
index 3351d9e..4663e29 100644
--- a/test/detect.js
+++ b/test/detect.js
@@ -71,11 +71,10 @@ describe("detect", () => {
call_order.push('callback');
expect(err).to.equal(null);
expect(result).to.equal(2);
- });
- setTimeout(() => {
+
expect(call_order).to.eql([3,2,'callback']);
done();
- }, 50);
+ });
});
it('detectSeries - multiple matches', function(done){
@@ -84,11 +83,10 @@ describe("detect", () => {
call_order.push('callback');
expect(err).to.equal(null);
expect(result).to.equal(2);
- });
- setTimeout(() => {
+
expect(call_order).to.eql([3,2,'callback']);
done();
- }, 50);
+ });
});
it('detect no callback', (done) => {
diff --git a/test/es2017/asyncFunctions.js b/test/es2017/asyncFunctions.js
index 59c0df8..efb6555 100644
--- a/test/es2017/asyncFunctions.js
+++ b/test/es2017/asyncFunctions.js
@@ -9,6 +9,8 @@ module.exports = function () {
return res;
}
+ this.retries(3);
+
const input = [1, 2, 3];
const inputObj = {a: 1, b: 2, c: 3};
@@ -303,8 +305,8 @@ module.exports = function () {
/* eslint prefer-arrow-callback: 0, object-shorthand: 0 */
it('should handle async functions in autoInject', (done) => {
async.autoInject({
- z: async function(){ return 0},
- a: async function a () {
+ z: async function () { return 0 },
+ a: async function () {
return await Promise.resolve(1);
},
b: async function (a) {
@@ -676,7 +678,7 @@ module.exports = function () {
var fn = async.timeout(async (val) => {
await new Promise((resolve) => setTimeout(resolve, 100));
return val;
- }, 50);
+ }, 20);
fn(1, (err) => {
expect(err.message).to.match(/timed out/);
done();
diff --git a/test/es2017/asyncGenerators.js b/test/es2017/asyncGenerators.js
index c9be07e..61ac964 100644
--- a/test/es2017/asyncGenerators.js
+++ b/test/es2017/asyncGenerators.js
@@ -26,12 +26,14 @@ module.exports = function () {
}
}
+ this.retries(3);
+
it('should handle async generators in each', (done) => {
const calls = []
async.each(range(5),
async (val) => {
calls.push(val)
- await delay(5)
+ await delay(1)
}, (err) => {
if (err) throw err
expect(calls).to.eql([0, 1, 2, 3, 4])
diff --git a/test/parallel.js b/test/parallel.js
index e95e65c..067c6ce 100644
--- a/test/parallel.js
+++ b/test/parallel.js
@@ -143,19 +143,19 @@ describe('parallel', () => {
setTimeout(() => {
call_order.push(1);
callback(null, 1);
- }, 50);
+ }, 10);
},
function(callback){
setTimeout(() => {
call_order.push(2);
callback(null, 2);
- }, 100);
+ }, 180);
},
function(callback){
setTimeout(() => {
call_order.push(3);
callback(null, 3,3);
- }, 25);
+ }, 10);
}
],
2,
diff --git a/test/priorityQueue.js b/test/priorityQueue.js
index e1c3b29..1a8cc76 100644
--- a/test/priorityQueue.js
+++ b/test/priorityQueue.js
@@ -55,7 +55,7 @@ describe('priorityQueue', () => {
it('concurrency', (done) => {
var call_order = [],
- delays = [160,80,240,80];
+ delays = [80,20,180,20];
// worker1: --2-3
// worker2: -1---4
@@ -65,7 +65,7 @@ describe('priorityQueue', () => {
setTimeout(() => {
call_order.push('process ' + task);
callback('error', 'arg');
- }, delays.splice(0,1)[0]);
+ }, delays.shift());
}, 2);
q.push(1, 1.4, (err, arg) => {
diff --git a/test/queue.js b/test/queue.js
index 2ac5077..f103aaa 100644
--- a/test/queue.js
+++ b/test/queue.js
@@ -10,8 +10,7 @@ describe('queue', function(){
it('basics', (done) => {
var call_order = [];
- var delays = [40,10,60,10];
-
+ var delays = [50,10,180,10];
// worker1: --1-4
// worker2: -2---3
@@ -66,7 +65,7 @@ describe('queue', function(){
it('default concurrency', (done) => {
var call_order = [],
- delays = [40,10,60,10];
+ delays = [50,10,180,10];
// order of completion: 1,2,3,4
@@ -223,7 +222,7 @@ describe('queue', function(){
this.retries(3); // test can be flakey
var call_order = [];
- var delays = [40,10,60,10];
+ var delays = [50,10,180,10];
var concurrencyList = [];
var running = 0;
@@ -300,7 +299,7 @@ describe('queue', function(){
it('bulk task', (done) => {
var call_order = [],
- delays = [40,10,60,10];
+ delays = [50,10,180,10];
// worker1: --1-4
// worker2: -2---3
@@ -445,6 +444,11 @@ describe('queue', function(){
it('start paused', (done) => {
var q = async.queue((task, callback) => {
+ if (task === 2) {
+ expect(q.length()).to.equal(1);
+ expect(q.running()).to.equal(2);
+ }
+
setTimeout(() => {
callback();
}, 40);
@@ -458,12 +462,6 @@ describe('queue', function(){
q.resume();
}, 5);
- setTimeout(() => {
- expect(q.length()).to.equal(1);
- expect(q.running()).to.equal(2);
- q.resume();
- }, 15);
-
q.drain = function () {
done();
};
diff --git a/test/retry.js b/test/retry.js
index d6cc06d..f76c7d8 100644
--- a/test/retry.js
+++ b/test/retry.js
@@ -124,7 +124,7 @@ describe("retry", () => {
setTimeout(() => {
expect(calls).to.equal(5);
done();
- }, 50);
+ }, 100);
});
it("should be cancelable", (done) => {
diff --git a/test/support/get_function_object.js b/test/support/get_function_object.js
index c31088f..561b152 100644
--- a/test/support/get_function_object.js
+++ b/test/support/get_function_object.js
@@ -10,7 +10,7 @@ module.exports = function (call_order) {
setTimeout(() => {
call_order.push(2);
callback(null, 2);
- }, 200);
+ }, 350);
},
three(callback) {
setTimeout(() => {
diff --git a/test/timeout.js b/test/timeout.js
index e5596ac..0d1c5b1 100644
--- a/test/timeout.js
+++ b/test/timeout.js
@@ -51,15 +51,15 @@ describe('timeout', () => {
it('timeout with parallel', (done) => {
async.parallel([
async.timeout((callback) => {
- setTimeout(() => {
+ setImmediate(() => {
callback(null, 'I didn\'t time out');
- }, 25);
- }, 50),
+ });
+ }, 20),
async.timeout((callback) => {
setTimeout(() => {
callback(null, 'I will time out');
}, 75);
- }, 50)
+ }, 20)
],
(err, results) => {
expect(err.message).to.equal('Callback function "anonymous" timed out.');
@@ -81,7 +81,7 @@ describe('timeout', () => {
callback(null, 'I didn\'t time out');
})
}
- }, 50);
+ }, 20);
async.series([
function(cb) {