Skip to content

Commit

Permalink
test: first regressions test for our GYP patches
Browse files Browse the repository at this point in the history
test the fix for nodejs#1151
  • Loading branch information
refack committed Mar 25, 2017
1 parent 47926a6 commit 772153b
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
gyp/test
node_modules
test/.node-gyp
/*.*.*/
!/test/node_modules
/build/
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 772153b

Please sign in to comment.