3 var test = require('tape')
4 var execFile = require('child_process').execFile
5 var path = require('path')
6 var addonPath = path.resolve(__dirname, 'node_modules', 'hello_world')
7 var nodeGyp = path.resolve(__dirname, '..', 'bin', 'node-gyp.js')
9 test('build simple addon', function (t) {
12 // Set the loglevel otherwise the output disappears when run via 'npm test'
13 var cmd = [nodeGyp, 'rebuild', '-C', addonPath, '--loglevel=verbose']
14 var proc = execFile(process.execPath, cmd, function (err, stdout, stderr) {
15 var logLines = stderr.toString().trim().split(/\r?\n/)
16 var lastLine = logLines[logLines.length-1]
17 t.strictEqual(err, null)
18 t.strictEqual(lastLine, 'gyp info ok', 'should end in ok')
20 var binding = require('hello_world')
21 t.strictEqual(binding.hello(), 'world')
23 t.error(error, 'load module')
26 proc.stdout.setEncoding('utf-8')
27 proc.stderr.setEncoding('utf-8')