UNPKG

795 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 test(name, function (t) {
8 t.plan(2)
9 var file = name.toLowerCase().replace(/\s+/g, '_') + '.js'
10 var solution = path.join(__dirname, 'solutions', file)
11
12 var ps = run(['select', name])
13 ps.on('exit', selected)
14 ps.stderr.pipe(process.stderr)
15
16 function selected (code) {
17 t.equal(code, 0)
18 var ps = run(['verify', solution])
19 ps.on('exit', verified)
20 ps.stderr.pipe(process.stderr)
21 }
22
23 function verified (code) {
24 t.equal(code, 0)
25 }
26 })
27})
28
29function run (args) {
30 args.unshift(path.join(__dirname, '../bin/cmd.js'))
31 return spawn(process.execPath, args)
32}