Skip to content

Commit 2e24d0a

Browse files
joaocgreisrvagg
authored andcommitted
test: accept Python 3 in test-find-python.js
Fixes: #1826 PR-URL: #1843 Reviewed-By: Christian Clauss <[email protected]> Reviewed-By: Rod Vagg <[email protected]> Reviewed-By: Matt Cowley <[email protected]> Reviewed-By: Richard Lau <[email protected]>
1 parent 1267b4d commit 2e24d0a

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

.travis.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ matrix:
6262
before_install: choco install python
6363

6464
allow_failures:
65-
- env: NODE_GYP_FORCE_PYTHON=python3 EXPERIMENTAL_NODE_GYP_PYTHON3=1
65+
- os: osx
66+
env: NODE_GYP_FORCE_PYTHON=python3 EXPERIMENTAL_NODE_GYP_PYTHON3=1
6667
- env: >-
6768
PATH=/c/Python37:/c/Python37/Scripts:$PATH
6869
NODE_GYP_FORCE_PYTHON=/c/Python37/python.exe

test/test-find-python.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
'use strict'
22

3+
delete process.env.PYTHON
4+
35
const test = require('tap').test
46
const findPython = require('../lib/find-python')
57
const execFile = require('child_process').execFile
68
const PythonFinder = findPython.test.PythonFinder
79

8-
delete process.env.PYTHON
9-
delete process.env.NODE_GYP_FORCE_PYTHON
10-
1110
require('npmlog').level = 'warn'
1211

1312
test('find python', function (t) {
@@ -17,8 +16,13 @@ test('find python', function (t) {
1716
t.strictEqual(err, null)
1817
var proc = execFile(found, ['-V'], function (err, stdout, stderr) {
1918
t.strictEqual(err, null)
20-
t.strictEqual(stdout, '')
21-
t.ok(/Python 2/.test(stderr))
19+
if (/Python 2/.test(stderr)) {
20+
t.strictEqual(stdout, '')
21+
t.ok(/Python 2/.test(stderr))
22+
} else {
23+
t.ok(/Python 3/.test(stdout))
24+
t.strictEqual(stderr, '')
25+
}
2226
})
2327
proc.stdout.setEncoding('utf-8')
2428
proc.stderr.setEncoding('utf-8')
@@ -51,6 +55,7 @@ TestPythonFinder.prototype.log = {
5155
warn: () => {},
5256
error: () => {}
5357
}
58+
delete TestPythonFinder.prototype.env.NODE_GYP_FORCE_PYTHON
5459

5560
test('find python - python', function (t) {
5661
t.plan(6)

0 commit comments

Comments
 (0)