Skip to content

Commit

Permalink
Moving test to another file added timeout to spawn sync
Browse files Browse the repository at this point in the history
  • Loading branch information
shubham9411 committed Nov 2, 2023
1 parent a0503e8 commit 88f0026
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 39 deletions.
18 changes: 0 additions & 18 deletions test/fixtures/test-runner/timeout.js

This file was deleted.

20 changes: 20 additions & 0 deletions test/parallel/test-runner-cli-timeout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';
require('../common');
const assert = require('node:assert');
const { spawnSync } = require('node:child_process');
const { test } = require('node:test');

test('test-timeout flag', () => {
const args = ['--test', '--test-timeout', 10, 'test/fixtures/test-runner/never_ending_sync.js'];
const child = spawnSync(process.execPath, args, { timeout: 100 });

assert.strictEqual(child.status, 1);

Check failure on line 11 in test/parallel/test-runner-cli-timeout.js

View workflow job for this annotation

GitHub Actions / test-linux

--- stdout --- βœ– test-timeout flag (108.902512ms) AssertionError [ERR_ASSERTION]: Expected values to be strictly equal: null !== 1 at TestContext.<anonymous> (/home/runner/work/node/node/test/parallel/test-runner-cli-timeout.js:11:10) at Test.runInAsyncScope (node:async_hooks:206:9) at Test.run (node:internal/test_runner/test:631:25) at Test.start (node:internal/test_runner/test:542:17) at startSubtest (node:internal/test_runner/harness:216:17) { generatedMessage: true, code: 'ERR_ASSERTION', actual: null, expected: 1, operator: 'strictEqual' } ::debug::starting to run test-timeout flag ::error title=test-timeout flag,file=test/parallel/test-runner-cli-timeout.js,line=11,col=10::[Error [ERR_TEST_FAILURE]: Expected values to be strictly equal: null !== 1 ] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: AssertionError [ERR_ASSERTION]: Expected values to be strictly equal: null !== 1 at TestContext.<anonymous> (/home/runner/work/node/node/test/parallel/test-runner-cli-timeout.js:11:10) at Test.runInAsyncScope (node:async_hooks:206:9) at Test.run (node:internal/test_runner/test:631:25) at Test.start (node:internal/test_runner/test:542:17) at startSubtest (node:internal/test_runner/harness:216:17) { generatedMessage: true, code: 'ERR_ASSERTION', actual: null, expected: 1, operator: 'strictEqual' } } β„Ή tests 1 β„Ή suites 0 β„Ή pass 0 β„Ή fail 1 β„Ή cancelled 0 β„Ή skipped 0 β„Ή todo 0 β„Ή duration_ms 162.143123 βœ– failing tests: test at test/parallel/test-runner-cli-timeout.js:7:1 βœ– test-timeout flag (108.902512ms) AssertionError [ERR_ASSERTION]: Expected values to be strictly equal: null !== 1 at TestContext.<anonymous> (/home/runner/work/node/node/test/parallel/test-runner-cli-timeout.js:11:10) at Test.runInAsyncScope (node:async_hooks:206:9) at Test.run (node:internal/test_runner/test:631:25) at Test.start (node:internal/test_runner/test:542:17) at startSubtest (node:internal/test_runner/harness:216:17) { generatedMessage: true, code: 'ERR_ASSERTION', actual: null, expected: 1, operator: 'strictEqual' } ::group::Test results (0 passed, 1 failed) ::notice::Total Tests: 1 Suites πŸ“‚: 0 Passed βœ…: 0 Failed ❌: 1 Canceled 🚫: 0 Skipped ⏭️: 0 Todo πŸ“: 0 Duration πŸ•: 162.143ms ::endgroup:: Command: out/Release/node --test-reporter=spec --test-reporter-destination=stdout --test-reporter=./tools/github_reporter/index.js --test-reporter-destination=stdout /home/runner/work/node/node/test/parallel/test-runner-cli-timeout.js

Check failure on line 11 in test/parallel/test-runner-cli-timeout.js

View workflow job for this annotation

GitHub Actions / test-macOS

--- stdout --- βœ– test-timeout flag (184.293659ms) AssertionError [ERR_ASSERTION]: Expected values to be strictly equal: 7 !== 1 at TestContext.<anonymous> (/Users/runner/work/node/node/test/parallel/test-runner-cli-timeout.js:11:10) at Test.runInAsyncScope (node:async_hooks:206:9) at Test.run (node:internal/test_runner/test:631:25) at Test.start (node:internal/test_runner/test:542:17) at startSubtest (node:internal/test_runner/harness:216:17) { generatedMessage: true, code: 'ERR_ASSERTION', actual: 7, expected: 1, operator: 'strictEqual' } ::debug::starting to run test-timeout flag ::error title=test-timeout flag,file=test/parallel/test-runner-cli-timeout.js,line=11,col=10::[Error [ERR_TEST_FAILURE]: Expected values to be strictly equal: 7 !== 1 ] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: AssertionError [ERR_ASSERTION]: Expected values to be strictly equal: 7 !== 1 at TestContext.<anonymous> (/Users/runner/work/node/node/test/parallel/test-runner-cli-timeout.js:11:10) at Test.runInAsyncScope (node:async_hooks:206:9) at Test.run (node:internal/test_runner/test:631:25) at Test.start (node:internal/test_runner/test:542:17) at startSubtest (node:internal/test_runner/harness:216:17) { generatedMessage: true, code: 'ERR_ASSERTION', actual: 7, expected: 1, operator: 'strictEqual' } } β„Ή tests 1 β„Ή suites 0 β„Ή pass 0 β„Ή fail 1 β„Ή cancelled 0 β„Ή skipped 0 β„Ή todo 0 β„Ή duration_ms 331.796365 βœ– failing tests: test at test/parallel/test-runner-cli-timeout.js:7:1 βœ– test-timeout flag (184.293659ms) AssertionError [ERR_ASSERTION]: Expected values to be strictly equal: 7 !== 1 at TestContext.<anonymous> (/Users/runner/work/node/node/test/parallel/test-runner-cli-timeout.js:11:10) at Test.runInAsyncScope (node:async_hooks:206:9) at Test.run (node:internal/test_runner/test:631:25) at Test.start (node:internal/test_runner/test:542:17) at startSubtest (node:internal/test_runner/harness:216:17) { generatedMessage: true, code: 'ERR_ASSERTION', actual: 7, expected: 1, operator: 'strictEqual' } ::group::Test results (0 passed, 1 failed) ::notice::Total Tests: 1 Suites πŸ“‚: 0 Passed βœ…: 0 Failed ❌: 1 Canceled 🚫: 0 Skipped ⏭️: 0 Todo πŸ“: 0 Duration πŸ•: 331.796ms ::endgroup:: Command: out/Release/node --test-reporter=spec --test-reporter-destination=stdout --test-reporter=./tools/github_reporter/index.js --test-reporter-destination=stdout /Users/runner/work/node/node/test/parallel/test-runner-cli-timeout.js

