Skip to content

Commit

Permalink
test: accept Python 3 in test-find-python.js
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
joaocgreis authored and rvagg committed Sep 26, 2019
1 parent 1267b4d commit 2e24d0a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ matrix:
before_install: choco install python

allow_failures:
- env: NODE_GYP_FORCE_PYTHON=python3 EXPERIMENTAL_NODE_GYP_PYTHON3=1
- os: osx
env: NODE_GYP_FORCE_PYTHON=python3 EXPERIMENTAL_NODE_GYP_PYTHON3=1
- env: >-
PATH=/c/Python37:/c/Python37/Scripts:$PATH
NODE_GYP_FORCE_PYTHON=/c/Python37/python.exe
Expand Down
15 changes: 10 additions & 5 deletions test/test-find-python.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
'use strict'

delete process.env.PYTHON

const test = require('tap').test
const findPython = require('../lib/find-python')
const execFile = require('child_process').execFile
const PythonFinder = findPython.test.PythonFinder

delete process.env.PYTHON
delete process.env.NODE_GYP_FORCE_PYTHON

require('npmlog').level = 'warn'

test('find python', function (t) {
Expand All @@ -17,8 +16,13 @@ test('find python', function (t) {
t.strictEqual(err, null)
var proc = execFile(found, ['-V'], function (err, stdout, stderr) {
t.strictEqual(err, null)
t.strictEqual(stdout, '')
t.ok(/Python 2/.test(stderr))
if (/Python 2/.test(stderr)) {
t.strictEqual(stdout, '')
t.ok(/Python 2/.test(stderr))
} else {
t.ok(/Python 3/.test(stdout))
t.strictEqual(stderr, '')
}
})
proc.stdout.setEncoding('utf-8')
proc.stderr.setEncoding('utf-8')
Expand Down Expand Up @@ -51,6 +55,7 @@ TestPythonFinder.prototype.log = {
warn: () => {},
error: () => {}
}
delete TestPythonFinder.prototype.env.NODE_GYP_FORCE_PYTHON

test('find python - python', function (t) {
t.plan(6)
Expand Down

0 comments on commit 2e24d0a

Please sign in to comment.