Skip to content

Commit 7b25799

Browse files
committed
Automatic bisecting script
1 parent 1e8e65c commit 7b25799

2 files changed

Lines changed: 78 additions & 0 deletions

File tree

scripts/bisect-test.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/// <reference path="..\src\harness\external\node.d.ts" />
2+
3+
import cp = require('child_process');
4+
import fs = require('fs');
5+
6+
var args = process.argv.slice(2);
7+
8+
var jake = cp.exec('jake clean local', () => void 0);
9+
jake.on('close', code => {
10+
if (code === 0) {
11+
// See what we're being asked to do
12+
if (args[1] === 'compiles' || args[1] === '!compiles') {
13+
var tsc = cp.exec('node built/local/tsc.js ' + args[0], () => void 0);
14+
tsc.on('close', tscCode => {
15+
if ((tscCode === 0) === (args[1] === 'compiles')) {
16+
console.log('Good');
17+
process.exit(0); // Good
18+
} else {
19+
console.log('Bad');
20+
process.exit(1); // Bad
21+
}
22+
});
23+
} else if (args[1] === 'emits' || args[1] === '!emits') {
24+
var tsc = cp.exec('node built/local/tsc.js ' + args[0], () => void 0);
25+
tsc.on('close', tscCode => {
26+
fs.readFile(args[2], 'utf-8', (err, data) => {
27+
var doesContains = data.indexOf(args[3]) >= 0;
28+
if (doesContains === (args[1] === 'emits')) {
29+
console.log('Good');
30+
process.exit(0); // Good
31+
} else {
32+
console.log('Bad');
33+
process.exit(1); // Bad
34+
}
35+
});
36+
});
37+
} else {
38+
console.log('Unknown command line arguments.');
39+
console.log('Usage (compile errors): git bisect run scripts\bisect.js "foo.ts --module amd" compiles');
40+
console.log('Usage (emit check): git bisect run scripts\bisect.js bar.ts emits bar.js "_this = this"');
41+
process.exit(-1);
42+
}
43+
} else {
44+
// Build failed
45+
process.exit(125); // bisect skip
46+
}
47+
});
48+

scripts/bisect.cmd

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
echo off
2+
IF NOT EXIST scripts\bisect.cmd GOTO :wrongdir
3+
IF "%1" == "" GOTO :usage
4+
IF "%1" == "GO" GOTO :run
5+
GOTO :copy
6+
7+
:usage
8+
echo Usage: bisect GoodCommit BadCommit test.ts compiles
9+
echo Usage: bisect GoodCommit BadCommit test.ts emits test.js "var x = 3"
10+
GOTO :eof
11+
12+
:copy
13+
copy scripts\bisect.cmd scripts\bisect-fresh.cmd
14+
scripts\bisect-fresh GO %*
15+
GOTO :eof
16+
17+
:run
18+
call jake local
19+
node built/local/tsc.js scripts/bisect-test.ts --module commonjs
20+
git bisect start %2 %3
21+
git bisect run node scripts/bisect-test.js %4 %5 %6 %7
22+
del scripts\bisect-test.js
23+
del scripts\bisect-fresh.cmd
24+
GOTO :eof
25+
26+
:wrongdir
27+
@echo Run this file from the repo folder, not the scripts folder
28+
GOTO :eof
29+
30+
:eof

0 commit comments

Comments
 (0)