-
Notifications
You must be signed in to change notification settings - Fork 0
/
test
executable file
·56 lines (47 loc) · 1.43 KB
/
test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env node
var child_process = require('child_process')
path = require('path'),
fs = require('fs');
var jsx = path.join(__dirname, 'JSX/bin/jsx');
var out = path.join(__dirname, 'out');
var jsx_url = 'https://github.com/jsx/JSX.git';
var CloneJsx = function(fn) {
if (fs.existsSync(path.join(__dirname, 'JSX'))) {
fn();
return;
}
var p = child_process.spawn('git', ['clone', jsx_url], {
stdio : [process.stdin, process.stdout, process.stderr],
cwd : __dirname
});
p.on('exit', function(code) {
if (code != 0)
process.exit(code);
fn();
});
};
// make sure we have a build directory.
if (!fs.existsSync(out))
fs.mkdirSync(out);
CloneJsx(function() {
// build the test
child_process.execFile(jsx, ['crypto_test.jsx'], {
cwd : __dirname,
stdio : [null, 'pipe', process.stderr]
}, function(err, stdout, stderr) {
// tell it to stream to this stderr, it just ignores you.
if (err != null) {
process.stderr.write(stderr);
process.exit(err.code);
}
var jso = path.join(out, 'test.js');
fs.writeFileSync(jso,
'var check = require("assert");\n' + stdout
+ 'JSX.require("crypto_test.jsx")._Main.main$AS([]);\n');
var p = child_process.spawn(process.execPath, [jso], {
stdio : [process.stdin, process.stdout, process.stderr]});
p.on('exit', function(code) {
process.exit(code);
});
});
});