Skip to content

Commit 474cd2f

Browse files
committed
test: added "build addon with an action"
test the fix for nodejs#1151 Ref: nodejs#1153
1 parent bad903a commit 474cd2f

File tree

7 files changed

+157
-0
lines changed

7 files changed

+157
-0
lines changed

test/node_modules/test_action1/binding.gyp

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/node_modules/test_action1/hello.txt

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/node_modules/test_action1/package.json

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/node_modules/test_action2/binding.gyp

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/node_modules/test_action2/hello.txt

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/node_modules/test_action2/package.json

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/test-gyp-patches.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
'use strict'
2+
3+
var test = require('tape')
4+
var execFile = require('child_process').execFile
5+
var path = require('path')
6+
var fs = require('fs')
7+
var nodeGyp = path.resolve(__dirname, '..', 'bin', 'node-gyp.js')
8+
9+
test('#1151 build addon with an action', function (t) {
10+
t.plan(3)
11+
12+
var addonPath = path.resolve(__dirname, 'node_modules', 'test_action1')
13+
// Set the loglevel otherwise the output disappears when run via 'npm test'
14+
var cmd = [nodeGyp, 'rebuild', '-C', addonPath, '--loglevel=verbose']
15+
var proc = execFile(process.execPath, cmd, function (err, stdout, stderr) {
16+
var logLines = stderr.toString().trim().split(/\r?\n/)
17+
var lastLine = logLines[logLines.length - 1]
18+
t.notOk(err)
19+
t.strictEqual(lastLine, 'gyp info ok', 'should end in ok')
20+
var locPath = path.resolve(addonPath, 'loc.txt')
21+
var loc = fs.readFileSync(locPath, {encoding: 'utf-8'}).trim()
22+
fs.unlinkSync(locPath);
23+
t.ok(fs.existsSync(loc));
24+
})
25+
proc.stdout.setEncoding('utf-8')
26+
proc.stderr.setEncoding('utf-8')
27+
})
28+
29+
test('#1151 build addon with an action 2', function (t) {
30+
t.plan(3)
31+
32+
var addonPath = path.resolve(__dirname, 'node_modules', 'test_action2')
33+
// Set the loglevel otherwise the output disappears when run via 'npm test'
34+
var cmd = [nodeGyp, 'rebuild', '-C', addonPath, '--loglevel=verbose']
35+
var proc = execFile(process.execPath, cmd, function (err, stdout, stderr) {
36+
var logLines = stderr.toString().trim().split(/\r?\n/)
37+
var lastLine = logLines[logLines.length - 1]
38+
t.notOk(err)
39+
t.strictEqual(lastLine, 'gyp info ok', 'should end in ok')
40+
var locPath = path.resolve(addonPath, 'loc.txt')
41+
var loc = fs.readFileSync(locPath, {encoding: 'utf-8'}).trim()
42+
fs.unlinkSync(locPath);
43+
t.ok(fs.existsSync(loc));
44+
})
45+
proc.stdout.setEncoding('utf-8')
46+
proc.stderr.setEncoding('utf-8')
47+
})

0 commit comments

Comments
 (0)