-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathodfeRunner.js
95 lines (79 loc) · 2.46 KB
/
odfeRunner.js
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
var spawn = require('child_process').spawn;
var odfeResults = require('./odfeResults');
var fs = require('fs-extra');
var ODFEXPLORER_DIR = "../ODFExplorer/";
var PRODCOV = "prodcov";
var testIncrement = {};
var docsBase = "";
function setDocsBaseDir(dir) {
docsBase = dir;
}
function setTestIncrement(inc) {
testIncrement = inc;
}
function run(test, key, callback) {
var cmdArgs = ['-jar', 'odfe.jar'];
cmdArgs.push('-a');
cmdArgs.push('-o');
cmdArgs.push(PRODCOV); //make this a set by the comparison run
cmdArgs.push('-f');
var docFullName = "";
console.log("Run ODFE for " + testIncrement.test);
var docsin = testIncrement.docsin;
console.log("Number of Docs in " + docsin.length);
for (var i = 0; i < docsin.length; i++) {
docFullName = docsBase + docsin[i];
console.log(docFullName);
//this is going to need a relative path...
//to the ODFEXPLORER_DIR?
//check existance of the document
if(exists(docFullName)) {
cmdArgs.push(docFullName);
}
}
var docsout = testIncrement.docsout;
if (docsout != null) {
console.log("Number of Docs out " + docsout.length);
for (var i = 0; i < docsout.length; i++) {
docFullName = docsBase + docsout[i];
console.log(docFullName);
if(exists(docFullName)) {
cmdArgs.push(docFullName);
}
}
}
runodfe(test, key, cmdArgs, callback);
}
// We need to build up the cmdArgs to aggregate into a given
// directory (or will it default)
// also need to make working directory something that of the odfe tool
// hard code the aggregation file name to prodcov?
// or make settable.... latter better... can then have odf and simple tests separate
var runodfe = function (test, key, cmdArgs, callback) {
console.log('process ' + cmdArgs.toString());
ls = spawn('java', cmdArgs, {
cwd : ODFEXPLORER_DIR
});
ls.stdout.on('data', function (data) {
console.log('stdout: ' + data);
});
ls.stderr.on('data', function (data) {
console.log('stderr: ' + data);
});
ls.on('close', function (code) {
console.log('child process exited with code ' + code);
//examine code > 0 we have an error
if (code > 0) {
callback(code);
} else {
odfeResults.generateJSON(ODFEXPLORER_DIR, PRODCOV, test, key, callback);
// callback();
}
});
}
function exists(file) {
return fs.existsSync(file);
}
module.exports.run = run;
module.exports.setTestIncrement = setTestIncrement;
module.exports.setDocsBaseDir = setDocsBaseDir;