1 | var spawn = require('child_process').spawn;
|
2 | var path = require('path');
|
3 | var test = require('tape');
|
4 |
|
5 | var adventures = require('../menu.json');
|
6 | adventures.forEach(function (name) {
|
7 | if (name === 'WEBSOCKETS') return;
|
8 |
|
9 | test(name, function (t) {
|
10 | t.plan(2);
|
11 | var file = name.toLowerCase().replace(/\s+/g, '_') + '.js';
|
12 | var solution = path.join(__dirname, 'solutions', file);
|
13 |
|
14 | var ps = run([ 'select', name ]);
|
15 | ps.on('exit', selected);
|
16 | ps.stderr.pipe(process.stderr);
|
17 |
|
18 | function selected (code) {
|
19 | t.equal(code, 0);
|
20 | var ps = run([ 'verify', solution ]);
|
21 | ps.on('exit', verified);
|
22 | ps.stderr.pipe(process.stderr);
|
23 | }
|
24 |
|
25 | function verified (code) {
|
26 | t.equal(code, 0);
|
27 | }
|
28 | });
|
29 | });
|
30 |
|
31 | function run (args) {
|
32 | args.unshift(path.join(__dirname, '../bin/cmd.js'));
|
33 | return spawn(process.execPath, args);
|
34 | }
|