Skip to content

Commit

Permalink
chore: vendor v18.12.1
Browse files Browse the repository at this point in the history
  • Loading branch information
kt3k committed May 12, 2023
1 parent cc5650c commit b6d7cad
Show file tree
Hide file tree
Showing 6,533 changed files with 606,505 additions and 1 deletion.
The diff you're trying to view is too large. We only load the first 3000 changed files.
68 changes: 68 additions & 0 deletions test/.eslintrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
## Test-specific linter rules

env:
node: true
es6: true

rules:
multiline-comment-style: [error, separate-lines]
prefer-const: error
symbol-description: off

no-restricted-syntax:
# Config copied from .eslintrc.js
- error
- selector: CallExpression:matches([callee.name='deepStrictEqual'], [callee.property.name='deepStrictEqual']):matches([arguments.1.type='Literal']:not([arguments.1.regex]), [arguments.1.type='Identifier'][arguments.1.name='undefined'])
message: Use strictEqual instead of deepStrictEqual for literals or undefined.
- selector: CallExpression:matches([callee.name='notDeepStrictEqual'], [callee.property.name='notDeepStrictEqual']):matches([arguments.1.type='Literal']:not([arguments.1.regex]), [arguments.1.type='Identifier'][arguments.1.name='undefined'])
message: Use notStrictEqual instead of notDeepStrictEqual for literals or undefined.
- selector: CallExpression:matches([callee.name='deepStrictEqual'], [callee.property.name='deepStrictEqual'])[arguments.2.type='Literal']
message: Do not use a literal for the third argument of assert.deepStrictEqual()
- selector: CallExpression:matches([callee.name='doesNotThrow'], [callee.property.name='doesNotThrow'])
message: Do not use `assert.doesNotThrow()`. Write the code without the wrapper and add a comment instead.
- selector: CallExpression:matches([callee.name='doesNotReject'], [callee.property.name='doesNotReject'])
message: Do not use `assert.doesNotReject()`. Write the code without the wrapper and add a comment instead.
- selector: CallExpression:matches([callee.name='rejects'], [callee.property.name='rejects'])[arguments.length<2]
message: '`assert.rejects()` must be invoked with at least two arguments.'
- selector: CallExpression[callee.property.name='strictEqual'][arguments.2.type='Literal']
message: Do not use a literal for the third argument of assert.strictEqual()
- selector: CallExpression:matches([callee.name='throws'], [callee.property.name='throws'])[arguments.1.type='Literal']:not([arguments.1.regex])
message: Use an object as second argument of `assert.throws()`.
- selector: CallExpression:matches([callee.name='throws'], [callee.property.name='throws'])[arguments.length<2]
message: '`assert.throws()` must be invoked with at least two arguments.'
- selector: CallExpression[callee.name='setInterval'][arguments.length<2]
message: '`setInterval()` must be invoked with at least two arguments.'
- selector: ThrowStatement > CallExpression[callee.name=/Error$/]
message: Use `new` keyword when throwing an `Error`.
- selector: CallExpression:matches([callee.name='notDeepStrictEqual'], [callee.property.name='notDeepStrictEqual'])[arguments.0.type='Literal']:not([arguments.1.type='Literal']):not([arguments.1.type='ObjectExpression']):not([arguments.1.type='ArrayExpression']):not([arguments.1.type='UnaryExpression'])
message: The first argument should be the `actual`, not the `expected` value.
- selector: CallExpression:matches([callee.name='notStrictEqual'], [callee.property.name='notStrictEqual'])[arguments.0.type='Literal']:not([arguments.1.type='Literal']):not([arguments.1.type='ObjectExpression']):not([arguments.1.type='ArrayExpression']):not([arguments.1.type='UnaryExpression'])
message: The first argument should be the `actual`, not the `expected` value.
- selector: CallExpression:matches([callee.name='deepStrictEqual'], [callee.property.name='deepStrictEqual'])[arguments.0.type='Literal']:not([arguments.1.type='Literal']):not([arguments.1.type='ObjectExpression']):not([arguments.1.type='ArrayExpression']):not([arguments.1.type='UnaryExpression'])
message: The first argument should be the `actual`, not the `expected` value.
- selector: CallExpression:matches([callee.name='strictEqual'], [callee.property.name='strictEqual'])[arguments.0.type='Literal']:not([arguments.1.type='Literal']):not([arguments.1.type='ObjectExpression']):not([arguments.1.type='ArrayExpression']):not([arguments.1.type='UnaryExpression'])
message: The first argument should be the `actual`, not the `expected` value.
- selector: CallExpression[callee.name='isNaN']
message: Use Number.isNaN() instead of the global isNaN() function.
- selector: VariableDeclarator > CallExpression:matches([callee.name='debuglog'], [callee.property.name='debuglog']):not([arguments.0.value='test'])
message: Use 'test' as debuglog value in tests.

