UNPKG

964 BJavaScriptView Raw
1var spawn = require('child_process').spawn;
2var path = require('path');
3var test = require('tape');
4
5var adventures = require('../menu.json');
6adventures.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
31function run (args) {
32 args.unshift(path.join(__dirname, '../bin/cmd.js'));
33 return spawn(process.execPath, args);
34}