From 2e24d0a3262bac5d1202a585981452a22ff68408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Reis?= Date: Tue, 23 Jul 2019 14:58:10 +0100 Subject: [PATCH] test: accept Python 3 in test-find-python.js Fixes: https://github.com/nodejs/node-gyp/issues/1826 PR-URL: https://github.com/nodejs/node-gyp/pull/1843 Reviewed-By: Christian Clauss Reviewed-By: Rod Vagg Reviewed-By: Matt Cowley Reviewed-By: Richard Lau --- .travis.yml | 3 ++- test/test-find-python.js | 15 ++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 18b00d11a4..4940dec0df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/test/test-find-python.js b/test/test-find-python.js index c52a579666..1c86f45b73 100644 --- a/test/test-find-python.js +++ b/test/test-find-python.js @@ -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) { @@ -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') @@ -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)