Skip to content

Commit

Permalink
fixup! cli: implement --trace-env and --trace-env-[js|native]-stack
Browse files Browse the repository at this point in the history
  • Loading branch information
joyeecheung committed Nov 19, 2024
1 parent 8a50cef commit 2553316
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
3 changes: 1 addition & 2 deletions test/parallel/test-trace-env-stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ const fixtures = require('../common/fixtures');
spawnSyncAndAssert(process.execPath, ['--trace-env-native-stack', fixtures.path('empty.js')], {
stderr(output) {
if (output.includes('PrintTraceEnvStack')) { // Some platforms do not support back traces.
assert.match(output, /node::credentials::SafeGetenv/);
assert.match(output, /node::EnvGetter/);
assert.match(output, /node::credentials::SafeGetenv/); // This is usually not optimized away.
}
}
});
Expand Down
20 changes: 15 additions & 5 deletions test/parallel/test-trace-env.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

// This tests that --trace-env works.
require('../common');
const common = require('../common');
const { spawnSyncAndAssert } = require('../common/child_process');
const assert = require('assert');
const fixtures = require('../common/fixtures');
Expand All @@ -13,17 +13,27 @@ spawnSyncAndAssert(process.execPath, ['--trace-env', fixtures.path('empty.js')],
// during startup of an empty script at the time this test was written.
// If the internals remove any one of them, the checks here can be updated
// accordingly.
assert.match(output, /get environment variable "NODE_ICU_DATA":/);
assert.match(output, /get environment variable "OPENSSL_CONF":/);
assert.match(output, /get environment variable "NODE_EXTRA_CA_CERTS":/);
if (common.hasIntl) {
assert.match(output, /get environment variable "NODE_ICU_DATA":/);
}
if (common.hasOpenSSL) {
assert.match(output, /get environment variable "NODE_EXTRA_CA_CERTS":/);
}
if (common.hasOpenSSL3) {
assert.match(output, /get environment variable "OPENSSL_CONF":/);
}
assert.match(output, /get environment variable "NODE_DEBUG_NATIVE":/);
assert.match(output, /get environment variable "NODE_COMPILE_CACHE":/);
assert.match(output, /get environment variable "NODE_NO_WARNINGS":/);
assert.match(output, /get environment variable "NODE_V8_COVERAGE":/);
assert.match(output, /get environment variable "NODE_DEBUG":/);
assert.match(output, /get environment variable "NODE_CHANNEL_FD":/);
assert.match(output, /get environment variable "NODE_UNIQUE_ID":/);
assert.match(output, /get environment variable "HOME":/);
if (common.isWindows) {
assert.match(output, /get environment variable "USERPROFILE":/);
} else {
assert.match(output, /get environment variable "HOME":/);
}
assert.match(output, /get environment variable "NODE_PATH":/);
assert.match(output, /get environment variable "WATCH_REPORT_DEPENDENCIES":/);
}
Expand Down

0 comments on commit 2553316

Please sign in to comment.