Skip to content

Commit

Permalink
test: configure proper devDir for invoking configure()
Browse files Browse the repository at this point in the history
test/test-configure-python.js downloads a fresh set of headers to the
package directory each time. By setting to the default global cache dir
we get to re-use cached headers and skip the download step.
  • Loading branch information
rvagg committed Jul 6, 2019
1 parent 7e81270 commit ee46c5c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions test/common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const envPaths = require('env-paths')

module.exports.devDir = () => envPaths('node-gyp', { suffix: '' }).cache
6 changes: 4 additions & 2 deletions test/test-configure-python.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

var test = require('tap').test
var path = require('path')
var devDir = require('./common').devDir()
var gyp = require('../lib/node-gyp')
var requireInject = require('require-inject')
var configure = requireInject('../lib/configure', {
Expand Down Expand Up @@ -30,6 +31,7 @@ test('configure PYTHONPATH with no existing env', function (t) {
t.equal(process.env.PYTHONPATH, EXPECTED_PYPATH)
return SPAWN_RESULT
}
prog.devDir = devDir
configure(prog, [], t.fail)
})

Expand All @@ -42,14 +44,14 @@ test('configure PYTHONPATH with existing env of one dir', function (t) {
var prog = gyp()
prog.parseArgv([])
prog.spawn = function () {

t.equal(process.env.PYTHONPATH, [EXPECTED_PYPATH, existingPath].join(SEPARATOR))

var dirs = process.env.PYTHONPATH.split(SEPARATOR)
t.deepEqual(dirs, [EXPECTED_PYPATH, existingPath])

return SPAWN_RESULT
}
prog.devDir = devDir
configure(prog, [], t.fail)
})

Expand All @@ -64,13 +66,13 @@ test('configure PYTHONPATH with existing env of multiple dirs', function (t) {
var prog = gyp()
prog.parseArgv([])
prog.spawn = function () {

t.equal(process.env.PYTHONPATH, [EXPECTED_PYPATH, existingPath].join(SEPARATOR))

var dirs = process.env.PYTHONPATH.split(SEPARATOR)
t.deepEqual(dirs, [EXPECTED_PYPATH, pythonDir1, pythonDir2])

return SPAWN_RESULT
}
prog.devDir = devDir
configure(prog, [], t.fail)
})

0 comments on commit ee46c5c

Please sign in to comment.