mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
(core) Move report-why-tests-hang helper to core
Summary: This helps forcibly end mocha tests when they hang, and print out something that may help debug the situation. Also add the generated static/bundle.css file to core/.gitignore. Also, avoid using npm-packages-offline-cache when building core, by avoiding use of .yarnrc which turns it on. Test Plan: Tested manually Reviewers: paulfitz Reviewed By: paulfitz Differential Revision: https://phab.getgrist.com/D2788
This commit is contained in:
parent
526b0ad33e
commit
fd73831b39
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,6 +2,7 @@
|
||||
/_build/
|
||||
/static/*.bundle.js
|
||||
/static/*.bundle.js.map
|
||||
/static/bundle.css
|
||||
|
||||
# Build helper files.
|
||||
/.build*
|
||||
|
@ -60,7 +60,8 @@
|
||||
"stats-webpack-plugin": "^0.7.0",
|
||||
"typescript": "3.9.3",
|
||||
"webpack": "4.41.0",
|
||||
"webpack-cli": "3.3.2"
|
||||
"webpack-cli": "3.3.2",
|
||||
"why-is-node-running": "2.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@gristlabs/connect-sqlite3": "0.9.11",
|
||||
|
@ -1,2 +1,3 @@
|
||||
--require source-map-support/register
|
||||
test/report-why-tests-hang
|
||||
test/init-mocha-webdriver
|
||||
|
34
test/report-why-tests-hang.js
Normal file
34
test/report-why-tests-hang.js
Normal file
@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Mocha 4 no longer forces exit of a process after tests end, so if a setTimeout() or anything
|
||||
* else is keeping node running, tests will hang after finishing.
|
||||
*
|
||||
* This helper module, always included via mocha.opts, ensures we print something if that happens.
|
||||
* We use why-is-node-running module to print something informative.
|
||||
*/
|
||||
|
||||
/* global after */
|
||||
|
||||
const whyIsNodeRunning = require('why-is-node-running');
|
||||
|
||||
function report() {
|
||||
whyIsNodeRunning();
|
||||
console.warn("*******************************************************");
|
||||
console.warn("Something above prevented node from exiting on its own.");
|
||||
console.warn("*******************************************************");
|
||||
// We want to exit, but process.exit(1) doesn't work, since mocha catches it and insists on
|
||||
// exiting with the test status result (which may be 0, and we need to indicate failure).
|
||||
process.kill(process.pid, 'SIGTERM');
|
||||
}
|
||||
|
||||
after(() => {
|
||||
// --no-exit|-E flag is interpreted by mocha-webdriver library to start REPL on failure, and we
|
||||
// do NOT want to output a big dump about that.
|
||||
const noexit = process.argv.includes("--no-exit") || process.argv.includes('-E');
|
||||
if (noexit) {
|
||||
console.log("report-why-tests-hang silenced with --no-exit flag");
|
||||
} else {
|
||||
// If still hanging after 5s after tests finish, say something. Unref() ensures that THIS
|
||||
// timeout doesn't itself keep node from exiting.
|
||||
setTimeout(report, 5000).unref();
|
||||
}
|
||||
});
|
12
yarn.lock
12
yarn.lock
@ -5957,6 +5957,11 @@ stack-trace@0.0.x:
|
||||
resolved "https://registry.yarnpkg.com/stack-trace/-/stack-trace-0.0.10.tgz#547c70b347e8d32b4e108ea1a2a159e5fdde19c0"
|
||||
integrity sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA=
|
||||
|
||||
stackback@0.0.2:
|
||||
version "0.0.2"
|
||||
resolved "https://registry.yarnpkg.com/stackback/-/stackback-0.0.2.tgz#1ac8a0d9483848d1695e418b6d031a3c3ce68e3b"
|
||||
integrity sha1-Gsig2Ug4SNFpXkGLbQMaPDzmjjs=
|
||||
|
||||
static-extend@^0.1.1:
|
||||
version "0.1.2"
|
||||
resolved "https://registry.yarnpkg.com/static-extend/-/static-extend-0.1.2.tgz#60809c39cbff55337226fd5e0b520f341f1fb5c6"
|
||||
@ -6894,6 +6899,13 @@ which@1.3.1, which@^1.2.14, which@^1.2.9:
|
||||
dependencies:
|
||||
isexe "^2.0.0"
|
||||
|
||||
why-is-node-running@2.0.3:
|
||||
version "2.0.3"
|
||||
resolved "https://registry.yarnpkg.com/why-is-node-running/-/why-is-node-running-2.0.3.tgz#86619c2861405d3509f55268684fc85e7f4ce145"
|
||||
integrity sha512-XmzbFN2T859avcs5qAsiiK1iu0nUpSUXRgiGsoHPcNijxhIlp1bPQWQk6ANUljDWqBtAbIR2jF1HxR0y2l2kCA==
|
||||
dependencies:
|
||||
stackback "0.0.2"
|
||||
|
||||
wide-align@1.1.3, wide-align@^1.1.0:
|
||||
version "1.1.3"
|
||||
resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.3.tgz#ae074e6bdc0c14a431e804e624549c633b000457"
|
||||
|
Loading…
Reference in New Issue
Block a user