Skip to content

Commit 7d984d9

Browse files
committed
Update tooling script for detecting deadlocked tests.
1 parent 8bb6933 commit 7d984d9

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tools/find-deadlock-tests.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env node
2+
'use strict';
3+
4+
/* This script gets the output of ctest and returns
5+
* the non-finished tests or the failed ones, useful
6+
* for detecting deadlocks. Use it like:
7+
* $ node find-deadlock-tests.js ctest_output_file.txt
8+
*/
9+
10+
const { readFileSync } = require('fs');
11+
12+
if (!process.argv[2]) {
13+
console.error('No file specified');
14+
process.exit(1);
15+
}
16+
17+
const file = readFileSync(process.argv[2]);
18+
19+
if (!file) {
20+
console.error('Failed to read the file');
21+
process.exit(2);
22+
}
23+
24+
const tests = file.toString().split('\n').reduce((tests, line) => {
25+
const splitted = line.split(' ').filter(element => element);
26+
if (splitted[0] === 'Start') {
27+
tests.start.push(splitted[2]);
28+
} else if (splitted[5] === 'Passed') {
29+
tests.finish.push(splitted[3]);
30+
}
31+
return tests;
32+
}, { start: [], finish: [] });
33+
34+
const deadlock = tests.start.filter(x => !tests.finish.includes(x));
35+
36+
console.log(deadlock);

0 commit comments

Comments
 (0)