From 7f9624af386429af641ef2bac5f97bed38bf7afd Mon Sep 17 00:00:00 2001 From: James Graham Date: Thu, 17 Apr 2014 13:48:28 +0100 Subject: [PATCH 1/2] Add a force_timeout function to tests. --- testharness.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/testharness.js b/testharness.js index 5ac8e55b79f2a3..782ddffa6799b0 100644 --- a/testharness.js +++ b/testharness.js @@ -162,6 +162,13 @@ policies and contribution forms [3]. * to the longer test timeout, the test must specify a meta element: * * + * Occasionally tests may have a race between the harness timing out and + * a particular test failing; typically when the test waits for some event + * that never occurs. In this case it is possible to use test.force_timeout() + * in place of assert_unreached(), to immediately fail the test but with a + * status of "timeout". This should only be used as a last resort when it is + * not possible to make the test reliable in some other way. + * * == Setup == * * Sometimes tests require non-trivial setup that may fail. For this purpose @@ -1214,6 +1221,11 @@ policies and contribution forms [3]. this.cleanup_callbacks.push(callback); }; + Test.prototype.force_timeout = function() { + test_obj.set_status(test_obj.TIMEOUT); + test_obj.phase = test_obj.phases.HAS_RESULT; + } + Test.prototype.set_timeout = function() { if (this.timeout_length !== null) { From 6768f7049d93d9dc5b2e40a9179dabf334ca8141 Mon Sep 17 00:00:00 2001 From: James Graham Date: Thu, 17 Apr 2014 13:57:17 +0100 Subject: [PATCH 2/2] fixup! Add a force_timeout function to tests. --- testharness.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testharness.js b/testharness.js index 782ddffa6799b0..656ad4dc77eb6b 100644 --- a/testharness.js +++ b/testharness.js @@ -1222,8 +1222,8 @@ policies and contribution forms [3]. }; Test.prototype.force_timeout = function() { - test_obj.set_status(test_obj.TIMEOUT); - test_obj.phase = test_obj.phases.HAS_RESULT; + this.set_status(this.TIMEOUT); + this.phase = this.phases.HAS_RESULT; } Test.prototype.set_timeout = function()