Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9506f77

Browse filesBrowse files
avivkellertargos
authored andcommitted
test: remove getCallSite from common
PR-URL: #54947 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 79ffefa commit 9506f77
Copy full SHA for 9506f77

File tree

Expand file treeCollapse file tree

3 files changed

+3
-25
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+3
-25
lines changed
Open diff view settings
Collapse file

‎test/common/README.md‎

Copy file name to clipboardExpand all lines: test/common/README.md
-7Lines changed: 0 additions & 7 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,6 @@ Returns an instance of all possible `ArrayBufferView`s of the provided Buffer.
187187
Returns an instance of all possible `BufferSource`s of the provided Buffer,
188188
consisting of all `ArrayBufferView` and an `ArrayBuffer`.
189189

190-
### `getCallSite(func)`
191-
192-
* `func` [\<Function>][<Function>]
193-
* return [\<string>][<string>]
194-
195-
Returns the file name and line number for the provided Function.
196-
197190
### `getTTYfd()`
198191

199192
Attempts to get a valid TTY file descriptor. Returns `-1` if it fails.
Collapse file

‎test/common/index.js‎

Copy file name to clipboardExpand all lines: test/common/index.js
+3-16Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const net = require('net');
3030
// Do not require 'os' until needed so that test-os-checked-function can
3131
// monkey patch it. If 'os' is required here, that test will fail.
3232
const path = require('path');
33-
const { inspect } = require('util');
33+
const { inspect, getCallSite } = require('util');
3434
const { isMainThread } = require('worker_threads');
3535
const { isModuleNamespaceObject } = require('util/types');
3636

@@ -551,25 +551,13 @@ function canCreateSymLink() {
551551
return true;
552552
}
553553

554-
function getCallSite(top) {
555-
const originalStackFormatter = Error.prepareStackTrace;
556-
Error.prepareStackTrace = (err, stack) =>
557-
`${stack[0].getFileName()}:${stack[0].getLineNumber()}`;
558-
const err = new Error();
559-
Error.captureStackTrace(err, top);
560-
// With the V8 Error API, the stack is not formatted until it is accessed
561-
err.stack; // eslint-disable-line no-unused-expressions
562-
Error.prepareStackTrace = originalStackFormatter;
563-
return err.stack;
564-
}
565-
566554
function mustNotCall(msg) {
567-
const callSite = getCallSite(mustNotCall);
555+
const callSite = getCallSite()[1];
568556
return function mustNotCall(...args) {
569557
const argsInfo = args.length > 0 ?
570558
`\ncalled with arguments: ${args.map((arg) => inspect(arg)).join(', ')}` : '';
571559
assert.fail(
572-
`${msg || 'function should not have been called'} at ${callSite}` +
560+
`${msg || 'function should not have been called'} at ${callSite.scriptName}:${callSite.lineNumber}` +
573561
argsInfo);
574562
};
575563
}
@@ -968,7 +956,6 @@ const common = {
968956
expectWarning,
969957
getArrayBufferViews,
970958
getBufferSources,
971-
getCallSite,
972959
getPrintedStackTrace,
973960
getTTYfd,
974961
hasIntl,
Collapse file

‎test/common/index.mjs‎

Copy file name to clipboardExpand all lines: test/common/index.mjs
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ const {
1515
expectWarning,
1616
getArrayBufferViews,
1717
getBufferSources,
18-
getCallSite,
1918
getTTYfd,
2019
hasCrypto,
2120
hasIntl,
@@ -69,7 +68,6 @@ export {
6968
expectWarning,
7069
getArrayBufferViews,
7170
getBufferSources,
72-
getCallSite,
7371
getPort,
7472
getTTYfd,
7573
hasCrypto,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.