Skip to content

Commit 6f44c33

Browse files
author
William Blankenship
committed
Basic functionality complete. Needs usability testing before we clean up code and output.
1 parent 42175ff commit 6f44c33

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

test.js

+13-18
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//test runs a specific test on a specified command
22
exports.test = function(dir,name,command) {
33
return function () {
4+
console.log("\nRunning test "+name+" on "+command+"\n");
45
var fs = require('fs');
56
var files;
67
try {
@@ -29,32 +30,26 @@ exports.test = function(dir,name,command) {
2930
files[i] = files[i].split(".input")[0];
3031
}
3132
}
32-
console.log(files);
3333

3434
//Start workers to test the files
3535
for(i=0;i<files.length;i++) {
3636
var exec = require('child_process').exec;
37-
var str = command+' < "'+dir+'/'+name+'/'+files[i]+'.input"';
38-
console.log(str);
39-
var child = exec(str, function(error,stdout,stderr) {
40-
console.log("stdout: "+stdout);
41-
});
37+
var str = command+' < "'+dir+'/'+name+'/'+files[i]+'.input" | diff --ignore-all-space "'+dir+'/'+name+'/'+files[i]+'.output" -';
38+
exec(str,execComplete(files[i]));
4239
}
4340
}
4441
}
4542

46-
function runTest(id,command) {
47-
return function(error,input) {
48-
if(error) {
49-
console.log("Unable to open input for "+id);
50-
return;
43+
function execComplete(id) {
44+
return function(error,stdout,stderr) {
45+
code = error || 0;
46+
switch(code) {
47+
case 0:
48+
console.log("Test "+id+" PASSED!");
49+
break;
50+
default:
51+
console.log("Test "+id+" FAILED!");
52+
break;
5153
}
52-
console.log("running process: ",id);
53-
var exec = require('child_process').exec;
54-
var child = exec("exec "+command, function(error,stdout,stderr) {
55-
console.log("stdout "+id+": "+stdout);
56-
});
57-
console.log("writing to stdin: ",id);
58-
child.stdin.write(input);
5954
}
6055
}

0 commit comments

Comments
 (0)