From 1ce05ad5401447cff6df6e62e22ff5cf052e5c92 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 5 Nov 2016 20:45:16 -0700 Subject: [PATCH] test: move timer-dependent test to sequential `test-regress-GH-897` is dependent on a timer firing within a period of time. Especially on some of the FreeBSD hosts on CI, we have seen tests like that fail when run in parallel. (This may have nothing to do with FreeBSD and may just mean that the hosts are resource-constrained.) Move this test to sequential as we have done with several other timer-dependent tests recently. The test has also been refactored and documented via comments. PR-URL: https://github.com/nodejs/node/pull/9487 Reviewed-By: Colin Ihrig Reviewed-By: Santiago Gimeno Reviewed-By: Minwoo Jung --- test/parallel/test-regress-GH-897.js | 15 --------------- test/sequential/test-regress-GH-897.js | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 15 deletions(-) delete mode 100644 test/parallel/test-regress-GH-897.js create mode 100644 test/sequential/test-regress-GH-897.js diff --git a/test/parallel/test-regress-GH-897.js b/test/parallel/test-regress-GH-897.js deleted file mode 100644 index 1b46994dc37d94..00000000000000 --- a/test/parallel/test-regress-GH-897.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; -require('../common'); -var assert = require('assert'); - -var t = Date.now(); -var diff; -setTimeout(function() { - diff = Date.now() - t; - console.error(diff); -}, 0.1); - - -process.on('exit', function() { - assert.ok(diff < 100); -}); diff --git a/test/sequential/test-regress-GH-897.js b/test/sequential/test-regress-GH-897.js new file mode 100644 index 00000000000000..7b1297efd5a1b7 --- /dev/null +++ b/test/sequential/test-regress-GH-897.js @@ -0,0 +1,17 @@ +'use strict'; + +// Test for bug where a timer duration greater than 0 ms but less than 1 ms +// resulted in the duration being set for 1000 ms. The expected behavior is +// that the timeout would be set for 1 ms, and thus fire more-or-less +// immediately. +// +// Ref: https://github.com/nodejs/node-v0.x-archive/pull/897 + +const common = require('../common'); +const assert = require('assert'); + +const t = Date.now(); +setTimeout(common.mustCall(function() { + const diff = Date.now() - t; + assert.ok(diff < 100, `timer fired after ${diff} ms`); +}), 0.1);