# Custom rules in tools/eslint-rules
node-core/prefer-assert-iferror: error
node-core/prefer-assert-methods: error
node-core/prefer-common-mustnotcall: error
node-core/prefer-common-mustsucceed: error
node-core/crypto-check: error
node-core/eslint-check: error
node-core/async-iife-no-unused-result: error
node-core/inspector-check: error
## common module is mandatory in tests
node-core/required-modules:
- error
- common: common(/index\.(m)?js)?$
node-core/require-common-first: error
node-core/no-duplicate-requires: off

# Global scoped methods and vars
globals:
WebAssembly: false
39 changes: 39 additions & 0 deletions test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Node.js Core Tests

This directory contains code and data used to test the Node.js implementation.

For a detailed guide on how to write tests in this
directory, see [the guide on writing tests](../doc/contributing/writing-tests.md).

On how to run tests in this directory, see
[the contributing guide](../doc/contributing/pull-requests.md#step-6-test).

For the tests to run on Windows, be sure to clone Node.js source code with the
`autocrlf` git config flag set to true.

## Test Directories

| Directory | Runs on CI | Purpose |
| ---------------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `abort` | Yes | Tests that use `--abort-on-uncaught-exception` and other situations where we want to test something but avoid generating a core file. |
| `addons` | Yes | Tests for [addon](https://nodejs.org/api/addons.html) functionality along with some tests that require an addon. |
| `async-hooks` | Yes | Tests for [async\_hooks](https://nodejs.org/api/async_hooks.html) functionality. |
| `benchmark` | Yes | Test minimal functionality of benchmarks. |
| `cctest` | Yes | C++ tests that are run as part of the build process. |
| `code-cache` | No | Tests for a Node.js binary compiled with V8 code cache. |
| `common` | | Common modules shared among many tests. [Documentation](./common/README.md) |
| `doctool` | Yes | Tests for the documentation generator. |
| `es-module` | Yes | Test ESM module loading. |
| `fixtures` | | Test fixtures used in various tests throughout the test suite. |
| `internet` | No | Tests that make real outbound network connections. Tests for networking related modules may also be present in other directories, but those tests do not make outbound connections. |
| `js-native-api` | Yes | Tests for Node.js-agnostic [Node-API](https://nodejs.org/api/n-api.html) functionality. |
| `known_issues` | Yes | Tests reproducing known issues within the system. All tests inside of this directory are expected to fail. If a test doesn't fail on certain platforms, those should be skipped via `known_issues.status`. |
| `message` | Yes | Tests for messages that are output for various conditions (`console.log`, error messages etc.) |
| `node-api` | Yes | Tests for Node.js-specific [Node-API](https://nodejs.org/api/n-api.html) functionality. |
| `parallel` | Yes | Various tests that are able to be run in parallel. |
| `pseudo-tty` | Yes | Tests that require stdin/stdout/stderr to be a TTY. |
| `pummel` | No | Various tests for various modules / system functionality operating under load. |
| `sequential` | Yes | Various tests that must not run in parallel. |
| `testpy` | | Test configuration utility used by various test suites. |
| `tick-processor` | No | Tests for the V8 tick processor integration. The tests are for the logic in `lib/internal/v8_prof_processor.js` and `lib/internal/v8_prof_polyfill.js`. The tests confirm that the profile processor packages the correct set of scripts from V8 and introduces the correct platform specific logic. |
| `v8-updates` | No | Tests for V8 performance integration. |
7 changes: 7 additions & 0 deletions test/abort/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.buildstamp
.docbuildstamp
Makefile
*.Makefile
*.mk
gyp-mac-tool
/*/build
21 changes: 21 additions & 0 deletions test/abort/abort.status
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
prefix abort

# To mark a test as flaky, list the test name in the appropriate section
# below, without ".js", followed by ": PASS,FLAKY". Example:
# sample-test : PASS,FLAKY

[true] # This section applies to all platforms

[$system==ibmi]
# https://github.com/nodejs/node/issues/34410
test-addon-register-signal-handler: PASS,FLAKY

[$system==solaris] # Also applies to SmartOS
# https://github.com/nodejs/node/issues/43457
test-abort-fatal-error: PASS, FLAKY
test-abort-uncaught-exception: PASS, FLAKY
test-addon-register-signal-handler: PASS, FLAKY
test-process-abort-exitcode: PASS, FLAKY
test-signal-handler: PASS, FLAKY
test-worker-abort-uncaught-exception: PASS, FLAKY
test-zlib-invalid-internals-usage: PASS, FLAKY
28 changes: 28 additions & 0 deletions test/abort/test-abort-backtrace.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const cp = require('child_process');

if (process.argv[2] === 'child') {
process.abort();
} else {
const child = cp.spawnSync(`${process.execPath}`, [`${__filename}`, 'child']);
const stderr = child.stderr.toString();

assert.strictEqual(child.stdout.toString(), '');
// Stderr will be empty for systems that don't support backtraces.
if (stderr !== '') {
const frames = stderr.trimRight().split('\n').map((s) => s.trim());

if (!frames.every((frame, index) => frame.startsWith(`${index + 1}:`))) {
assert.fail(`Each frame should start with a frame number:\n${stderr}`);
}

if (!common.isWindows) {
const { getBinaryPath } = require('../common/shared-lib-util');
if (!frames.some((frame) => frame.includes(`[${getBinaryPath()}]`))) {
assert.fail(`Some frames should include the binary name:\n${stderr}`);
}
}
}
}
48 changes: 48 additions & 0 deletions test/abort/test-abort-fatal-error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

'use strict';
const common = require('../common');
if (common.isWindows)
common.skip('no RLIMIT_NOFILE on Windows');

const assert = require('assert');
const exec = require('child_process').exec;

let cmdline = `ulimit -c 0; ${process.execPath}`;
cmdline += ' --max-old-space-size=16 --max-semi-space-size=4';
cmdline += ' -e "a = []; for (i = 0; i < 1e9; i++) { a.push({}) }"';

exec(cmdline, function(err, stdout, stderr) {
if (!err) {
console.log(stdout);
console.log(stderr);
assert(false, 'this test should fail');
return;
}

if (err.code !== 134 && err.signal !== 'SIGABRT') {
console.log(stdout);
console.log(stderr);
console.log(err);
assert(false, err);
}
});
40 changes: 40 additions & 0 deletions test/abort/test-abort-uncaught-exception.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
'use strict';

const common = require('../common');
const assert = require('assert');
const spawn = require('child_process').spawn;
const vm = require('vm');
const node = process.execPath;

if (process.argv[2] === 'child') {
throw new Error('child error');
} else if (process.argv[2] === 'vm') {
// Refs: https://github.com/nodejs/node/issues/13258
// This *should* still crash.
new vm.Script('[', {});
} else {
run('', 'child', null);
run('--abort-on-uncaught-exception', 'child',
['SIGABRT', 'SIGTRAP', 'SIGILL']);
run('--abort-on-uncaught-exception', 'vm', ['SIGABRT', 'SIGTRAP', 'SIGILL']);
}

function run(flags, argv2, signals) {
const args = [__filename, argv2];
if (flags)
args.unshift(flags);

const child = spawn(node, args);
child.on('exit', common.mustCall(function(code, sig) {
if (common.isWindows) {
if (signals)
assert.strictEqual(code, 0x80000003);
else
assert.strictEqual(code, 1);
} else if (signals) {
assert(signals.includes(sig), `Unexpected signal ${sig}`);
} else {
assert.strictEqual(sig, null);
}
}));
}
7 changes: 7 additions & 0 deletions test/abort/test-addon-register-signal-handler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';
require('../common');

// This is a sibling test to test/addons/register-signal-handler/

process.env.ALLOW_CRASHES = true;
require('../addons/register-signal-handler/test');
Loading

0 comments on commit b6d7cad

Please sign in to comment.