Skip to content

Commit 2181da3

Browse files
committed
try to catch busy hanging
1 parent c0136e0 commit 2181da3

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/TestCases.template.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ const describeCases = config => {
7979
testName
8080
);
8181
const log = [];
82+
let startTime = 0;
8283
const options = {
8384
context: casesPath,
8485
entry: "./" + category.name + "/" + testName + "/index",
@@ -163,22 +164,34 @@ const describeCases = config => {
163164
});
164165
}, new webpack.ProgressPlugin((...args) => {
165166
log.push(args);
167+
if(startTime && startTime + 50000 > Date.now()) {
168+
process.stdout.write(`\n\nBUSY HANGING ${config.name} ${category.name} ${testName}\n`);
169+
for(const line of log) {
170+
process.stdout.write(line.join(" ") + "\n");
171+
}
172+
process.stdout.write(`\n\n\n`);
173+
log.length = 0;
174+
throw new Error("Compilation is busy hanging");
175+
}
166176
}))
167177
};
168178
it(
169179
testName + " should compile",
170180
done => {
181+
startTime = Date.now();
171182
const timeout = setTimeout(() => {
172183
process.stdout.write(`\n\nHANGING ${config.name} ${category.name} ${testName}\n`);
173184
for(const line of log) {
174185
process.stdout.write(line.join(" ") + "\n");
175186
}
176187
process.stdout.write(`\n\n\n`);
188+
log.length = 0;
177189
done(new Error("Compilation is hanging"));
178190
}, 50000);
179191
const exportedTests = [];
180192
webpack(options, (err, stats) => {
181193
clearTimeout(timeout);
194+
startTime = 0;
182195
if (err) done(err);
183196
const statOptions = Stats.presetToOptions("verbose");
184197
statOptions.colors = false;

0 commit comments

Comments
 (0)