1 var tap = require('tap')
2 var pz = require('../promzard.js')
3 var spawn = require('child_process').spawn
5 tap.test('run the example', function (t) {
7 var example = require.resolve('../example/index.js')
8 var node = process.execPath
13 "description": "testing description",
14 "main": "test-entry.js",
24 "test": "tap test/*.js"
28 "url": "git://github.com/substack/example.git"
30 "homepage": "https://github.com/substack/example",
38 "name": "James Halliday",
39 "email": "mail@substack.net",
40 "url": "http://substack.net"
48 console.error('%s %s', node, example)
49 var c = spawn(node, [example], { customFds: [-1,-1,-1] })
51 c.stdout.on('data', function (d) {
57 c.stderr.on('data', function (d) {
62 console.error('respond', output)
63 if (output.match(/description: $/)) {
64 c.stdin.write('testing description\n')
67 if (output.match(/entry point: \(index\.js\) $/)) {
68 c.stdin.write('test-entry.js\n')
71 if (output.match(/keywords: $/)) {
72 c.stdin.write('fugazi function waiting room\n')
73 // "read" module is weird on node >= 0.10 when not a TTY
74 // requires explicit ending for reasons.
75 // could dig in, but really just wanna make tests pass, whatever.
81 c.on('exit', function () {
82 console.error('exit event')
85 c.on('close', function () {
86 console.error('actual', actual)
87 actual = JSON.parse(actual)
88 t.deepEqual(actual, expect)