|
1 | 1 | //test runs a specific test on a specified command
|
2 | 2 | exports.test = function(dir,name,command) {
|
3 | 3 | return function () {
|
| 4 | + console.log("\nRunning test "+name+" on "+command+"\n"); |
4 | 5 | var fs = require('fs');
|
5 | 6 | var files;
|
6 | 7 | try {
|
@@ -29,32 +30,26 @@ exports.test = function(dir,name,command) {
|
29 | 30 | files[i] = files[i].split(".input")[0];
|
30 | 31 | }
|
31 | 32 | }
|
32 |
| - console.log(files); |
33 | 33 |
|
34 | 34 | //Start workers to test the files
|
35 | 35 | for(i=0;i<files.length;i++) {
|
36 | 36 | 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])); |
42 | 39 | }
|
43 | 40 | }
|
44 | 41 | }
|
45 | 42 |
|
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; |
51 | 53 | }
|
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); |
59 | 54 | }
|
60 | 55 | }
|
0 commit comments