Skip to content

Commit

Permalink
test: added "build addon with an action"
Browse files Browse the repository at this point in the history
test the fix for nodejs#1151

Ref: nodejs#1153
  • Loading branch information
refack committed May 17, 2017
1 parent bad903a commit 474cd2f
Show file tree
Hide file tree
Showing 7 changed files with 157 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/node_modules/test_action1/binding.gyp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions test/node_modules/test_action1/hello.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions test/node_modules/test_action1/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions test/node_modules/test_action2/binding.gyp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions test/node_modules/test_action2/hello.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions test/node_modules/test_action2/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 47 additions & 0 deletions test/test-gyp-patches.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
'use strict'

var test = require('tape')
var execFile = require('child_process').execFile
var path = require('path')
var fs = require('fs')
var nodeGyp = path.resolve(__dirname, '..', 'bin', 'node-gyp.js')

test('#1151 build addon with an action', function (t) {
t.plan(3)

var addonPath = path.resolve(__dirname, 'node_modules', 'test_action1')
// Set the loglevel otherwise the output disappears when run via 'npm test'
var cmd = [nodeGyp, 'rebuild', '-C', addonPath, '--loglevel=verbose']
var proc = execFile(process.execPath, cmd, function (err, stdout, stderr) {
var logLines = stderr.toString().trim().split(/\r?\n/)
var lastLine = logLines[logLines.length - 1]
t.notOk(err)
t.strictEqual(lastLine, 'gyp info ok', 'should end in ok')
var locPath = path.resolve(addonPath, 'loc.txt')
var loc = fs.readFileSync(locPath, {encoding: 'utf-8'}).trim()
fs.unlinkSync(locPath);
t.ok(fs.existsSync(loc));
})
proc.stdout.setEncoding('utf-8')
proc.stderr.setEncoding('utf-8')
})

test('#1151 build addon with an action 2', function (t) {
t.plan(3)

var addonPath = path.resolve(__dirname, 'node_modules', 'test_action2')
// Set the loglevel otherwise the output disappears when run via 'npm test'
var cmd = [nodeGyp, 'rebuild', '-C', addonPath, '--loglevel=verbose']
var proc = execFile(process.execPath, cmd, function (err, stdout, stderr) {
var logLines = stderr.toString().trim().split(/\r?\n/)
var lastLine = logLines[logLines.length - 1]
t.notOk(err)
t.strictEqual(lastLine, 'gyp info ok', 'should end in ok')
var locPath = path.resolve(addonPath, 'loc.txt')
var loc = fs.readFileSync(locPath, {encoding: 'utf-8'}).trim()
fs.unlinkSync(locPath);
t.ok(fs.existsSync(loc));
})
proc.stdout.setEncoding('utf-8')
proc.stderr.setEncoding('utf-8')
})

0 comments on commit 474cd2f

Please sign in to comment.