Check failure on line 11 in test/parallel/test-runner-cli-timeout.js

View workflow job for this annotation

GitHub Actions / test-asan

--- stdout --- βœ– test-timeout flag (143.414053ms) AssertionError [ERR_ASSERTION]: Expected values to be strictly equal: null !== 1 at TestContext.<anonymous> (/home/runner/work/node/node/test/parallel/test-runner-cli-timeout.js:11:10) at Test.runInAsyncScope (node:async_hooks:206:9) at Test.run (node:internal/test_runner/test:631:25) at Test.start (node:internal/test_runner/test:542:17) at startSubtest (node:internal/test_runner/harness:216:17) { generatedMessage: true, code: 'ERR_ASSERTION', actual: null, expected: 1, operator: 'strictEqual' } ::debug::starting to run test-timeout flag ::error title=test-timeout flag,file=test/parallel/test-runner-cli-timeout.js,line=11,col=10::[Error [ERR_TEST_FAILURE]: Expected values to be strictly equal: null !== 1 ] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: AssertionError [ERR_ASSERTION]: Expected values to be strictly equal: null !== 1 at TestContext.<anonymous> (/home/runner/work/node/node/test/parallel/test-runner-cli-timeout.js:11:10) at Test.runInAsyncScope (node:async_hooks:206:9) at Test.run (node:internal/test_runner/test:631:25) at Test.start (node:internal/test_runner/test:542:17) at startSubtest (node:internal/test_runner/harness:216:17) { generatedMessage: true, code: 'ERR_ASSERTION', actual: null, expected: 1, operator: 'strictEqual' } } β„Ή tests 1 β„Ή suites 0 β„Ή pass 0 β„Ή fail 1 β„Ή cancelled 0 β„Ή skipped 0 β„Ή todo 0 β„Ή duration_ms 480.186092 βœ– failing tests: test at test/parallel/test-runner-cli-timeout.js:7:1 βœ– test-timeout flag (143.414053ms) AssertionError [ERR_ASSERTION]: Expected values to be strictly equal: null !== 1 at TestContext.<anonymous> (/home/runner/work/node/node/test/parallel/test-runner-cli-timeout.js:11:10) at Test.runInAsyncScope (node:async_hooks:206:9) at Test.run (node:internal/test_runner/test:631:25) at Test.start (node:internal/test_runner/test:542:17) at startSubtest (node:internal/test_runner/harness:216:17) { generatedMessage: true, code: 'ERR_ASSERTION', actual: null, expected: 1, operator: 'strictEqual' } ::group::Test results (0 passed, 1 failed) ::notice::Total Tests: 1 Suites πŸ“‚: 0 Passed βœ…: 0 Failed ❌: 1 Canceled 🚫: 0 Skipped ⏭️: 0 Todo πŸ“: 0 Duration πŸ•: 480.186ms ::endgroup:: Command: out/Release/node --test-reporter=spec --test-reporter-destination=stdout --test-reporter=./tools/github_reporter/index.js --test-reporter-destination=stdout /home/runner/work/node/node/test/parallel/test-runner-cli-timeout.js
assert.strictEqual(child.signal, null);
assert.strictEqual(child.stderr.toString(), '');
const stdout = child.stdout.toString();
assert.match(stdout, /not ok 1 - test/);
assert.match(stdout, / {2}---/);
assert.match(stdout, / {2}duration_ms: .*/);
assert.match(stdout, /failureType: 'testTimeoutFailure/);
assert.match(stdout, /error: 'test timed out after 10ms'/);
});
21 changes: 0 additions & 21 deletions test/parallel/test-runner-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,27 +115,6 @@ const testFixtures = fixtures.path('test-runner');
});
}

{
// Test --test-timeout flag
const args = [
'--test',
'--test-timeout',
50,
'test/fixtures/test-runner/timeout.js',
];
const child = spawnSync(process.execPath, args);

assert.strictEqual(child.status, 1);
assert.strictEqual(child.signal, null);
assert.strictEqual(child.stderr.toString(), '');
const stdout = child.stdout.toString();
assert.match(stdout, /not ok 1 - test/);
assert.match(stdout, / {2}---/);
assert.match(stdout, / {2}duration_ms: .*/);
assert.match(stdout, /failureType: 'testTimeoutFailure/);
assert.match(stdout, /error: 'test timed out after 50ms'/);
}

{
// Test combined stream outputs
const args = [
Expand Down

0 comments on commit 88f0026

Please sign in to comment.