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

Fix test-find-python on v0.10.x buildbot. #1172

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
4 changes: 2 additions & 2 deletions lib/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ PythonFinder.prototype = {
env: process.env,
execFile: cp.execFile,
log: log,
resolve: path.win32 && path.win32.resolve || path.resolve,
stat: fs.stat,
which: which,
win: win,
Expand Down Expand Up @@ -499,8 +500,7 @@ PythonFinder.prototype = {
if (rootDir[rootDir.length - 1] !== '\\') {
rootDir += '\\'
}
var resolve = path.win32 && path.win32.resolve || path.resolve
var pythonPath = resolve(rootDir, 'Python27', 'python.exe')
var pythonPath = this.resolve(rootDir, 'Python27', 'python.exe')
this.log.verbose('ensuring that file exists:', pythonPath)
this.stat(pythonPath, function (err, stat) {
if (err) {
Expand Down
12 changes: 12 additions & 0 deletions test/test-find-python.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict'

var test = require('tape')
var path = require('path')
var configure = require('../lib/configure')
var execFile = require('child_process').execFile
var PythonFinder = configure.test.PythonFinder
Expand Down Expand Up @@ -34,10 +35,19 @@ function poison(object, property) {
Object.defineProperty(object, property, descriptor)
}

// Work around a v0.10.x CI issue where path.resolve() on UNIX systems prefixes
// Windows paths with the current working directory. v0.12 and up are free of
// this issue because they use path.win32.resolve() which does the right thing.
var resolve = path.win32 && path.win32.resolve || function() {
function rstrip(s) { return s.replace(/\\+$/, '') }
return [].slice.call(arguments).map(rstrip).join('\\')
}

function TestPythonFinder() { PythonFinder.apply(this, arguments) }
TestPythonFinder.prototype = Object.create(PythonFinder.prototype)
poison(TestPythonFinder.prototype, 'env')
poison(TestPythonFinder.prototype, 'execFile')
poison(TestPythonFinder.prototype, 'resolve')
poison(TestPythonFinder.prototype, 'stat')
poison(TestPythonFinder.prototype, 'which')
poison(TestPythonFinder.prototype, 'win')
Expand Down Expand Up @@ -287,6 +297,7 @@ test('find python - no python, no python launcher, good guess', function (t) {
t.strictEqual(program, 'py.exe')
cb(new Error('not found'))
}
f.resolve = resolve
f.stat = function(path, cb) {
t.ok(re.test(path))
cb(null, {})
Expand All @@ -313,6 +324,7 @@ test('find python - no python, no python launcher, bad guess', function (t) {
t.strictEqual(program, 'py.exe')
cb(new Error('not found'))
}
f.resolve = resolve
f.stat = function(path, cb) {
t.ok(/Z:[\\\/]Python27[\\\/]python.exe/.test(path))
var err = new Error('not found')
Expand Down