Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4a1c86d

Browse files
authoredSep 27, 2023
Merge branch 'main' into perf-timessync
2 parents ae73a09 + 783f64b commit 4a1c86d

25 files changed

+467
-226
lines changed
 

‎.github/workflows/tools.yml

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ on:
2323
- corepack
2424
- doc
2525
- eslint
26+
- github_reporter
2627
- googletest
2728
- histogram
2829
- icu

‎benchmark/fs/bench-unlinkSync.js

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const fs = require('fs');
5+
const tmpdir = require('../../test/common/tmpdir');
6+
tmpdir.refresh();
7+
8+
const bench = common.createBenchmark(main, {
9+
type: ['existing', 'non-existing'],
10+
n: [1e3],
11+
});
12+
13+
function main({ n, type }) {
14+
let files;
15+
16+
switch (type) {
17+
case 'existing':
18+
files = [];
19+
20+
// Populate tmpdir with mock files
21+
for (let i = 0; i < n; i++) {
22+
const path = tmpdir.resolve(`unlinksync-bench-file-${i}`);
23+
fs.writeFileSync(path, 'bench');
24+
files.push(path);
25+
}
26+
break;
27+
case 'non-existing':
28+
files = new Array(n).fill(tmpdir.resolve(`.non-existing-file-${Date.now()}`));
29+
break;
30+
default:
31+
new Error('Invalid type');
32+
}
33+
34+
bench.start();
35+
for (let i = 0; i < n; i++) {
36+
try {
37+
fs.unlinkSync(files[i]);
38+
} catch {
39+
// do nothing
40+
}
41+
}
42+
bench.end(n);
43+
}

‎benchmark/fs/readFileSync.js

+15-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,21 @@ const fs = require('fs');
66
const bench = common.createBenchmark(main, {
77
encoding: ['undefined', 'utf8'],
88
path: ['existing', 'non-existing'],
9-
n: [60e1],
9+
hasFileDescriptor: ['true', 'false'],
10+
n: [1e4],
1011
});
1112

