Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] test: added "build addon with an action" #1156

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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')
})