diff options
author | Luke Karrys <luke@lukekarrys.com> | 2021-11-27 18:08:06 +0300 |
---|---|---|
committer | Luke Karrys <luke@lukekarrys.com> | 2021-12-02 03:43:08 +0300 |
commit | 6734ba36dd6e07a859ab4d6eb4f264d2c0022276 (patch) | |
tree | b21a5c01d1661b4384a2251d801a590c9e14dc13 /tap-snapshots | |
parent | 037f2cc8c8ed9d9a092475a5a07f2a3a88915633 (diff) |
feat: streaming debug logfile
This decouples the log file writing from the terminal logging. We now
open an append only file at the start of the process and stream logs to
it. We still only display the log file message in timing mode or if
there is an error, but the file is still written regardless.
All logging now goes through `proc-log` and this is the first step to
removing `npmlog`. For now `npmlog` is still used for the terminal
logging but with a shim in front of it to make it easier to test and
use in conjunction with `proc-log`. Ref: npm/statusboard#366
This also refactors many of the tests to always use an explicit
`t.testdir` for their cache since the file is opened on each `new Npm()`.
Tests are also refactored to use more of `MockNpm` with behavior to
add config items and load `npm` if necessary. A new fixture `mockGlobals`
was also added to make much of this more ergonomic. Ref: npm/statusboard#410
Closes npm/statusboard#411
Closes npm/statusboard#367
PR-URL: https://github.com/npm/cli/pull/4062
Credit: @lukekarrys
Close: #4062
Reviewed-by: @wraithgar
Diffstat (limited to 'tap-snapshots')
6 files changed, 222 insertions, 75 deletions
diff --git a/tap-snapshots/test/lib/commands/config.js.test.cjs b/tap-snapshots/test/lib/commands/config.js.test.cjs index 814f6de7c..da7a89bae 100644 --- a/tap-snapshots/test/lib/commands/config.js.test.cjs +++ b/tap-snapshots/test/lib/commands/config.js.test.cjs @@ -9,6 +9,7 @@ exports[`test/lib/commands/config.js TAP config list --json > output matches sna { "prefix": "{LOCALPREFIX}", "userconfig": "{HOME}/.npmrc", + "cache": "{NPMDIR}/test/lib/commands/tap-testdir-config-config-list---json-sandbox/cache", "json": true, "projectloaded": "yes", "userloaded": "yes", @@ -24,7 +25,6 @@ exports[`test/lib/commands/config.js TAP config list --json > output matches sna "bin-links": true, "browser": null, "ca": null, - "cache": "{CACHE}", "cache-max": null, "cache-min": 0, "cafile": null, @@ -175,7 +175,7 @@ before = null bin-links = true browser = null ca = null -cache = "{CACHE}" +; cache = "{CACHE}" ; overridden by cli cache-max = null cache-min = 0 cafile = null @@ -324,6 +324,7 @@ projectloaded = "yes" ; "cli" config from command line options +cache = "{NPMDIR}/test/lib/commands/tap-testdir-config-config-list---long-sandbox/cache" long = true prefix = "{LOCALPREFIX}" userconfig = "{HOME}/.npmrc" @@ -332,6 +333,7 @@ userconfig = "{HOME}/.npmrc" exports[`test/lib/commands/config.js TAP config list > output matches snapshot 1`] = ` ; "cli" config from command line options +cache = "{NPMDIR}/test/lib/commands/tap-testdir-config-config-list-sandbox/cache" prefix = "{LOCALPREFIX}" userconfig = "{HOME}/.npmrc" diff --git a/tap-snapshots/test/lib/commands/shrinkwrap.js.test.cjs b/tap-snapshots/test/lib/commands/shrinkwrap.js.test.cjs index a0d579577..ddc80a935 100644 --- a/tap-snapshots/test/lib/commands/shrinkwrap.js.test.cjs +++ b/tap-snapshots/test/lib/commands/shrinkwrap.js.test.cjs @@ -16,7 +16,7 @@ exports[`test/lib/commands/shrinkwrap.js TAP with hidden lockfile ancient > must }, "config": {}, "shrinkwrap": { - "name": "tap-testdir-shrinkwrap-with-hidden-lockfile-ancient", + "name": "root", "lockfileVersion": 1, "requires": true }, @@ -36,10 +36,10 @@ exports[`test/lib/commands/shrinkwrap.js TAP with hidden lockfile ancient upgrad } }, "config": { - "lockfileVersion": 3 + "lockfile-version": 3 }, "shrinkwrap": { - "name": "tap-testdir-shrinkwrap-with-hidden-lockfile-ancient-upgrade", + "name": "root", "lockfileVersion": 3, "requires": true, "packages": {} @@ -61,7 +61,7 @@ exports[`test/lib/commands/shrinkwrap.js TAP with hidden lockfile existing > mus }, "config": {}, "shrinkwrap": { - "name": "tap-testdir-shrinkwrap-with-hidden-lockfile-existing", + "name": "root", "lockfileVersion": 2, "requires": true, "packages": {} @@ -82,10 +82,10 @@ exports[`test/lib/commands/shrinkwrap.js TAP with hidden lockfile existing downg } }, "config": { - "lockfileVersion": 1 + "lockfile-version": 1 }, "shrinkwrap": { - "name": "tap-testdir-shrinkwrap-with-hidden-lockfile-existing-downgrade", + "name": "root", "lockfileVersion": 1, "requires": true }, @@ -105,10 +105,10 @@ exports[`test/lib/commands/shrinkwrap.js TAP with hidden lockfile existing upgra } }, "config": { - "lockfileVersion": 3 + "lockfile-version": 3 }, "shrinkwrap": { - "name": "tap-testdir-shrinkwrap-with-hidden-lockfile-existing-upgrade", + "name": "root", "lockfileVersion": 3, "requires": true, "packages": {} @@ -124,7 +124,7 @@ exports[`test/lib/commands/shrinkwrap.js TAP with nothing ancient > must match s "localPrefix": {}, "config": {}, "shrinkwrap": { - "name": "tap-testdir-shrinkwrap-with-nothing-ancient", + "name": "root", "lockfileVersion": 2, "requires": true, "packages": {} @@ -139,10 +139,10 @@ exports[`test/lib/commands/shrinkwrap.js TAP with nothing ancient upgrade > must { "localPrefix": {}, "config": { - "lockfileVersion": 3 + "lockfile-version": 3 }, "shrinkwrap": { - "name": "tap-testdir-shrinkwrap-with-nothing-ancient-upgrade", + "name": "root", "lockfileVersion": 3, "requires": true, "packages": {} @@ -162,12 +162,12 @@ exports[`test/lib/commands/shrinkwrap.js TAP with npm-shrinkwrap.json ancient > }, "config": {}, "shrinkwrap": { - "name": "tap-testdir-shrinkwrap-with-npm-shrinkwrap.json-ancient", + "name": "root", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "tap-testdir-shrinkwrap-with-npm-shrinkwrap.json-ancient" + "name": "root" } } }, @@ -185,15 +185,15 @@ exports[`test/lib/commands/shrinkwrap.js TAP with npm-shrinkwrap.json ancient up } }, "config": { - "lockfileVersion": 3 + "lockfile-version": 3 }, "shrinkwrap": { - "name": "tap-testdir-shrinkwrap-with-npm-shrinkwrap.json-ancient-upgrade", + "name": "root", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "tap-testdir-shrinkwrap-with-npm-shrinkwrap.json-ancient-upgrade" + "name": "root" } } }, @@ -212,12 +212,12 @@ exports[`test/lib/commands/shrinkwrap.js TAP with npm-shrinkwrap.json existing > }, "config": {}, "shrinkwrap": { - "name": "tap-testdir-shrinkwrap-with-npm-shrinkwrap.json-existing", + "name": "root", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "tap-testdir-shrinkwrap-with-npm-shrinkwrap.json-existing" + "name": "root" } } }, @@ -235,10 +235,10 @@ exports[`test/lib/commands/shrinkwrap.js TAP with npm-shrinkwrap.json existing d } }, "config": { - "lockfileVersion": 1 + "lockfile-version": 1 }, "shrinkwrap": { - "name": "tap-testdir-shrinkwrap-with-npm-shrinkwrap.json-existing-downgrade", + "name": "root", "lockfileVersion": 1, "requires": true }, @@ -256,15 +256,15 @@ exports[`test/lib/commands/shrinkwrap.js TAP with npm-shrinkwrap.json existing u } }, "config": { - "lockfileVersion": 3 + "lockfile-version": 3 }, "shrinkwrap": { - "name": "tap-testdir-shrinkwrap-with-npm-shrinkwrap.json-existing-upgrade", + "name": "root", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "tap-testdir-shrinkwrap-with-npm-shrinkwrap.json-existing-upgrade" + "name": "root" } } }, @@ -283,12 +283,12 @@ exports[`test/lib/commands/shrinkwrap.js TAP with package-lock.json ancient > mu }, "config": {}, "shrinkwrap": { - "name": "tap-testdir-shrinkwrap-with-package-lock.json-ancient", + "name": "root", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "tap-testdir-shrinkwrap-with-package-lock.json-ancient" + "name": "root" } } }, @@ -306,15 +306,15 @@ exports[`test/lib/commands/shrinkwrap.js TAP with package-lock.json ancient upgr } }, "config": { - "lockfileVersion": 3 + "lockfile-version": 3 }, "shrinkwrap": { - "name": "tap-testdir-shrinkwrap-with-package-lock.json-ancient-upgrade", + "name": "root", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "tap-testdir-shrinkwrap-with-package-lock.json-ancient-upgrade" + "name": "root" } } }, @@ -333,12 +333,12 @@ exports[`test/lib/commands/shrinkwrap.js TAP with package-lock.json existing > m }, "config": {}, "shrinkwrap": { - "name": "tap-testdir-shrinkwrap-with-package-lock.json-existing", + "name": "root", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "tap-testdir-shrinkwrap-with-package-lock.json-existing" + "name": "root" } } }, @@ -356,10 +356,10 @@ exports[`test/lib/commands/shrinkwrap.js TAP with package-lock.json existing dow } }, "config": { - "lockfileVersion": 1 + "lockfile-version": 1 }, "shrinkwrap": { - "name": "tap-testdir-shrinkwrap-with-package-lock.json-existing-downgrade", + "name": "root", "lockfileVersion": 1, "requires": true }, @@ -377,15 +377,15 @@ exports[`test/lib/commands/shrinkwrap.js TAP with package-lock.json existing upg } }, "config": { - "lockfileVersion": 3 + "lockfile-version": 3 }, "shrinkwrap": { - "name": "tap-testdir-shrinkwrap-with-package-lock.json-existing-upgrade", + "name": "root", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "tap-testdir-shrinkwrap-with-package-lock.json-existing-upgrade" + "name": "root" } } }, diff --git a/tap-snapshots/test/lib/commands/view.js.test.cjs b/tap-snapshots/test/lib/commands/view.js.test.cjs index 10d38cb3f..72d09b44e 100644 --- a/tap-snapshots/test/lib/commands/view.js.test.cjs +++ b/tap-snapshots/test/lib/commands/view.js.test.cjs @@ -82,7 +82,7 @@ dist dist-tags: [1m[32mlatest[39m[22m: 1.0.0 -published [33myesterday[39m +published {TIME} ago[39m ` exports[`test/lib/commands/view.js TAP should log info of package in current working dir specific version > must match snapshot 1`] = ` @@ -99,7 +99,7 @@ dist dist-tags: [1m[32mlatest[39m[22m: 1.0.0 -published [33myesterday[39m +published {TIME} ago[39m ` exports[`test/lib/commands/view.js TAP should log package info package from git > must match snapshot 1`] = ` @@ -302,7 +302,7 @@ dist dist-tags: [1m[32mlatest[39m[22m: 1.0.0 -published [33myesterday[39m +published {TIME} ago[39m ` exports[`test/lib/commands/view.js TAP should log package info package with semver range > must match snapshot 1`] = ` @@ -319,7 +319,7 @@ dist dist-tags: [1m[32mlatest[39m[22m: 1.0.0 -published [33myesterday[39m +published {TIME} ago[39m [4m[1m[32mblue[39m@[32m1.0.1[39m[22m[24m | [1m[31mProprietary[39m[22m | deps: [32mnone[39m | versions: [33m2[39m diff --git a/tap-snapshots/test/lib/utils/error-message.js.test.cjs b/tap-snapshots/test/lib/utils/error-message.js.test.cjs index e4efb0eb9..3b82e3c05 100644 --- a/tap-snapshots/test/lib/utils/error-message.js.test.cjs +++ b/tap-snapshots/test/lib/utils/error-message.js.test.cjs @@ -255,7 +255,7 @@ Object { "summary": Array [ Array [ "notsup", - "Unsupported platform for lodash@1.0.0: wanted {\\"os\\":\\"!yours,mine\\",\\"arch\\":\\"x867,x5309\\"} (current: {\\"os\\":\\"posix\\",\\"arch\\":\\"x64\\"})", + "Unsupported platform for lodash@1.0.0: wanted {/"os/":/"!yours,mine/",/"arch/":/"x867,x5309/"} (current: {/"os/":/"posix/",/"arch/":/"x64/"})", ], ], } @@ -277,7 +277,7 @@ Object { "summary": Array [ Array [ "notsup", - "Unsupported platform for lodash@1.0.0: wanted {\\"os\\":\\"!yours\\",\\"arch\\":\\"x420\\"} (current: {\\"os\\":\\"posix\\",\\"arch\\":\\"x64\\"})", + "Unsupported platform for lodash@1.0.0: wanted {/"os/":/"!yours/",/"arch/":/"x420/"} (current: {/"os/":/"posix/",/"arch/":/"x64/"})", ], ], } @@ -394,7 +394,7 @@ Object { "", Error: whoopsie { "code": "EACCES", - "dest": "/some/cache/dir/dest", + "dest": "{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-false-loaded-false-cachePath-false-cacheDest-true-/cache/dest", "path": "/not/cache/dir/path", }, ], @@ -428,7 +428,7 @@ Object { Error: whoopsie { "code": "EACCES", "dest": "/not/cache/dir/dest", - "path": "/some/cache/dir/path", + "path": "{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-false-loaded-false-cachePath-true-cacheDest-false-/cache/path", }, ], ], @@ -460,8 +460,8 @@ Object { "", Error: whoopsie { "code": "EACCES", - "dest": "/some/cache/dir/dest", - "path": "/some/cache/dir/path", + "dest": "{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-false-loaded-false-cachePath-true-cacheDest-true-/cache/dest", + "path": "{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-false-loaded-false-cachePath-true-cacheDest-true-/cache/path", }, ], ], @@ -502,7 +502,12 @@ Object { ` exports[`test/lib/utils/error-message.js TAP eacces/eperm {"windows":false,"loaded":true,"cachePath":false,"cacheDest":false} > must match snapshot 2`] = ` -Array [] +Array [ + Array [ + "logfile", + "{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-false-loaded-true-cachePath-false-cacheDest-false-/cache/_logs/{DATE}-debug-0.log", + ], +] ` exports[`test/lib/utils/error-message.js TAP eacces/eperm {"windows":false,"loaded":true,"cachePath":false,"cacheDest":true} > must match snapshot 1`] = ` @@ -517,7 +522,7 @@ Object { previous versions of npm which has since been addressed. To permanently fix this problem, please run: - sudo chown -R 867:5309 "/some/cache/dir" + sudo chown -R 867:5309 "{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-false-loaded-true-cachePath-false-cacheDest-true-/cache" ), ], ], @@ -527,6 +532,10 @@ Object { exports[`test/lib/utils/error-message.js TAP eacces/eperm {"windows":false,"loaded":true,"cachePath":false,"cacheDest":true} > must match snapshot 2`] = ` Array [ Array [ + "logfile", + "{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-false-loaded-true-cachePath-false-cacheDest-true-/cache/_logs/{DATE}-debug-0.log", + ], + Array [ "dummy stack trace", ], ] @@ -544,7 +553,7 @@ Object { previous versions of npm which has since been addressed. To permanently fix this problem, please run: - sudo chown -R 867:5309 "/some/cache/dir" + sudo chown -R 867:5309 "{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-false-loaded-true-cachePath-true-cacheDest-false-/cache" ), ], ], @@ -554,6 +563,10 @@ Object { exports[`test/lib/utils/error-message.js TAP eacces/eperm {"windows":false,"loaded":true,"cachePath":true,"cacheDest":false} > must match snapshot 2`] = ` Array [ Array [ + "logfile", + "{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-false-loaded-true-cachePath-true-cacheDest-false-/cache/_logs/{DATE}-debug-0.log", + ], + Array [ "dummy stack trace", ], ] @@ -571,7 +584,7 @@ Object { previous versions of npm which has since been addressed. To permanently fix this problem, please run: - sudo chown -R 867:5309 "/some/cache/dir" + sudo chown -R 867:5309 "{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-false-loaded-true-cachePath-true-cacheDest-true-/cache" ), ], ], @@ -581,6 +594,10 @@ Object { exports[`test/lib/utils/error-message.js TAP eacces/eperm {"windows":false,"loaded":true,"cachePath":true,"cacheDest":true} > must match snapshot 2`] = ` Array [ Array [ + "logfile", + "{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-false-loaded-true-cachePath-true-cacheDest-true-/cache/_logs/{DATE}-debug-0.log", + ], + Array [ "dummy stack trace", ], ] @@ -642,7 +659,7 @@ Object { "", Error: whoopsie { "code": "EACCES", - "dest": "/some/cache/dir/dest", + "dest": "{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-true-loaded-false-cachePath-false-cacheDest-true-/cache/dest", "path": "/not/cache/dir/path", }, ], @@ -677,7 +694,7 @@ Object { Error: whoopsie { "code": "EACCES", "dest": "/not/cache/dir/dest", - "path": "/some/cache/dir/path", + "path": "{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-true-loaded-false-cachePath-true-cacheDest-false-/cache/path", }, ], ], @@ -710,8 +727,8 @@ Object { "", Error: whoopsie { "code": "EACCES", - "dest": "/some/cache/dir/dest", - "path": "/some/cache/dir/path", + "dest": "{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-true-loaded-false-cachePath-true-cacheDest-true-/cache/dest", + "path": "{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-true-loaded-false-cachePath-true-cacheDest-true-/cache/path", }, ], ], @@ -753,7 +770,12 @@ Object { ` exports[`test/lib/utils/error-message.js TAP eacces/eperm {"windows":true,"loaded":true,"cachePath":false,"cacheDest":false} > must match snapshot 2`] = ` -Array [] +Array [ + Array [ + "logfile", + "{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-true-loaded-true-cachePath-false-cacheDest-false-/cache/_logs/{DATE}-debug-0.log", + ], +] ` exports[`test/lib/utils/error-message.js TAP eacces/eperm {"windows":true,"loaded":true,"cachePath":false,"cacheDest":true} > must match snapshot 1`] = ` @@ -778,7 +800,7 @@ Object { "", Error: whoopsie { "code": "EACCES", - "dest": "/some/cache/dir/dest", + "dest": "{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-true-loaded-true-cachePath-false-cacheDest-true-/cache/dest", "path": "/not/cache/dir/path", }, ], @@ -787,7 +809,12 @@ Object { ` exports[`test/lib/utils/error-message.js TAP eacces/eperm {"windows":true,"loaded":true,"cachePath":false,"cacheDest":true} > must match snapshot 2`] = ` -Array [] +Array [ + Array [ + "logfile", + "{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-true-loaded-true-cachePath-false-cacheDest-true-/cache/_logs/{DATE}-debug-0.log", + ], +] ` exports[`test/lib/utils/error-message.js TAP eacces/eperm {"windows":true,"loaded":true,"cachePath":true,"cacheDest":false} > must match snapshot 1`] = ` @@ -813,7 +840,7 @@ Object { Error: whoopsie { "code": "EACCES", "dest": "/not/cache/dir/dest", - "path": "/some/cache/dir/path", + "path": "{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-true-loaded-true-cachePath-true-cacheDest-false-/cache/path", }, ], ], @@ -821,7 +848,12 @@ Object { ` exports[`test/lib/utils/error-message.js TAP eacces/eperm {"windows":true,"loaded":true,"cachePath":true,"cacheDest":false} > must match snapshot 2`] = ` -Array [] +Array [ + Array [ + "logfile", + "{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-true-loaded-true-cachePath-true-cacheDest-false-/cache/_logs/{DATE}-debug-0.log", + ], +] ` exports[`test/lib/utils/error-message.js TAP eacces/eperm {"windows":true,"loaded":true,"cachePath":true,"cacheDest":true} > must match snapshot 1`] = ` @@ -846,8 +878,8 @@ Object { "", Error: whoopsie { "code": "EACCES", - "dest": "/some/cache/dir/dest", - "path": "/some/cache/dir/path", + "dest": "{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-true-loaded-true-cachePath-true-cacheDest-true-/cache/dest", + "path": "{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-true-loaded-true-cachePath-true-cacheDest-true-/cache/path", }, ], ], @@ -855,7 +887,12 @@ Object { ` exports[`test/lib/utils/error-message.js TAP eacces/eperm {"windows":true,"loaded":true,"cachePath":true,"cacheDest":true} > must match snapshot 2`] = ` -Array [] +Array [ + Array [ + "logfile", + "{CWD}/test/lib/utils/tap-testdir-error-message-eacces-eperm--windows-true-loaded-true-cachePath-true-cacheDest-true-/cache/_logs/{DATE}-debug-0.log", + ], +] ` exports[`test/lib/utils/error-message.js TAP enoent without a file > must match snapshot 1`] = ` @@ -863,7 +900,7 @@ Object { "detail": Array [ Array [ "enoent", - "This is related to npm not being able to find a file.\\n", + "This is related to npm not being able to find a file./n", ], ], "summary": Array [ diff --git a/tap-snapshots/test/lib/utils/exit-handler.js.test.cjs b/tap-snapshots/test/lib/utils/exit-handler.js.test.cjs index eb383c104..523aabca2 100644 --- a/tap-snapshots/test/lib/utils/exit-handler.js.test.cjs +++ b/tap-snapshots/test/lib/utils/exit-handler.js.test.cjs @@ -5,16 +5,56 @@ * Make sure to inspect the output below. Do not ignore changes! */ 'use strict' -exports[`test/lib/utils/exit-handler.js TAP handles unknown error > should have expected log contents for unknown error 1`] = ` -24 verbose stack Error: ERROR -25 verbose cwd {CWD} -26 verbose Foo 1.0.0 -27 verbose argv "/node" "{CWD}/test/lib/utils/exit-handler.js" -28 verbose node v1.0.0 -29 verbose npm v1.0.0 -30 error code ERROR -31 error ERR ERROR -32 error ERR ERROR -33 verbose exit 1 +exports[`test/lib/utils/exit-handler.js TAP handles unknown error with logs and debug file > debug file contents 1`] = ` +0 timing npm:load:whichnode Completed in {TIME}ms +15 timing config:load Completed in {TIME}ms +16 timing npm:load:configload Completed in {TIME}ms +17 timing npm:load:setTitle Completed in {TIME}ms +19 timing npm:load:display Completed in {TIME}ms +20 verbose logfile {CWD}/test/lib/utils/tap-testdir-exit-handler-handles-unknown-error-with-logs-and-debug-file/cache/_logs/{DATE}-debug-0.log +21 timing npm:load:logFile Completed in {TIME}ms +22 timing npm:load:timers Completed in {TIME}ms +23 timing npm:load:configScope Completed in {TIME}ms +24 timing npm:load Completed in {TIME}ms +25 verbose stack Error: Unknown error +26 verbose cwd {CWD} +27 verbose Foo 1.0.0 +28 verbose argv "/node" "{CWD}/test/lib/utils/exit-handler.js" +29 verbose node v1.0.0 +30 verbose npm v1.0.0 +31 error code ECODE +32 error ERR SUMMARY Unknown error +33 error ERR DETAIL Unknown error +34 verbose exit 1 +35 timing npm Completed in {TIME}ms +36 verbose code 1 +37 error A complete log of this run can be found in: +37 error {CWD}/test/lib/utils/tap-testdir-exit-handler-handles-unknown-error-with-logs-and-debug-file/cache/_logs/{DATE}-debug-0.log +` +exports[`test/lib/utils/exit-handler.js TAP handles unknown error with logs and debug file > logs 1`] = ` +timing npm:load:whichnode Completed in {TIME}ms +timing config:load Completed in {TIME}ms +timing npm:load:configload Completed in {TIME}ms +timing npm:load:setTitle Completed in {TIME}ms +timing npm:load:display Completed in {TIME}ms +verbose logfile {CWD}/test/lib/utils/tap-testdir-exit-handler-handles-unknown-error-with-logs-and-debug-file/cache/_logs/{DATE}-debug-0.log +timing npm:load:logFile Completed in {TIME}ms +timing npm:load:timers Completed in {TIME}ms +timing npm:load:configScope Completed in {TIME}ms +timing npm:load Completed in {TIME}ms +verbose stack Error: Unknown error +verbose cwd {CWD} +verbose Foo 1.0.0 +verbose argv "/node" "{CWD}/test/lib/utils/exit-handler.js" +verbose node v1.0.0 +verbose npm v1.0.0 +error code ECODE +error ERR SUMMARY Unknown error +error ERR DETAIL Unknown error +verbose exit 1 +timing npm Completed in {TIME}ms +verbose code 1 +error A complete log of this run can be found in: + {CWD}/test/lib/utils/tap-testdir-exit-handler-handles-unknown-error-with-logs-and-debug-file/cache/_logs/{DATE}-debug-0.log ` diff --git a/tap-snapshots/test/lib/utils/log-file.js.test.cjs b/tap-snapshots/test/lib/utils/log-file.js.test.cjs new file mode 100644 index 000000000..ecce9eafc --- /dev/null +++ b/tap-snapshots/test/lib/utils/log-file.js.test.cjs @@ -0,0 +1,68 @@ +/* IMPORTANT + * This snapshot file is auto-generated, but designed for humans. + * It should be checked into source control and tracked carefully. + * Re-generate by setting TAP_SNAPSHOT=1 and running tests. + * Make sure to inspect the output below. Do not ignore changes! + */ +'use strict' +exports[`test/lib/utils/log-file.js TAP snapshot > must match snapshot 1`] = ` +0 error no prefix +1 error prefix with prefix +2 error prefix 1 2 3 +3 verbose { obj: { with: { many: [Object] } } } +4 verbose {"obj":{"with":{"many":{"props":1}}}} +5 verbose { +5 verbose "obj": { +5 verbose "with": { +5 verbose "many": { +5 verbose "props": 1 +5 verbose } +5 verbose } +5 verbose } +5 verbose } +6 verbose [ 'test', 'with', 'an', 'array' ] +7 verbose ["test","with","an","array"] +8 verbose [ +8 verbose "test", +8 verbose "with", +8 verbose "an", +8 verbose "array" +8 verbose ] +9 verbose [ 'test', [ 'with', [ 'an', [Array] ] ] ] +10 verbose ["test",["with",["an",["array"]]]] +11 verbose [ +11 verbose "test", +11 verbose [ +11 verbose "with", +11 verbose [ +11 verbose "an", +11 verbose [ +11 verbose "array" +11 verbose ] +11 verbose ] +11 verbose ] +11 verbose ] +12 error pre has many errors Error: message +12 error pre at stack trace line 0 +12 error pre at stack trace line 1 +12 error pre at stack trace line 2 +12 error pre at stack trace line 3 +12 error pre at stack trace line 4 +12 error pre at stack trace line 5 +12 error pre at stack trace line 6 +12 error pre at stack trace line 7 +12 error pre at stack trace line 8 +12 error pre at stack trace line 9 Error: message2 +12 error pre at stack trace line 0 +12 error pre at stack trace line 1 +12 error pre at stack trace line 2 +12 error pre at stack trace line 3 +12 error pre at stack trace line 4 +12 error pre at stack trace line 5 +12 error pre at stack trace line 6 +12 error pre at stack trace line 7 +12 error pre at stack trace line 8 +12 error pre at stack trace line 9 +13 error nostack [Error: message] + +` |