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 Jun 23, 2019
1 parent 03683f0 commit 9b3f6d0
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('tape')
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 All @@ -28,6 +29,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 @@ -40,14 +42,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 @@ -62,13 +64,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 9b3f6d0

Please sign in to comment.