12-
function main({ n, encoding, path }) {
13+
function main({ n, encoding, path, hasFileDescriptor }) {
1314
const enc = encoding === 'undefined' ? undefined : encoding;
14-
const file = path === 'existing' ? __filename : '/tmp/not-found';
15+
let file;
16+
let shouldClose = false;
17+
18+
if (hasFileDescriptor === 'true') {
19+
shouldClose = path === 'existing';
20+
file = path === 'existing' ? fs.openSync(__filename) : -1;
21+
} else {
22+
file = path === 'existing' ? __filename : '/tmp/not-found';
23+
}
1524
bench.start();
1625
for (let i = 0; i < n; ++i) {
1726
try {
@@ -21,4 +30,7 @@ function main({ n, encoding, path }) {
2130
}
2231
}
2332
bench.end(n);
33+
if (shouldClose) {
34+
fs.closeSync(file);
35+
}
2436
}

‎benchmark/perf_hooks/timerfied.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
'use strict';
2+
3+
const assert = require('assert');
4+
const common = require('../common.js');
5+
6+
const {
7+
PerformanceObserver,
8+
performance,
9+
} = require('perf_hooks');
10+
11+
function randomFn() {
12+
return Math.random();
13+
}
14+
15+
const bench = common.createBenchmark(main, {
16+
n: [1e5],
17+
observe: ['function'],
18+
});
19+
20+
let _result;
21+
22+
function main({ n, observe }) {
23+
const obs = new PerformanceObserver(() => {
24+
bench.end(n);
25+
});
26+
obs.observe({ entryTypes: [observe], buffered: true });
27+
28+
const timerfied = performance.timerify(randomFn);
29+
30+
bench.start();
31+
for (let i = 0; i < n; i++)
32+
_result = timerfied();
33+
34+
// Avoid V8 deadcode (elimination)
35+
assert.ok(_result);
36+
}

‎benchmark/url/whatwg-url-validity.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
const common = require('../common.js');
3+
const url = require('url');
4+
const URL = url.URL;
5+
6+
const bench = common.createBenchmark(main, {
7+
type: ['valid', 'invalid'],
8+
e: [1e5],
9+
});
10+
11+
// This benchmark is used to compare the `Invalid URL` path of the URL parser
12+
function main({ type, e }) {
13+
const url = type === 'valid' ? 'https://www.nodejs.org' : 'www.nodejs.org';
14+
bench.start();
15+
for (let i = 0; i < e; i++) {
16+
try {
17+
new URL(url);
18+
} catch {
19+
// do nothing
20+
}
21+
}
22+
bench.end(e);
23+
}

‎lib/fs.js

+3-8
Original file line numberDiff line numberDiff line change
@@ -437,13 +437,11 @@ function tryReadSync(fd, isUserFd, buffer, pos, len) {
437437
function readFileSync(path, options) {
438438
options = getOptions(options, { flag: 'r' });
439439

440-
const isUserFd = isFd(path); // File descriptor ownership
441-
442-
// TODO(@anonrig): Do not handle file descriptor ownership for now.
443-
if (!isUserFd && (options.encoding === 'utf8' || options.encoding === 'utf-8')) {
440+
if (options.encoding === 'utf8' || options.encoding === 'utf-8') {
444441
return syncFs.readFileUtf8(path, options.flag);
445442
}
446443

444+
const isUserFd = isFd(path); // File descriptor ownership
447445
const fd = isUserFd ? path : fs.openSync(path, options.flag, 0o666);
448446

449447
const stats = tryStatSync(fd, isUserFd);
@@ -1852,10 +1850,7 @@ function unlink(path, callback) {
18521850
* @returns {void}
18531851
*/
18541852
function unlinkSync(path) {
1855-
path = getValidatedPath(path);
1856-
const ctx = { path };
1857-
binding.unlink(pathModule.toNamespacedPath(path), undefined, ctx);
1858-
handleErrorFromBinding(ctx);
1853+
return syncFs.unlink(path);
18591854
}
18601855

18611856
/**

‎lib/internal/errors.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -1370,8 +1370,13 @@ E('ERR_INVALID_SYNC_FORK_INPUT',
13701370
E('ERR_INVALID_THIS', 'Value of "this" must be of type %s', TypeError);
13711371
E('ERR_INVALID_TUPLE', '%s must be an iterable %s tuple', TypeError);
13721372
E('ERR_INVALID_URI', 'URI malformed', URIError);
1373-
E('ERR_INVALID_URL', function(input) {
1373+
E('ERR_INVALID_URL', function(input, base = null) {
13741374
this.input = input;
1375+
1376+
if (base != null) {
1377+
this.base = base;
1378+
}
1379+
13751380
// Don't include URL in message.
13761381
// (See https://github.com/nodejs/node/pull/38614)
13771382
return 'Invalid URL';

‎lib/internal/fs/sync.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const {
1010
getValidatedFd,
1111
toUnixTimestamp,
1212
} = require('internal/fs/utils');
13-
const { parseFileMode } = require('internal/validators');
13+
const { parseFileMode, isInt32 } = require('internal/validators');
1414

1515
const binding = internalBinding('fs');
1616

@@ -20,7 +20,9 @@ const binding = internalBinding('fs');
2020
* @return {string}
2121
*/
2222
function readFileUtf8(path, flag) {
23-
path = pathModule.toNamespacedPath(getValidatedPath(path));
23+
if (!isInt32(path)) {
24+
path = pathModule.toNamespacedPath(getValidatedPath(path));
25+
}
2426
return binding.readFileUtf8(path, stringToFlags(flag));
2527
}
2628

@@ -104,6 +106,11 @@ function lutimes(path, atime, mtime) {
104106
return binding.lutimesSync(path, toUnixTimestamp(atime), toUnixTimestamp(mtime));
105107
}
106108

109+
function unlink(path) {
110+
path = pathModule.toNamespacedPath(getValidatedPath(path));
111+
return binding.unlinkSync(path);
112+
}
113+
107114
module.exports = {
108115
readFileUtf8,
109116
exists,
@@ -116,4 +123,5 @@ module.exports = {
116123
utimes,
117124
futimes,
118125
lutimes,
126+
unlink,
119127
};

‎lib/internal/perf/performance_entry.js

+16-10
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
const {
44
ObjectDefineProperties,
5-
ReflectConstruct,
65
Symbol,
76
} = primordials;
87

@@ -25,14 +24,17 @@ const kEntryType = Symbol('PerformanceEntry.EntryType');
2524
const kStartTime = Symbol('PerformanceEntry.StartTime');
2625
const kDuration = Symbol('PerformanceEntry.Duration');
2726
const kDetail = Symbol('NodePerformanceEntry.Detail');
27+
const kSkipThrow = Symbol('kSkipThrow');
2828

2929
function isPerformanceEntry(obj) {
3030
return obj?.[kName] !== undefined;
3131
}
3232

3333
class PerformanceEntry {
34-
constructor() {
35-
throw new ERR_ILLEGAL_CONSTRUCTOR();
34+
constructor(skipThrowSymbol = undefined) {
35+
if (skipThrowSymbol !== kSkipThrow) {
36+
throw new ERR_ILLEGAL_CONSTRUCTOR();
37+
}
3638
}
3739

3840
get name() {
@@ -92,9 +94,11 @@ function initPerformanceEntry(entry, name, type, start, duration) {
9294
}
9395

9496
function createPerformanceEntry(name, type, start, duration) {
95-
return ReflectConstruct(function PerformanceEntry() {
96-
initPerformanceEntry(this, name, type, start, duration);
97-
}, [], PerformanceEntry);
97+
const entry = new PerformanceEntry(kSkipThrow);
98+
99+
initPerformanceEntry(entry, name, type, start, duration);
100+
101+
return entry;
98102
}
99103

100104
/**
@@ -119,10 +123,12 @@ class PerformanceNodeEntry extends PerformanceEntry {
119123
}
120124

121125
function createPerformanceNodeEntry(name, type, start, duration, detail) {
122-
return ReflectConstruct(function PerformanceNodeEntry() {
123-
initPerformanceEntry(this, name, type, start, duration);
124-
this[kDetail] = detail;
125-
}, [], PerformanceNodeEntry);
126+
const entry = new PerformanceNodeEntry(kSkipThrow);
127+
128+
initPerformanceEntry(entry, name, type, start, duration);
129+
entry[kDetail] = detail;
130+
131+
return entry;
126132
}
127133

128134
module.exports = {

‎lib/internal/streams/writable.js

+195-142
Large diffs are not rendered by default.

‎lib/internal/url.js

+1-7
Original file line numberDiff line numberDiff line change
@@ -780,13 +780,7 @@ class URL {
780780
base = `${base}`;
781781
}
782782

783-
const href = bindingUrl.parse(input, base);
784-
785-
if (!href) {
786-
throw new ERR_INVALID_URL(input);
787-
}
788-
789-
this.#updateContext(href);
783+
this.#updateContext(bindingUrl.parse(input, base));
790784
}
791785

792786
[inspect.custom](depth, opts) {

‎src/env_properties.h

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
V(args_string, "args") \
5858
V(asn1curve_string, "asn1Curve") \
5959
V(async_ids_stack_string, "async_ids_stack") \
60+
V(base_string, "base") \
6061
V(bits_string, "bits") \
6162
V(block_list_string, "blockList") \
6263
V(buffer_string, "buffer") \

‎src/node_file.cc

+56-22
Original file line numberDiff line numberDiff line change
@@ -1667,6 +1667,27 @@ static void Unlink(const FunctionCallbackInfo<Value>& args) {
16671667
}
16681668
}
16691669

1670+
static void UnlinkSync(const FunctionCallbackInfo<Value>& args) {
1671+
Environment* env = Environment::GetCurrent(args);
1672+
1673+
const int argc = args.Length();
1674+
CHECK_GE(argc, 1);
1675+
1676+
BufferValue path(env->isolate(), args[0]);
1677+
CHECK_NOT_NULL(*path);
1678+
THROW_IF_INSUFFICIENT_PERMISSIONS(
1679+
env, permission::PermissionScope::kFileSystemWrite, path.ToStringView());
1680+
1681+
uv_fs_t req;
1682+
auto make = OnScopeLeave([&req]() { uv_fs_req_cleanup(&req); });
1683+
FS_SYNC_TRACE_BEGIN(unlink);
1684+
int err = uv_fs_unlink(nullptr, &req, *path, nullptr);
1685+
FS_SYNC_TRACE_END(unlink);
1686+
if (err < 0) {
1687+
return env->ThrowUVException(err, "unlink", nullptr, *path);
1688+
}
1689+
}
1690+
16701691
static void RMDir(const FunctionCallbackInfo<Value>& args) {
16711692
Environment* env = Environment::GetCurrent(args);
16721693

@@ -2155,7 +2176,7 @@ static void OpenSync(const FunctionCallbackInfo<Value>& args) {
21552176
uv_fs_t req;
21562177
auto make = OnScopeLeave([&req]() { uv_fs_req_cleanup(&req); });
21572178
FS_SYNC_TRACE_BEGIN(open);
2158-
int err = uv_fs_open(nullptr, &req, *path, flags, mode, nullptr);
2179+
auto err = uv_fs_open(nullptr, &req, *path, flags, mode, nullptr);
21592180
FS_SYNC_TRACE_END(open);
21602181
if (err < 0) {
21612182
return env->ThrowUVException(err, "open", nullptr, path.out());
@@ -2546,30 +2567,41 @@ static void ReadFileUtf8(const FunctionCallbackInfo<Value>& args) {
25462567

25472568
CHECK_GE(args.Length(), 2);
25482569

2549-
BufferValue path(env->isolate(), args[0]);
2550-
CHECK_NOT_NULL(*path);
2551-
25522570
CHECK(args[1]->IsInt32());
25532571
const int flags = args[1].As<Int32>()->Value();
25542572

2555-
if (CheckOpenPermissions(env, path, flags).IsNothing()) return;
2556-
2573+
uv_file file;
25572574
uv_fs_t req;
2558-
auto defer_req_cleanup = OnScopeLeave([&req]() { uv_fs_req_cleanup(&req); });
25592575

2560-
FS_SYNC_TRACE_BEGIN(open);
2561-
uv_file file = uv_fs_open(nullptr, &req, *path, flags, 438, nullptr);
2562-
FS_SYNC_TRACE_END(open);
2563-
if (req.result < 0) {
2564-
// req will be cleaned up by scope leave.
2565-
return env->ThrowUVException(req.result, "open", nullptr, path.out());
2576+
bool is_fd = args[0]->IsInt32();
2577+
2578+
// Check for file descriptor
2579+
if (is_fd) {
2580+
file = args[0].As<Int32>()->Value();
2581+
} else {
2582+
BufferValue path(env->isolate(), args[0]);
2583+
CHECK_NOT_NULL(*path);
2584+
if (CheckOpenPermissions(env, path, flags).IsNothing()) return;
2585+
2586+
FS_SYNC_TRACE_BEGIN(open);
2587+
file = uv_fs_open(nullptr, &req, *path, flags, O_RDONLY, nullptr);
2588+
FS_SYNC_TRACE_END(open);
2589+
if (req.result < 0) {
2590+
uv_fs_req_cleanup(&req);
2591+
// req will be cleaned up by scope leave.
2592+
return env->ThrowUVException(req.result, "open", nullptr, path.out());
2593+
}
25662594
}
25672595

2568-
auto defer_close = OnScopeLeave([file]() {
2569-
uv_fs_t close_req;
2570-
CHECK_EQ(0, uv_fs_close(nullptr, &close_req, file, nullptr));
2571-
uv_fs_req_cleanup(&close_req);
2596+
auto defer_close = OnScopeLeave([file, is_fd, &req]() {
2597+
if (!is_fd) {
2598+
FS_SYNC_TRACE_BEGIN(close);
2599+
CHECK_EQ(0, uv_fs_close(nullptr, &req, file, nullptr));
2600+
FS_SYNC_TRACE_END(close);
2601+
}
2602+
uv_fs_req_cleanup(&req);
25722603
});
2604+
25732605
std::string result{};
25742606
char buffer[8192];
25752607
uv_buf_t buf = uv_buf_init(buffer, sizeof(buffer));
@@ -2580,7 +2612,7 @@ static void ReadFileUtf8(const FunctionCallbackInfo<Value>& args) {
25802612
if (req.result < 0) {
25812613
FS_SYNC_TRACE_END(read);
25822614
// req will be cleaned up by scope leave.
2583-
return env->ThrowUVException(req.result, "read", nullptr, path.out());
2615+
return env->ThrowUVException(req.result, "read", nullptr);
25842616
}
25852617
if (r <= 0) {
25862618
break;
@@ -3429,15 +3461,15 @@ static void CreatePerIsolateProperties(IsolateData* isolate_data,
34293461
Isolate* isolate = isolate_data->isolate();
34303462

34313463
SetMethod(isolate, target, "access", Access);
3432-
SetMethodNoSideEffect(isolate, target, "accessSync", AccessSync);
3464+
SetMethod(isolate, target, "accessSync", AccessSync);
34333465
SetMethod(isolate, target, "close", Close);
34343466
SetMethod(isolate, target, "closeSync", CloseSync);
3435-
SetMethodNoSideEffect(isolate, target, "existsSync", ExistsSync);
3467+
SetMethod(isolate, target, "existsSync", ExistsSync);
34363468
SetMethod(isolate, target, "open", Open);
34373469
SetMethod(isolate, target, "openSync", OpenSync);
34383470
SetMethod(isolate, target, "openFileHandle", OpenFileHandle);
34393471
SetMethod(isolate, target, "read", Read);
3440-
SetMethodNoSideEffect(isolate, target, "readFileUtf8", ReadFileUtf8);
3472+
SetMethod(isolate, target, "readFileUtf8", ReadFileUtf8);
34413473
SetMethod(isolate, target, "readBuffers", ReadBuffers);
34423474
SetMethod(isolate, target, "fdatasync", Fdatasync);
34433475
SetMethod(isolate, target, "fsync", Fsync);
@@ -3458,12 +3490,13 @@ static void CreatePerIsolateProperties(IsolateData* isolate_data,
34583490
SetMethod(isolate, target, "symlink", Symlink);
34593491
SetMethod(isolate, target, "readlink", ReadLink);
34603492
SetMethod(isolate, target, "unlink", Unlink);
3493+
SetMethod(isolate, target, "unlinkSync", UnlinkSync);
34613494
SetMethod(isolate, target, "writeBuffer", WriteBuffer);
34623495
SetMethod(isolate, target, "writeBuffers", WriteBuffers);
34633496
SetMethod(isolate, target, "writeString", WriteString);
34643497
SetMethod(isolate, target, "realpath", RealPath);
34653498
SetMethod(isolate, target, "copyFile", CopyFile);
3466-
SetMethodNoSideEffect(isolate, target, "copyFileSync", CopyFileSync);
3499+
SetMethod(isolate, target, "copyFileSync", CopyFileSync);
34673500

34683501
SetMethod(isolate, target, "chmod", Chmod);
34693502
SetMethod(isolate, target, "fchmod", FChmod);
@@ -3586,6 +3619,7 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
35863619
registry->Register(Symlink);
35873620
registry->Register(ReadLink);
35883621
registry->Register(Unlink);
3622+
registry->Register(UnlinkSync);
35893623
registry->Register(WriteBuffer);
35903624
registry->Register(WriteBuffers);
35913625
registry->Register(WriteString);

‎src/node_url.cc

+34-4
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,35 @@ void BindingData::Format(const FunctionCallbackInfo<Value>& args) {
227227
.ToLocalChecked());
228228
}
229229

230+
void BindingData::ThrowInvalidURL(node::Environment* env,
231+
std::string_view input,
232+
std::optional<std::string> base) {
233+
Local<Value> err = ERR_INVALID_URL(env->isolate(), "Invalid URL");
234+
DCHECK(err->IsObject());
235+
236+
auto err_object = err.As<Object>();
237+
238+
USE(err_object->Set(env->context(),
239+
env->input_string(),
240+
v8::String::NewFromUtf8(env->isolate(),
241+
input.data(),
242+
v8::NewStringType::kNormal,
243+
input.size())
244+
.ToLocalChecked()));
245+
246+
if (base.has_value()) {
247+
USE(err_object->Set(env->context(),
248+
env->base_string(),
249+
v8::String::NewFromUtf8(env->isolate(),
250+
base.value().c_str(),
251+
v8::NewStringType::kNormal,
252+
base.value().size())
253+
.ToLocalChecked()));
254+
}
255+
256+
env->isolate()->ThrowException(err);
257+
}
258+
230259
void BindingData::Parse(const FunctionCallbackInfo<Value>& args) {
231260
CHECK_GE(args.Length(), 1);
232261
CHECK(args[0]->IsString()); // input
@@ -235,23 +264,24 @@ void BindingData::Parse(const FunctionCallbackInfo<Value>& args) {
235264
Realm* realm = Realm::GetCurrent(args);
236265
BindingData* binding_data = realm->GetBindingData<BindingData>();
237266
Isolate* isolate = realm->isolate();
267+
std::optional<std::string> base_{};
238268

239269
Utf8Value input(isolate, args[0]);
240270
ada::result<ada::url_aggregator> base;
241271
ada::url_aggregator* base_pointer = nullptr;
242272
if (args[1]->IsString()) {
243-
base =
244-
ada::parse<ada::url_aggregator>(Utf8Value(isolate, args[1]).ToString());
273+
base_ = Utf8Value(isolate, args[1]).ToString();
274+
base = ada::parse<ada::url_aggregator>(*base_);
245275
if (!base) {
246-
return args.GetReturnValue().Set(false);
276+
return ThrowInvalidURL(realm->env(), input.ToStringView(), base_);
247277
}
248278
base_pointer = &base.value();
249279
}
250280
auto out =
251281
ada::parse<ada::url_aggregator>(input.ToStringView(), base_pointer);
252282

253283
if (!out) {
254-
return args.GetReturnValue().Set(false);
284+
return ThrowInvalidURL(realm->env(), input.ToStringView(), base_);
255285
}
256286

257287
binding_data->UpdateComponents(out->get_components(), out->type);

‎src/node_url.h

+3
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ class BindingData : public SnapshotableObject {
7676
const ada::scheme::type type);
7777

7878
static v8::CFunction fast_can_parse_methods_[];
79+
static void ThrowInvalidURL(Environment* env,
80+
std::string_view input,
81+
std::optional<std::string> base);
7982
};
8083

8184
std::string FromFilePath(const std::string_view file_path);

‎test/fixtures/test-runner/output/abort.snapshot

+8-8
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ TAP version 13
3232
# Subtest: not ok 2
3333
not ok 6 - not ok 2
3434
---
35-
duration_ms: ZERO
35+
duration_ms: *
3636
location: '/test/fixtures/test-runner/output/abort.js:(LINE):7'
3737
failureType: 'cancelledByParent'
3838
error: 'test did not finish before its parent and was cancelled'
@@ -41,7 +41,7 @@ TAP version 13
4141
# Subtest: not ok 3
4242
not ok 7 - not ok 3
4343
---
44-
duration_ms: ZERO
44+
duration_ms: *
4545
location: '/test/fixtures/test-runner/output/abort.js:(LINE):7'
4646
failureType: 'testAborted'
4747
error: 'This operation was aborted'
@@ -62,7 +62,7 @@ TAP version 13
6262
# Subtest: not ok 4
6363
not ok 8 - not ok 4
6464
---
65-
duration_ms: ZERO
65+
duration_ms: *
6666
location: '/test/fixtures/test-runner/output/abort.js:(LINE):7'
6767
failureType: 'testAborted'
6868
error: 'This operation was aborted'
@@ -83,7 +83,7 @@ TAP version 13
8383
# Subtest: not ok 5
8484
not ok 9 - not ok 5
8585
---
86-
duration_ms: ZERO
86+
duration_ms: *
8787
location: '/test/fixtures/test-runner/output/abort.js:(LINE):7'
8888
failureType: 'testAborted'
8989
error: 'This operation was aborted'
@@ -169,7 +169,7 @@ not ok 2 - promise abort signal
169169
# Subtest: not ok 2
170170
not ok 6 - not ok 2
171171
---
172-
duration_ms: ZERO
172+
duration_ms: *
173173
location: '/test/fixtures/test-runner/output/abort.js:(LINE):5'
174174
failureType: 'cancelledByParent'
175175
error: 'test did not finish before its parent and was cancelled'
@@ -178,7 +178,7 @@ not ok 2 - promise abort signal
178178
# Subtest: not ok 3
179179
not ok 7 - not ok 3
180180
---
181-
duration_ms: ZERO
181+
duration_ms: *
182182
location: '/test/fixtures/test-runner/output/abort.js:(LINE):5'
183183
failureType: 'testAborted'
184184
error: 'This operation was aborted'
@@ -199,7 +199,7 @@ not ok 2 - promise abort signal
199199
# Subtest: not ok 4
200200
not ok 8 - not ok 4
201201
---
202-
duration_ms: ZERO
202+
duration_ms: *
203203
location: '/test/fixtures/test-runner/output/abort.js:(LINE):5'
204204
failureType: 'testAborted'
205205
error: 'This operation was aborted'
@@ -220,7 +220,7 @@ not ok 2 - promise abort signal
220220
# Subtest: not ok 5
221221
not ok 9 - not ok 5
222222
---
223-
duration_ms: ZERO
223+
duration_ms: *
224224
location: '/test/fixtures/test-runner/output/abort.js:(LINE):5'
225225
failureType: 'testAborted'
226226
error: 'This operation was aborted'

‎test/fixtures/test-runner/output/abort_hooks.snapshot

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ TAP version 13
1111
# Subtest: test 1
1212
not ok 1 - test 1
1313
---
14-
duration_ms: ZERO
14+
duration_ms: *
1515
location: '/test/fixtures/test-runner/output/abort_hooks.js:(LINE):3'
1616
failureType: 'cancelledByParent'
1717
error: 'test did not finish before its parent and was cancelled'
@@ -20,7 +20,7 @@ TAP version 13
2020
# Subtest: test 2
2121
not ok 2 - test 2
2222
---
23-
duration_ms: ZERO
23+
duration_ms: *
2424
location: '/test/fixtures/test-runner/output/abort_hooks.js:(LINE):3'
2525
failureType: 'cancelledByParent'
2626
error: 'test did not finish before its parent and was cancelled'

‎test/fixtures/test-runner/output/abort_suite.snapshot

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ TAP version 13
3232
# Subtest: not ok 2
3333
not ok 6 - not ok 2
3434
---
35-
duration_ms: ZERO
35+
duration_ms: *
3636
location: '/test/fixtures/test-runner/output/abort_suite.js:(LINE):3'
3737
failureType: 'cancelledByParent'
3838
error: 'test did not finish before its parent and was cancelled'
@@ -41,7 +41,7 @@ TAP version 13
4141
# Subtest: not ok 3
4242
not ok 7 - not ok 3
4343
---
44-
duration_ms: ZERO
44+
duration_ms: *
4545
location: '/test/fixtures/test-runner/output/abort_suite.js:(LINE):3'
4646
failureType: 'testAborted'
4747
error: 'This operation was aborted'
@@ -62,7 +62,7 @@ TAP version 13
6262
# Subtest: not ok 4
6363
not ok 8 - not ok 4
6464
---
65-
duration_ms: ZERO
65+
duration_ms: *
6666
location: '/test/fixtures/test-runner/output/abort_suite.js:(LINE):3'
6767
failureType: 'testAborted'
6868
error: 'This operation was aborted'
@@ -83,7 +83,7 @@ TAP version 13
8383
# Subtest: not ok 5
8484
not ok 9 - not ok 5
8585
---
86-
duration_ms: ZERO
86+
duration_ms: *
8787
location: '/test/fixtures/test-runner/output/abort_suite.js:(LINE):3'
8888
failureType: 'testAborted'
8989
error: 'This operation was aborted'

‎test/fixtures/test-runner/output/arbitrary-output.snapshot

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
TAP version 13
22
ok 1 - test
33
---
4-
duration_ms: ZERO
4+
duration_ms: *
55
...
66
# arbitrary - pre
77
ok 2 - test
88
---
9-
duration_ms: ZERO
9+
duration_ms: *
1010
...
1111
# arbitrary - mid
1212
ok 3 - test
1313
---
14-
duration_ms: ZERO
14+
duration_ms: *
1515
...
1616
# arbitrary - post
1717
1..3

‎test/fixtures/test-runner/output/describe_it.snapshot

+2-2
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ not ok 51 - subtest sync throw fails
513513
# Subtest: should not run
514514
not ok 1 - should not run
515515
---
516-
duration_ms: ZERO
516+
duration_ms: *
517517
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):3'
518518
failureType: 'cancelledByParent'
519519
error: 'test did not finish before its parent and was cancelled'
@@ -544,7 +544,7 @@ not ok 52 - describe sync throw fails
544544
# Subtest: should not run
545545
not ok 1 - should not run
546546
---
547-
duration_ms: ZERO
547+
duration_ms: *
548548
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):3'
549549
failureType: 'cancelledByParent'
550550
error: 'test did not finish before its parent and was cancelled'

‎test/fixtures/test-runner/output/hooks.snapshot

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ ok 1 - describe hooks
3737
# Subtest: 1
3838
not ok 1 - 1
3939
---
40-
duration_ms: ZERO
40+
duration_ms: *
4141
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):3'
4242
failureType: 'cancelledByParent'
4343
error: 'test did not finish before its parent and was cancelled'
@@ -46,7 +46,7 @@ ok 1 - describe hooks
4646
# Subtest: 2
4747
not ok 2 - 2
4848
---
49-
duration_ms: ZERO
49+
duration_ms: *
5050
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):3'
5151
failureType: 'cancelledByParent'
5252
error: 'test did not finish before its parent and was cancelled'

‎test/fixtures/test-runner/output/unresolved_promise.snapshot

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ not ok 2 - never resolving promise
1818
# Subtest: fail
1919
not ok 3 - fail
2020
---
21-
duration_ms: ZERO
21+
duration_ms: *
2222
location: '/test/fixtures/test-runner/output/unresolved_promise.js:(LINE):1'
2323
failureType: 'cancelledByParent'
2424
error: 'Promise resolution is still pending but the event loop has already resolved'

‎test/parallel/test-runner-output.mjs

-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const skipForceColors =
1010

1111
function replaceTestDuration(str) {
1212
return str
13-
.replaceAll(/duration_ms: 0(\r?\n)/g, 'duration_ms: ZERO$1')
1413
.replaceAll(/duration_ms: [0-9.]+/g, 'duration_ms: *')
1514
.replaceAll(/duration_ms [0-9.]+/g, 'duration_ms *');
1615
}
@@ -20,15 +19,13 @@ const stackTraceBasePath = new RegExp(`${color}\\(${process.cwd()}/?${color}(.*)
2019

2120
function replaceSpecDuration(str) {
2221
return str
23-
.replaceAll(/\(0(\r?\n)ms\)/g, '(ZEROms)')
2422
.replaceAll(/[0-9.]+ms/g, '*ms')
2523
.replaceAll(/duration_ms [0-9.]+/g, 'duration_ms *')
2624
.replace(stackTraceBasePath, '$3');
2725
}
2826

2927
function replaceJunitDuration(str) {
3028
return str
31-
.replaceAll(/time="0"/g, 'time="ZERO"')
3229
.replaceAll(/time="[0-9.]+"/g, 'time="*"')
3330
.replaceAll(/duration_ms [0-9.]+/g, 'duration_ms *')
3431
.replaceAll(hostname(), 'HOSTNAME')

‎test/parallel/test-url-null-char.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ const assert = require('assert');
44

55
assert.throws(
66
() => { new URL('a\0b'); },
7-
{ input: 'a\0b' }
7+
{ code: 'ERR_INVALID_URL', input: 'a\0b' }
88
);

‎test/parallel/test-whatwg-url-custom-parsing.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ for (const test of failureTests) {
5555
() => new URL(test.input, test.base),
5656
(error) => {
5757
assert.throws(() => { throw error; }, expectedError);
58-
assert.strictEqual(`${error}`, 'TypeError [ERR_INVALID_URL]: Invalid URL');
58+
assert.strictEqual(`${error}`, 'TypeError: Invalid URL');
5959
assert.strictEqual(error.message, 'Invalid URL');
6060
return true;
6161
});

0 commit comments

Comments
 (0)
Please sign in to comment.