mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +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:
@@ -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();
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user