Migration from tap to mocha (#2851)

* migrate from tap to mocha

After make-fetch-happen update GitHub Actions started failing. Migrating
from tap to mocha testing framework for GitHub Action stability.

* write custom test reporter for more verbose output

Implemented a simple custom mocha test reporter to replace the default
one. Made test report more developer friendly.
This commit is contained in:
Stefan Stojanovic 2023-06-05 17:05:29 +02:00 committed by GitHub
parent aaa117c514
commit 5df2b72a8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 1876 additions and 1938 deletions

View file

@ -39,13 +39,13 @@
},
"devDependencies": {
"bindings": "^1.5.0",
"mocha": "^10.2.0",
"nan": "^2.14.2",
"require-inject": "^1.4.4",
"standard": "^14.3.4",
"tap": "^12.7.0"
"standard": "^14.3.4"
},
"scripts": {
"lint": "standard */*.js test/**/*.js",
"test": "npm run lint && tap --timeout=1200 test/test-*"
"test": "npm run lint && mocha --reporter=test/reporter.js test/test-download.js test/test-*"
}
}

75
test/reporter.js Normal file
View file

@ -0,0 +1,75 @@
const Mocha = require('mocha')
class Reporter {
constructor (runner) {
this.failedTests = []
runner.on(Mocha.Runner.constants.EVENT_RUN_BEGIN, () => {
console.log('Starting tests')
})
runner.on(Mocha.Runner.constants.EVENT_RUN_END, () => {
console.log('Tests finished')
console.log()
console.log('****************')
console.log('* TESTS REPORT *')
console.log('****************')
console.log()
console.log(`Executed ${runner.stats.suites} suites with ${runner.stats.tests} tests in ${runner.stats.duration} ms`)
console.log(` Passed: ${runner.stats.passes}`)
console.log(` Skipped: ${runner.stats.pending}`)
console.log(` Failed: ${runner.stats.failures}`)
if (this.failedTests.length > 0) {
console.log()
console.log(' Failed test details')
this.failedTests.forEach((failedTest, index) => {
console.log()
console.log(` ${index + 1}.'${failedTest.test.fullTitle()}'`)
console.log(` Name: ${failedTest.error.name}`)
console.log(` Message: ${failedTest.error.message}`)
console.log(` Code: ${failedTest.error.code}`)
console.log(` Stack: ${failedTest.error.stack}`)
})
}
console.log()
})
runner.on(Mocha.Runner.constants.EVENT_SUITE_BEGIN, (suite) => {
if (suite.root) {
return
}
console.log(`Starting suite '${suite.title}'`)
})
runner.on(Mocha.Runner.constants.EVENT_SUITE_END, (suite) => {
if (suite.root) {
return
}
console.log(`Suite '${suite.title}' finished`)
console.log()
})
runner.on(Mocha.Runner.constants.EVENT_TEST_BEGIN, (test) => {
console.log(`Starting test '${test.title}'`)
})
runner.on(Mocha.Runner.constants.EVENT_TEST_PASS, (test) => {
console.log(`Test '${test.title}' passed in ${test.duration} ms`)
})
runner.on(Mocha.Runner.constants.EVENT_TEST_PENDING, (test) => {
console.log(`Test '${test.title}' skipped in ${test.duration} ms`)
})
runner.on(Mocha.Runner.constants.EVENT_TEST_FAIL, (test, error) => {
this.failedTests.push({ test, error })
console.log(`Test '${test.title}' failed in ${test.duration} ms with ${error}`)
})
runner.on(Mocha.Runner.constants.EVENT_TEST_END, (test) => {
console.log()
})
}
}
module.exports = Reporter

View file

@ -1,6 +1,7 @@
'use strict'
const test = require('tap').test
const { describe, it } = require('mocha')
const assert = require('assert')
const path = require('path')
const fs = require('graceful-fs')
const childProcess = require('child_process')
@ -35,27 +36,27 @@ function checkCharmapValid () {
return lines.pop() === 'True'
}
test('build simple addon', function (t) {
t.plan(3)
describe('addon', function () {
this.timeout(300000)
it('build simple addon', function (done) {
// Set the loglevel otherwise the output disappears when run via 'npm test'
var cmd = [nodeGyp, 'rebuild', '-C', addonPath, '--loglevel=verbose']
var proc = execFile(process.execPath, cmd, function (err, stdout, stderr) {
var logLines = stderr.toString().trim().split(/\r?\n/)
var lastLine = logLines[logLines.length - 1]
t.strictEqual(err, null)
t.strictEqual(lastLine, 'gyp info ok', 'should end in ok')
t.strictEqual(runHello().trim(), 'world')
assert.strictEqual(err, null)
assert.strictEqual(lastLine, 'gyp info ok', 'should end in ok')
assert.strictEqual(runHello().trim(), 'world')
done()
})
proc.stdout.setEncoding('utf-8')
proc.stderr.setEncoding('utf-8')
})
test('build simple addon in path with non-ascii characters', function (t) {
t.plan(1)
it('build simple addon in path with non-ascii characters', function (done) {
if (!checkCharmapValid()) {
return t.skip('python console app can\'t encode non-ascii character.')
return this.skip('python console app can\'t encode non-ascii character.')
}
var testDirNames = {
@ -67,17 +68,17 @@ test('build simple addon in path with non-ascii characters', function (t) {
var testDirName = testDirNames[getEncoding()]
// If encoding is UTF-8 or other then no need to test
if (!testDirName) {
return t.skip('no need to test')
return this.skip('no need to test')
}
t.plan(3)
this.timeout(300000)
var data
var configPath = path.join(addonPath, 'build', 'config.gypi')
try {
data = fs.readFileSync(configPath, 'utf8')
} catch (err) {
t.error(err)
assert.fail(err)
return
}
var config = JSON.parse(data.replace(/#.+\n/, ''))
@ -90,10 +91,10 @@ test('build simple addon in path with non-ascii characters', function (t) {
switch (err.code) {
case 'EEXIST': break
case 'EPERM':
t.error(err, 'Please try to running console as an administrator')
assert.fail(err, null, 'Please try to running console as an administrator')
return
default:
t.error(err)
assert.fail(err)
return
}
}
@ -110,28 +111,27 @@ test('build simple addon in path with non-ascii characters', function (t) {
try {
fs.unlink(testNodeDir)
} catch (err) {
t.error(err)
assert.fail(err)
}
var logLines = stderr.toString().trim().split(/\r?\n/)
var lastLine = logLines[logLines.length - 1]
t.strictEqual(err, null)
t.strictEqual(lastLine, 'gyp info ok', 'should end in ok')
t.strictEqual(runHello().trim(), 'world')
assert.strictEqual(err, null)
assert.strictEqual(lastLine, 'gyp info ok', 'should end in ok')
assert.strictEqual(runHello().trim(), 'world')
done()
})
proc.stdout.setEncoding('utf-8')
proc.stderr.setEncoding('utf-8')
})
test('addon works with renamed host executable', function (t) {
it('addon works with renamed host executable', function (done) {
// No `fs.copyFileSync` before node8.
if (process.version.substr(1).split('.')[0] < 8) {
t.skip('skipping test for old node version')
t.end()
return
return this.skip('skipping test for old node version')
}
t.plan(3)
this.timeout(300000)
var notNodePath = path.join(os.tmpdir(), 'notnode' + path.extname(process.execPath))
fs.copyFileSync(process.execPath, notNodePath)
@ -140,11 +140,13 @@ test('addon works with renamed host executable', function (t) {
var proc = execFile(process.execPath, cmd, function (err, stdout, stderr) {
var logLines = stderr.toString().trim().split(/\r?\n/)
var lastLine = logLines[logLines.length - 1]
t.strictEqual(err, null)
t.strictEqual(lastLine, 'gyp info ok', 'should end in ok')
t.strictEqual(runHello(notNodePath).trim(), 'world')
assert.strictEqual(err, null)
assert.strictEqual(lastLine, 'gyp info ok', 'should end in ok')
assert.strictEqual(runHello(notNodePath).trim(), 'world')
fs.unlinkSync(notNodePath)
done()
})
proc.stdout.setEncoding('utf-8')
proc.stderr.setEncoding('utf-8')
})
})

View file

@ -1,6 +1,7 @@
'use strict'
const test = require('tap').test
const { describe, it } = require('mocha')
const assert = require('assert')
const path = require('path')
const devDir = require('./common').devDir()
const gyp = require('../lib/node-gyp')
@ -22,48 +23,43 @@ const configure = requireInject('../lib/configure', {
const EXPECTED_PYPATH = path.join(__dirname, '..', 'gyp', 'pylib')
const SEPARATOR = process.platform === 'win32' ? ';' : ':'
const SPAWN_RESULT = { on: function () { } }
const SPAWN_RESULT = cb => ({ on: function () { cb() } })
require('npmlog').level = 'warn'
test('configure PYTHONPATH with no existing env', function (t) {
t.plan(1)
describe('configure-python', function () {
it('configure PYTHONPATH with no existing env', function (done) {
delete process.env.PYTHONPATH
var prog = gyp()
prog.parseArgv([])
prog.spawn = function () {
t.equal(process.env.PYTHONPATH, EXPECTED_PYPATH)
return SPAWN_RESULT
assert.strictEqual(process.env.PYTHONPATH, EXPECTED_PYPATH)
return SPAWN_RESULT(done)
}
prog.devDir = devDir
configure(prog, [], t.fail)
configure(prog, [], assert.fail)
})
test('configure PYTHONPATH with existing env of one dir', function (t) {
t.plan(2)
it('configure PYTHONPATH with existing env of one dir', function (done) {
var existingPath = path.join('a', 'b')
process.env.PYTHONPATH = existingPath
var prog = gyp()
prog.parseArgv([])
prog.spawn = function () {
t.equal(process.env.PYTHONPATH, [EXPECTED_PYPATH, existingPath].join(SEPARATOR))
assert.strictEqual(process.env.PYTHONPATH, [EXPECTED_PYPATH, existingPath].join(SEPARATOR))
var dirs = process.env.PYTHONPATH.split(SEPARATOR)
t.deepEqual(dirs, [EXPECTED_PYPATH, existingPath])
assert.deepStrictEqual(dirs, [EXPECTED_PYPATH, existingPath])
return SPAWN_RESULT
return SPAWN_RESULT(done)
}
prog.devDir = devDir
configure(prog, [], t.fail)
configure(prog, [], assert.fail)
})
test('configure PYTHONPATH with existing env of multiple dirs', function (t) {
t.plan(2)
it('configure PYTHONPATH with existing env of multiple dirs', function (done) {
var pythonDir1 = path.join('a', 'b')
var pythonDir2 = path.join('b', 'c')
var existingPath = [pythonDir1, pythonDir2].join(SEPARATOR)
@ -72,13 +68,14 @@ 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))
assert.strictEqual(process.env.PYTHONPATH, [EXPECTED_PYPATH, existingPath].join(SEPARATOR))
var dirs = process.env.PYTHONPATH.split(SEPARATOR)
t.deepEqual(dirs, [EXPECTED_PYPATH, pythonDir1, pythonDir2])
assert.deepStrictEqual(dirs, [EXPECTED_PYPATH, pythonDir1, pythonDir2])
return SPAWN_RESULT
return SPAWN_RESULT(done)
}
prog.devDir = devDir
configure(prog, [], t.fail)
configure(prog, [], assert.fail)
})
})

View file

@ -1,70 +1,61 @@
'use strict'
const path = require('path')
const { test } = require('tap')
const { describe, it } = require('mocha')
const assert = require('assert')
const gyp = require('../lib/node-gyp')
const createConfigGypi = require('../lib/create-config-gypi')
const { parseConfigGypi, getCurrentConfigGypi } = createConfigGypi.test
test('config.gypi with no options', async function (t) {
t.plan(2)
describe('create-config-gypi', function () {
it('config.gypi with no options', async function () {
const prog = gyp()
prog.parseArgv([])
const config = await getCurrentConfigGypi({ gyp: prog, vsInfo: {} })
t.equal(config.target_defaults.default_configuration, 'Release')
t.equal(config.variables.target_arch, process.arch)
assert.strictEqual(config.target_defaults.default_configuration, 'Release')
assert.strictEqual(config.variables.target_arch, process.arch)
})
test('config.gypi with --debug', async function (t) {
t.plan(1)
it('config.gypi with --debug', async function () {
const prog = gyp()
prog.parseArgv(['_', '_', '--debug'])
const config = await getCurrentConfigGypi({ gyp: prog, vsInfo: {} })
t.equal(config.target_defaults.default_configuration, 'Debug')
assert.strictEqual(config.target_defaults.default_configuration, 'Debug')
})
test('config.gypi with custom options', async function (t) {
t.plan(1)
it('config.gypi with custom options', async function () {
const prog = gyp()
prog.parseArgv(['_', '_', '--shared-libxml2'])
const config = await getCurrentConfigGypi({ gyp: prog, vsInfo: {} })
t.equal(config.variables.shared_libxml2, true)
assert.strictEqual(config.variables.shared_libxml2, true)
})
test('config.gypi with nodedir', async function (t) {
t.plan(1)
it('config.gypi with nodedir', async function () {
const nodeDir = path.join(__dirname, 'fixtures', 'nodedir')
const prog = gyp()
prog.parseArgv(['_', '_', `--nodedir=${nodeDir}`])
const config = await getCurrentConfigGypi({ gyp: prog, nodeDir, vsInfo: {} })
t.equal(config.variables.build_with_electron, true)
assert.strictEqual(config.variables.build_with_electron, true)
})
test('config.gypi with --force-process-config', async function (t) {
t.plan(1)
it('config.gypi with --force-process-config', async function () {
const nodeDir = path.join(__dirname, 'fixtures', 'nodedir')
const prog = gyp()
prog.parseArgv(['_', '_', '--force-process-config', `--nodedir=${nodeDir}`])
const config = await getCurrentConfigGypi({ gyp: prog, nodeDir, vsInfo: {} })
t.equal(config.variables.build_with_electron, undefined)
assert.strictEqual(config.variables.build_with_electron, undefined)
})
test('config.gypi parsing', function (t) {
t.plan(1)
it('config.gypi parsing', function () {
const str = "# Some comments\n{'variables': {'multiline': 'A'\n'B'}}"
const config = parseConfigGypi(str)
t.deepEqual(config, { variables: { multiline: 'AB' } })
assert.deepStrictEqual(config, { variables: { multiline: 'AB' } })
})
})

View file

@ -1,6 +1,7 @@
'use strict'
const { test } = require('tap')
const { describe, it, after } = require('mocha')
const assert = require('assert')
const fs = require('fs')
const path = require('path')
const util = require('util')
@ -16,15 +17,14 @@ const certs = require('./fixtures/certs')
log.level = 'warn'
test('download over http', async (t) => {
t.plan(2)
describe('download', function () {
it('download over http', async function () {
const server = http.createServer((req, res) => {
t.strictEqual(req.headers['user-agent'], `node-gyp v42 (node ${process.version})`)
assert.strictEqual(req.headers['user-agent'], `node-gyp v42 (node ${process.version})`)
res.end('ok')
})
t.tearDown(() => new Promise((resolve) => server.close(resolve)))
after(() => new Promise((resolve) => server.close(resolve)))
const host = 'localhost'
await new Promise((resolve) => server.listen(0, host, resolve))
@ -35,12 +35,10 @@ test('download over http', async (t) => {
}
const url = `http://${host}:${port}`
const res = await install.test.download(gyp, url)
t.strictEqual(await res.text(), 'ok')
assert.strictEqual(await res.text(), 'ok')
})
test('download over https with custom ca', async (t) => {
t.plan(3)
it('download over https with custom ca', async function () {
const cafile = path.join(__dirname, 'fixtures/ca.crt')
const cacontents = certs['ca.crt']
const cert = certs['server.crt']
@ -48,15 +46,15 @@ test('download over https with custom ca', async (t) => {
await fs.promises.writeFile(cafile, cacontents, 'utf8')
const ca = await install.test.readCAFile(cafile)
t.strictEqual(ca.length, 1)
assert.strictEqual(ca.length, 1)
const options = { ca: ca, cert: cert, key: key }
const server = https.createServer(options, (req, res) => {
t.strictEqual(req.headers['user-agent'], `node-gyp v42 (node ${process.version})`)
assert.strictEqual(req.headers['user-agent'], `node-gyp v42 (node ${process.version})`)
res.end('ok')
})
t.tearDown(async () => {
after(async () => {
await new Promise((resolve) => server.close(resolve))
await fs.promises.unlink(cafile)
})
@ -72,22 +70,20 @@ test('download over https with custom ca', async (t) => {
}
const url = `https://${host}:${port}`
const res = await install.test.download(gyp, url)
t.strictEqual(await res.text(), 'ok')
assert.strictEqual(await res.text(), 'ok')
})
test('download over http with proxy', async (t) => {
t.plan(2)
it('download over http with proxy', async function () {
const server = http.createServer((_, res) => {
res.end('ok')
})
const pserver = http.createServer((req, res) => {
t.strictEqual(req.headers['user-agent'], `node-gyp v42 (node ${process.version})`)
assert.strictEqual(req.headers['user-agent'], `node-gyp v42 (node ${process.version})`)
res.end('proxy ok')
})
t.tearDown(() => Promise.all([
after(() => Promise.all([
new Promise((resolve) => server.close(resolve)),
new Promise((resolve) => pserver.close(resolve))
]))
@ -105,14 +101,12 @@ test('download over http with proxy', async (t) => {
}
const url = `http://${host}:${port}`
const res = await install.test.download(gyp, url)
t.strictEqual(await res.text(), 'proxy ok')
assert.strictEqual(await res.text(), 'proxy ok')
})
test('download over http with noproxy', async (t) => {
t.plan(2)
it('download over http with noproxy', async function () {
const server = http.createServer((req, res) => {
t.strictEqual(req.headers['user-agent'], `node-gyp v42 (node ${process.version})`)
assert.strictEqual(req.headers['user-agent'], `node-gyp v42 (node ${process.version})`)
res.end('ok')
})
@ -120,7 +114,7 @@ test('download over http with noproxy', async (t) => {
res.end('proxy ok')
})
t.tearDown(() => Promise.all([
after(() => Promise.all([
new Promise((resolve) => server.close(resolve)),
new Promise((resolve) => pserver.close(resolve))
]))
@ -138,45 +132,43 @@ test('download over http with noproxy', async (t) => {
}
const url = `http://${host}:${port}`
const res = await install.test.download(gyp, url)
t.strictEqual(await res.text(), 'ok')
assert.strictEqual(await res.text(), 'ok')
})
test('download with missing cafile', async (t) => {
t.plan(1)
it('download with missing cafile', async function () {
const gyp = {
opts: { cafile: 'no.such.file' }
}
try {
await install.test.download(gyp, {}, 'http://bad/')
} catch (e) {
t.ok(/no.such.file/.test(e.message))
assert.ok(/no.such.file/.test(e.message))
}
})
test('check certificate splitting', async (t) => {
it('check certificate splitting', async function () {
const cafile = path.join(__dirname, 'fixtures/ca-bundle.crt')
const cacontents = certs['ca-bundle.crt']
await fs.promises.writeFile(cafile, cacontents, 'utf8')
t.tearDown(async () => {
after(async () => {
await fs.promises.unlink(cafile)
})
const cas = await install.test.readCAFile(path.join(__dirname, 'fixtures/ca-bundle.crt'))
t.plan(2)
t.strictEqual(cas.length, 2)
t.notStrictEqual(cas[0], cas[1])
assert.strictEqual(cas.length, 2)
assert.notStrictEqual(cas[0], cas[1])
})
// only run this test if we are running a version of Node with predictable version path behavior
test('download headers (actual)', async (t) => {
it('download headers (actual)', async function () {
if (process.env.FAST_TEST ||
process.release.name !== 'node' ||
semver.prerelease(process.version) !== null ||
semver.satisfies(process.version, '<10')) {
return t.skip('Skipping actual download of headers due to test environment configuration')
return this.skip('Skipping actual download of headers due to test environment configuration')
}
t.plan(12)
this.timeout(300000)
const expectedDir = path.join(devDir, process.version.replace(/^v/, ''))
await util.promisify(rimraf)(expectedDir)
@ -188,19 +180,19 @@ test('download headers (actual)', async (t) => {
await util.promisify(install)(prog, [])
const data = await fs.promises.readFile(path.join(expectedDir, 'installVersion'), 'utf8')
t.strictEqual(data, '10\n', 'correct installVersion')
assert.strictEqual(data, '10\n', 'correct installVersion')
const list = await fs.promises.readdir(path.join(expectedDir, 'include/node'))
t.ok(list.includes('common.gypi'))
t.ok(list.includes('config.gypi'))
t.ok(list.includes('node.h'))
t.ok(list.includes('node_version.h'))
t.ok(list.includes('openssl'))
t.ok(list.includes('uv'))
t.ok(list.includes('uv.h'))
t.ok(list.includes('v8-platform.h'))
t.ok(list.includes('v8.h'))
t.ok(list.includes('zlib.h'))
assert.ok(list.includes('common.gypi'))
assert.ok(list.includes('config.gypi'))
assert.ok(list.includes('node.h'))
assert.ok(list.includes('node_version.h'))
assert.ok(list.includes('openssl'))
assert.ok(list.includes('uv'))
assert.ok(list.includes('uv.h'))
assert.ok(list.includes('v8-platform.h'))
assert.ok(list.includes('v8.h'))
assert.ok(list.includes('zlib.h'))
const lines = (await fs.promises.readFile(path.join(expectedDir, 'include/node/node_version.h'), 'utf8')).split('\n')
@ -213,5 +205,6 @@ test('download headers (actual)', async (t) => {
return `${version}${type !== 'major' ? '.' : 'v'}${i}`
}, '')
t.strictEqual(version, process.version)
assert.strictEqual(version, process.version)
})
})

View file

@ -1,6 +1,7 @@
'use strict'
const test = require('tap').test
const { describe, it } = require('mocha')
const assert = require('assert')
const path = require('path')
const requireInject = require('require-inject')
const configure = requireInject('../lib/configure', {
@ -27,58 +28,46 @@ const readableFiles = [
path.resolve(dir, readableFileInDir)
]
test('find accessible - empty array', function (t) {
t.plan(1)
describe('find-accessible-sync', function () {
it('find accessible - empty array', function () {
var candidates = []
var found = configure.test.findAccessibleSync('test', dir, candidates)
t.strictEqual(found, undefined)
assert.strictEqual(found, undefined)
})
test('find accessible - single item array, readable', function (t) {
t.plan(1)
it('find accessible - single item array, readable', function () {
var candidates = [readableFile]
var found = configure.test.findAccessibleSync('test', dir, candidates)
t.strictEqual(found, path.resolve(dir, readableFile))
assert.strictEqual(found, path.resolve(dir, readableFile))
})
test('find accessible - single item array, readable in subdir', function (t) {
t.plan(1)
it('find accessible - single item array, readable in subdir', function () {
var candidates = [readableFileInDir]
var found = configure.test.findAccessibleSync('test', dir, candidates)
t.strictEqual(found, path.resolve(dir, readableFileInDir))
assert.strictEqual(found, path.resolve(dir, readableFileInDir))
})
test('find accessible - single item array, unreadable', function (t) {
t.plan(1)
it('find accessible - single item array, unreadable', function () {
var candidates = ['unreadable_file']
var found = configure.test.findAccessibleSync('test', dir, candidates)
t.strictEqual(found, undefined)
assert.strictEqual(found, undefined)
})
test('find accessible - multi item array, no matches', function (t) {
t.plan(1)
it('find accessible - multi item array, no matches', function () {
var candidates = ['non_existent_file', 'unreadable_file']
var found = configure.test.findAccessibleSync('test', dir, candidates)
t.strictEqual(found, undefined)
assert.strictEqual(found, undefined)
})
test('find accessible - multi item array, single match', function (t) {
t.plan(1)
it('find accessible - multi item array, single match', function () {
var candidates = ['non_existent_file', readableFile]
var found = configure.test.findAccessibleSync('test', dir, candidates)
t.strictEqual(found, path.resolve(dir, readableFile))
assert.strictEqual(found, path.resolve(dir, readableFile))
})
test('find accessible - multi item array, return first match', function (t) {
t.plan(1)
it('find accessible - multi item array, return first match', function () {
var candidates = ['non_existent_file', anotherReadableFile, readableFile]
var found = configure.test.findAccessibleSync('test', dir, candidates)
t.strictEqual(found, path.resolve(dir, anotherReadableFile))
assert.strictEqual(found, path.resolve(dir, anotherReadableFile))
})
})

View file

@ -1,20 +1,21 @@
'use strict'
const test = require('tap').test
const { describe, it } = require('mocha')
const assert = require('assert')
const path = require('path')
const findNodeDirectory = require('../lib/find-node-directory')
const platforms = ['darwin', 'freebsd', 'linux', 'sunos', 'win32', 'aix', 'os400']
describe('find-node-directory', function () {
// we should find the directory based on the directory
// the script is running in and it should match the layout
// in a build tree where npm is installed in
// .... /deps/npm
test('test find-node-directory - node install', function (t) {
t.plan(platforms.length)
it('test find-node-directory - node install', function () {
for (var next = 0; next < platforms.length; next++) {
var processObj = { execPath: '/x/y/bin/node', platform: platforms[next] }
t.equal(
assert.strictEqual(
findNodeDirectory('/x/deps/npm/node_modules/node-gyp/lib', processObj),
path.join('/x'))
}
@ -25,16 +26,15 @@ test('test find-node-directory - node install', function (t) {
// in an installed tree where npm is installed in
// .... /lib/node_modules/npm or .../node_modules/npm
// depending on the patform
test('test find-node-directory - node build', function (t) {
t.plan(platforms.length)
it('test find-node-directory - node build', function () {
for (var next = 0; next < platforms.length; next++) {
var processObj = { execPath: '/x/y/bin/node', platform: platforms[next] }
if (platforms[next] === 'win32') {
t.equal(
assert.strictEqual(
findNodeDirectory('/y/node_modules/npm/node_modules/node-gyp/lib',
processObj), path.join('/y'))
} else {
t.equal(
assert.strictEqual(
findNodeDirectory('/y/lib/node_modules/npm/node_modules/node-gyp/lib',
processObj), path.join('/y'))
}
@ -43,11 +43,10 @@ test('test find-node-directory - node build', function (t) {
// we should find the directory based on the execPath
// for node and match because it was in the bin directory
test('test find-node-directory - node in bin directory', function (t) {
t.plan(platforms.length)
it('test find-node-directory - node in bin directory', function () {
for (var next = 0; next < platforms.length; next++) {
var processObj = { execPath: '/x/y/bin/node', platform: platforms[next] }
t.equal(
assert.strictEqual(
findNodeDirectory('/nothere/npm/node_modules/node-gyp/lib', processObj),
path.join('/x/y'))
}
@ -55,8 +54,7 @@ test('test find-node-directory - node in bin directory', function (t) {
// we should find the directory based on the execPath
// for node and match because it was in the Release directory
test('test find-node-directory - node in build release dir', function (t) {
t.plan(platforms.length)
it('test find-node-directory - node in build release dir', function () {
for (var next = 0; next < platforms.length; next++) {
var processObj
if (platforms[next] === 'win32') {
@ -68,7 +66,7 @@ test('test find-node-directory - node in build release dir', function (t) {
}
}
t.equal(
assert.strictEqual(
findNodeDirectory('/nothere/npm/node_modules/node-gyp/lib', processObj),
path.join('/x/y'))
}
@ -76,8 +74,7 @@ test('test find-node-directory - node in build release dir', function (t) {
// we should find the directory based on the execPath
// for node and match because it was in the Debug directory
test('test find-node-directory - node in Debug release dir', function (t) {
t.plan(platforms.length)
it('test find-node-directory - node in Debug release dir', function () {
for (var next = 0; next < platforms.length; next++) {
var processObj
if (platforms[next] === 'win32') {
@ -86,7 +83,7 @@ test('test find-node-directory - node in Debug release dir', function (t) {
processObj = { execPath: '/a/b/out/Debug/node', platform: platforms[next] }
}
t.equal(
assert.strictEqual(
findNodeDirectory('/nothere/npm/node_modules/node-gyp/lib', processObj),
path.join('/a/b'))
}
@ -94,11 +91,10 @@ test('test find-node-directory - node in Debug release dir', function (t) {
// we should not find it as it will not match based on the execPath nor
// the directory from which the script is running
test('test find-node-directory - not found', function (t) {
t.plan(platforms.length)
it('test find-node-directory - not found', function () {
for (var next = 0; next < platforms.length; next++) {
var processObj = { execPath: '/x/y/z/y', platform: next }
t.equal(findNodeDirectory('/a/b/c/d', processObj), '')
assert.strictEqual(findNodeDirectory('/a/b/c/d', processObj), '')
}
})
@ -108,12 +104,12 @@ test('test find-node-directory - not found', function (t) {
// .... /deps/npm
// same test as above but make sure additional directory entries
// don't cause an issue
test('test find-node-directory - node install', function (t) {
t.plan(platforms.length)
it('test find-node-directory - node install', function () {
for (var next = 0; next < platforms.length; next++) {
var processObj = { execPath: '/x/y/bin/node', platform: platforms[next] }
t.equal(
assert.strictEqual(
findNodeDirectory('/x/y/z/a/b/c/deps/npm/node_modules/node-gyp/lib',
processObj), path.join('/x/y/z/a/b/c'))
}
})
})

View file

@ -2,22 +2,22 @@
delete process.env.PYTHON
const test = require('tap').test
const { describe, it } = require('mocha')
const assert = require('assert')
const findPython = require('../lib/find-python')
const execFile = require('child_process').execFile
const PythonFinder = findPython.test.PythonFinder
require('npmlog').level = 'warn'
test('find python', function (t) {
t.plan(4)
describe('find-python', function () {
it('find python', function () {
findPython.test.findPython(null, function (err, found) {
t.strictEqual(err, null)
assert.strictEqual(err, null)
var proc = execFile(found, ['-V'], function (err, stdout, stderr) {
t.strictEqual(err, null)
t.ok(/Python 3/.test(stdout))
t.strictEqual(stderr, '')
assert.strictEqual(err, null)
assert.ok(/Python 3/.test(stdout))
assert.strictEqual(stderr, '')
})
proc.stdout.setEncoding('utf-8')
proc.stderr.setEncoding('utf-8')
@ -52,33 +52,29 @@ TestPythonFinder.prototype.log = {
}
delete TestPythonFinder.prototype.env.NODE_GYP_FORCE_PYTHON
test('find python - python', function (t) {
t.plan(6)
it('find python - python', function () {
var f = new TestPythonFinder('python', done)
f.execFile = function (program, args, opts, cb) {
f.execFile = function (program, args, opts, cb) {
poison(f, 'execFile')
t.strictEqual(program, '/path/python')
t.ok(/sys\.version_info/.test(args[1]))
assert.strictEqual(program, '/path/python')
assert.ok(/sys\.version_info/.test(args[1]))
cb(null, '3.9.1')
}
t.strictEqual(program,
assert.strictEqual(program,
process.platform === 'win32' ? '"python"' : 'python')
t.ok(/sys\.executable/.test(args[1]))
assert.ok(/sys\.executable/.test(args[1]))
cb(null, '/path/python')
}
f.findPython()
function done (err, python) {
t.strictEqual(err, null)
t.strictEqual(python, '/path/python')
assert.strictEqual(err, null)
assert.strictEqual(python, '/path/python')
}
})
test('find python - python too old', function (t) {
t.plan(2)
it('find python - python too old', function () {
var f = new TestPythonFinder(null, done)
f.execFile = function (program, args, opts, cb) {
if (/sys\.executable/.test(args[args.length - 1])) {
@ -86,20 +82,18 @@ test('find python - python too old', function (t) {
} else if (/sys\.version_info/.test(args[args.length - 1])) {
cb(null, '2.3.4')
} else {
t.fail()
assert.fail()
}
}
f.findPython()
function done (err) {
t.ok(/Could not find any Python/.test(err))
t.ok(/not supported/i.test(f.errorLog))
assert.ok(/Could not find any Python/.test(err))
assert.ok(/not supported/i.test(f.errorLog))
}
})
test('find python - no python', function (t) {
t.plan(2)
it('find python - no python', function () {
var f = new TestPythonFinder(null, done)
f.execFile = function (program, args, opts, cb) {
if (/sys\.executable/.test(args[args.length - 1])) {
@ -107,49 +101,45 @@ test('find python - no python', function (t) {
} else if (/sys\.version_info/.test(args[args.length - 1])) {
cb(new Error('not a Python executable'))
} else {
t.fail()
assert.fail()
}
}
f.findPython()
function done (err) {
t.ok(/Could not find any Python/.test(err))
t.ok(/not in PATH/.test(f.errorLog))
assert.ok(/Could not find any Python/.test(err))
assert.ok(/not in PATH/.test(f.errorLog))
}
})
test('find python - no python2, no python, unix', function (t) {
t.plan(2)
it('find python - no python2, no python, unix', function () {
var f = new TestPythonFinder(null, done)
f.checkPyLauncher = t.fail
f.checkPyLauncher = assert.fail
f.win = false
f.execFile = function (program, args, opts, cb) {
if (/sys\.executable/.test(args[args.length - 1])) {
cb(new Error('not found'))
} else {
t.fail()
assert.fail()
}
}
f.findPython()
function done (err) {
t.ok(/Could not find any Python/.test(err))
t.ok(/not in PATH/.test(f.errorLog))
assert.ok(/Could not find any Python/.test(err))
assert.ok(/not in PATH/.test(f.errorLog))
}
})
test('find python - no python, use python launcher', function (t) {
t.plan(4)
it('find python - no python, use python launcher', function () {
var f = new TestPythonFinder(null, done)
f.win = true
f.execFile = function (program, args, opts, cb) {
if (program === 'py.exe') {
t.notEqual(args.indexOf('-3'), -1)
t.notEqual(args.indexOf('-c'), -1)
assert.notStrictEqual(args.indexOf('-3'), -1)
assert.notStrictEqual(args.indexOf('-c'), -1)
return cb(null, 'Z:\\snake.exe')
}
if (/sys\.executable/.test(args[args.length - 1])) {
@ -160,23 +150,21 @@ test('find python - no python, use python launcher', function (t) {
if (program === 'Z:\\snake.exe') {
cb(null, '3.9.0')
} else {
t.fail()
assert.fail()
}
} else {
t.fail()
assert.fail()
}
}
f.findPython()
function done (err, python) {
t.strictEqual(err, null)
t.strictEqual(python, 'Z:\\snake.exe')
assert.strictEqual(err, null)
assert.strictEqual(python, 'Z:\\snake.exe')
}
})
test('find python - no python, no python launcher, good guess', function (t) {
t.plan(2)
it('find python - no python, no python launcher, good guess', function () {
var f = new TestPythonFinder(null, done)
f.win = true
const expectedProgram = f.winDefaultLocations[0]
@ -191,20 +179,18 @@ test('find python - no python, no python launcher, good guess', function (t) {
/sys\.version_info/.test(args[args.length - 1])) {
cb(null, '3.7.3')
} else {
t.fail()
assert.fail()
}
}
f.findPython()
function done (err, python) {
t.strictEqual(err, null)
t.ok(python === expectedProgram)
assert.strictEqual(err, null)
assert.ok(python === expectedProgram)
}
})
test('find python - no python, no python launcher, bad guess', function (t) {
t.plan(2)
it('find python - no python, no python launcher, bad guess', function () {
var f = new TestPythonFinder(null, done)
f.win = true
@ -214,13 +200,14 @@ test('find python - no python, no python launcher, bad guess', function (t) {
} else if (/sys\.version_info/.test(args[args.length - 1])) {
cb(new Error('not a Python executable'))
} else {
t.fail()
assert.fail()
}
}
f.findPython()
function done (err) {
t.ok(/Could not find any Python/.test(err))
t.ok(/not in PATH/.test(f.errorLog))
assert.ok(/Could not find any Python/.test(err))
assert.ok(/not in PATH/.test(f.errorLog))
}
})
})

View file

@ -1,6 +1,7 @@
'use strict'
const test = require('tap').test
const { describe, it } = require('mocha')
const assert = require('assert')
const fs = require('fs')
const path = require('path')
const findVisualStudio = require('../lib/find-visualstudio')
@ -35,12 +36,11 @@ TestVisualStudioFinder.prototype.log = {
error: () => {}
}
test('VS2013', function (t) {
t.plan(4)
describe('find-visualstudio', function () {
it('VS2013', function () {
const finder = new TestVisualStudioFinder(semverV1, null, (err, info) => {
t.strictEqual(err, null)
t.deepEqual(info, {
assert.strictEqual(err, null)
assert.deepStrictEqual(info, {
msBuild: 'C:\\MSBuild12\\MSBuild.exe',
path: 'C:\\VS2013',
sdk: null,
@ -63,13 +63,13 @@ test('VS2013', function (t) {
case 'HKLM\\Software\\Wow6432Node\\Microsoft\\VisualStudio\\SxS\\VC7\\14.0':
continue
case 'HKLM\\Software\\Microsoft\\VisualStudio\\SxS\\VC7\\12.0':
t.pass(`expected search for registry value ${fullName}`)
assert.ok(true, `expected search for registry value ${fullName}`)
return cb(null, 'C:\\VS2013\\VC\\')
case 'HKLM\\Software\\Microsoft\\MSBuild\\ToolsVersions\\12.0\\MSBuildToolsPath':
t.pass(`expected search for registry value ${fullName}`)
assert.ok(true, `expected search for registry value ${fullName}`)
return cb(null, 'C:\\MSBuild12\\')
default:
t.fail(`unexpected search for registry value ${fullName}`)
assert.fail(`unexpected search for registry value ${fullName}`)
}
}
return cb(new Error())
@ -77,16 +77,14 @@ test('VS2013', function (t) {
finder.findVisualStudio()
})
test('VS2013 should not be found on new node versions', function (t) {
t.plan(2)
it('VS2013 should not be found on new node versions', function () {
const finder = new TestVisualStudioFinder({
major: 10,
minor: 0,
patch: 0
}, null, (err, info) => {
t.ok(/find .* Visual Studio/i.test(err), 'expect error')
t.false(info, 'no data')
assert.ok(/find .* Visual Studio/i.test(err), 'expect error')
assert.ok(!info, 'no data')
})
finder.findVisualStudio2017OrNewer = (cb) => {
@ -102,7 +100,7 @@ test('VS2013 should not be found on new node versions', function (t) {
case 'HKLM\\Software\\Wow6432Node\\Microsoft\\VisualStudio\\SxS\\VC7\\14.0':
continue
default:
t.fail(`unexpected search for registry value ${fullName}`)
assert.fail(`unexpected search for registry value ${fullName}`)
}
}
return cb(new Error())
@ -110,12 +108,10 @@ test('VS2013 should not be found on new node versions', function (t) {
finder.findVisualStudio()
})
test('VS2015', function (t) {
t.plan(4)
it('VS2015', function () {
const finder = new TestVisualStudioFinder(semverV1, null, (err, info) => {
t.strictEqual(err, null)
t.deepEqual(info, {
assert.strictEqual(err, null)
assert.deepStrictEqual(info, {
msBuild: 'C:\\MSBuild14\\MSBuild.exe',
path: 'C:\\VS2015',
sdk: null,
@ -135,13 +131,13 @@ test('VS2015', function (t) {
const fullName = `${keys[i]}\\${value}`
switch (fullName) {
case 'HKLM\\Software\\Microsoft\\VisualStudio\\SxS\\VC7\\14.0':
t.pass(`expected search for registry value ${fullName}`)
assert.ok(true, `expected search for registry value ${fullName}`)
return cb(null, 'C:\\VS2015\\VC\\')
case 'HKLM\\Software\\Microsoft\\MSBuild\\ToolsVersions\\14.0\\MSBuildToolsPath':
t.pass(`expected search for registry value ${fullName}`)
assert.ok(true, `expected search for registry value ${fullName}`)
return cb(null, 'C:\\MSBuild14\\')
default:
t.fail(`unexpected search for registry value ${fullName}`)
assert.fail(`unexpected search for registry value ${fullName}`)
}
}
return cb(new Error())
@ -149,64 +145,52 @@ test('VS2015', function (t) {
finder.findVisualStudio()
})
test('error from PowerShell', function (t) {
t.plan(2)
it('error from PowerShell', function () {
const finder = new TestVisualStudioFinder(semverV1, null, null)
finder.parseData(new Error(), '', '', (info) => {
t.ok(/use PowerShell/i.test(finder.errorLog[0]), 'expect error')
t.false(info, 'no data')
assert.ok(/use PowerShell/i.test(finder.errorLog[0]), 'expect error')
assert.ok(!info, 'no data')
})
})
test('empty output from PowerShell', function (t) {
t.plan(2)
it('empty output from PowerShell', function () {
const finder = new TestVisualStudioFinder(semverV1, null, null)
finder.parseData(null, '', '', (info) => {
t.ok(/use PowerShell/i.test(finder.errorLog[0]), 'expect error')
t.false(info, 'no data')
assert.ok(/use PowerShell/i.test(finder.errorLog[0]), 'expect error')
assert.ok(!info, 'no data')
})
})
test('output from PowerShell not JSON', function (t) {
t.plan(2)
it('output from PowerShell not JSON', function () {
const finder = new TestVisualStudioFinder(semverV1, null, null)
finder.parseData(null, 'AAAABBBB', '', (info) => {
t.ok(/use PowerShell/i.test(finder.errorLog[0]), 'expect error')
t.false(info, 'no data')
assert.ok(/use PowerShell/i.test(finder.errorLog[0]), 'expect error')
assert.ok(!info, 'no data')
})
})
test('wrong JSON from PowerShell', function (t) {
t.plan(2)
it('wrong JSON from PowerShell', function () {
const finder = new TestVisualStudioFinder(semverV1, null, null)
finder.parseData(null, '{}', '', (info) => {
t.ok(/use PowerShell/i.test(finder.errorLog[0]), 'expect error')
t.false(info, 'no data')
assert.ok(/use PowerShell/i.test(finder.errorLog[0]), 'expect error')
assert.ok(!info, 'no data')
})
})
test('empty JSON from PowerShell', function (t) {
t.plan(2)
it('empty JSON from PowerShell', function () {
const finder = new TestVisualStudioFinder(semverV1, null, null)
finder.parseData(null, '[]', '', (info) => {
t.ok(/find .* Visual Studio/i.test(finder.errorLog[0]), 'expect error')
t.false(info, 'no data')
assert.ok(/find .* Visual Studio/i.test(finder.errorLog[0]), 'expect error')
assert.ok(!info, 'no data')
})
})
test('future version', function (t) {
t.plan(3)
it('future version', function () {
const finder = new TestVisualStudioFinder(semverV1, null, null)
finder.parseData(null, JSON.stringify([{
@ -218,32 +202,28 @@ test('future version', function (t) {
path: 'C:\\VS',
version: '9999.9999.9999.9999'
}]), '', (info) => {
t.ok(/unknown version/i.test(finder.errorLog[0]), 'expect error')
t.ok(/find .* Visual Studio/i.test(finder.errorLog[1]), 'expect error')
t.false(info, 'no data')
assert.ok(/unknown version/i.test(finder.errorLog[0]), 'expect error')
assert.ok(/find .* Visual Studio/i.test(finder.errorLog[1]), 'expect error')
assert.ok(!info, 'no data')
})
})
test('single unusable VS2017', function (t) {
t.plan(3)
it('single unusable VS2017', function () {
const finder = new TestVisualStudioFinder(semverV1, null, null)
const file = path.join(__dirname, 'fixtures', 'VS_2017_Unusable.txt')
const data = fs.readFileSync(file)
finder.parseData(null, data, '', (info) => {
t.ok(/checking/i.test(finder.errorLog[0]), 'expect error')
t.ok(/find .* Visual Studio/i.test(finder.errorLog[2]), 'expect error')
t.false(info, 'no data')
assert.ok(/checking/i.test(finder.errorLog[0]), 'expect error')
assert.ok(/find .* Visual Studio/i.test(finder.errorLog[2]), 'expect error')
assert.ok(!info, 'no data')
})
})
test('minimal VS2017 Build Tools', function (t) {
t.plan(2)
it('minimal VS2017 Build Tools', function () {
const finder = new TestVisualStudioFinder(semverV1, null, (err, info) => {
t.strictEqual(err, null)
t.deepEqual(info, {
assert.strictEqual(err, null)
assert.deepStrictEqual(info, {
msBuild: 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\' +
'BuildTools\\MSBuild\\15.0\\Bin\\MSBuild.exe',
path:
@ -267,12 +247,10 @@ test('minimal VS2017 Build Tools', function (t) {
finder.findVisualStudio()
})
test('VS2017 Community with C++ workload', function (t) {
t.plan(2)
it('VS2017 Community with C++ workload', function () {
const finder = new TestVisualStudioFinder(semverV1, null, (err, info) => {
t.strictEqual(err, null)
t.deepEqual(info, {
assert.strictEqual(err, null)
assert.deepStrictEqual(info, {
msBuild: 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\' +
'Community\\MSBuild\\15.0\\Bin\\MSBuild.exe',
path:
@ -296,12 +274,10 @@ test('VS2017 Community with C++ workload', function (t) {
finder.findVisualStudio()
})
test('VS2017 Express', function (t) {
t.plan(2)
it('VS2017 Express', function () {
const finder = new TestVisualStudioFinder(semverV1, null, (err, info) => {
t.strictEqual(err, null)
t.deepEqual(info, {
assert.strictEqual(err, null)
assert.deepStrictEqual(info, {
msBuild: 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\' +
'WDExpress\\MSBuild\\15.0\\Bin\\MSBuild.exe',
path:
@ -324,12 +300,10 @@ test('VS2017 Express', function (t) {
finder.findVisualStudio()
})
test('VS2019 Preview with C++ workload', function (t) {
t.plan(2)
it('VS2019 Preview with C++ workload', function () {
const finder = new TestVisualStudioFinder(semverV1, null, (err, info) => {
t.strictEqual(err, null)
t.deepEqual(info, {
assert.strictEqual(err, null)
assert.deepStrictEqual(info, {
msBuild: 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\' +
'Preview\\MSBuild\\Current\\Bin\\MSBuild.exe',
path:
@ -353,12 +327,10 @@ test('VS2019 Preview with C++ workload', function (t) {
finder.findVisualStudio()
})
test('minimal VS2019 Build Tools', function (t) {
t.plan(2)
it('minimal VS2019 Build Tools', function () {
const finder = new TestVisualStudioFinder(semverV1, null, (err, info) => {
t.strictEqual(err, null)
t.deepEqual(info, {
assert.strictEqual(err, null)
assert.deepStrictEqual(info, {
msBuild: 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\' +
'BuildTools\\MSBuild\\Current\\Bin\\MSBuild.exe',
path:
@ -382,12 +354,10 @@ test('minimal VS2019 Build Tools', function (t) {
finder.findVisualStudio()
})
test('VS2019 Community with C++ workload', function (t) {
t.plan(2)
it('VS2019 Community with C++ workload', function () {
const finder = new TestVisualStudioFinder(semverV1, null, (err, info) => {
t.strictEqual(err, null)
t.deepEqual(info, {
assert.strictEqual(err, null)
assert.deepStrictEqual(info, {
msBuild: 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\' +
'Community\\MSBuild\\Current\\Bin\\MSBuild.exe',
path:
@ -411,9 +381,7 @@ test('VS2019 Community with C++ workload', function (t) {
finder.findVisualStudio()
})
test('VS2022 Preview with C++ workload', function (t) {
t.plan(2)
it('VS2022 Preview with C++ workload', function () {
const msBuildPath = process.arch === 'arm64'
? 'C:\\Program Files\\Microsoft Visual Studio\\2022\\' +
'Community\\MSBuild\\Current\\Bin\\arm64\\MSBuild.exe'
@ -421,8 +389,8 @@ test('VS2022 Preview with C++ workload', function (t) {
'Community\\MSBuild\\Current\\Bin\\MSBuild.exe'
const finder = new TestVisualStudioFinder(semverV1, null, (err, info) => {
t.strictEqual(err, null)
t.deepEqual(info, {
assert.strictEqual(err, null)
assert.deepStrictEqual(info, {
msBuild: msBuildPath,
path:
'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community',
@ -448,7 +416,7 @@ test('VS2022 Preview with C++ workload', function (t) {
finder.findVisualStudio()
})
function allVsVersions (t, finder) {
function allVsVersions (finder) {
finder.findVisualStudio2017OrNewer = (cb) => {
const data0 = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures',
'VS_2017_Unusable.txt')))
@ -486,250 +454,217 @@ function allVsVersions (t, finder) {
case 'HKLM\\Software\\Microsoft\\MSBuild\\ToolsVersions\\14.0\\MSBuildToolsPath':
return cb(null, 'C:\\MSBuild14\\')
default:
t.fail(`unexpected search for registry value ${fullName}`)
assert.fail(`unexpected search for registry value ${fullName}`)
}
}
return cb(new Error())
}
}
test('fail when looking for invalid path', function (t) {
t.plan(2)
it('fail when looking for invalid path', function () {
const finder = new TestVisualStudioFinder(semverV1, 'AABB', (err, info) => {
t.ok(/find .* Visual Studio/i.test(err), 'expect error')
t.false(info, 'no data')
assert.ok(/find .* Visual Studio/i.test(err), 'expect error')
assert.ok(!info, 'no data')
})
allVsVersions(t, finder)
allVsVersions(finder)
finder.findVisualStudio()
})
test('look for VS2013 by version number', function (t) {
t.plan(2)
it('look for VS2013 by version number', function () {
const finder = new TestVisualStudioFinder(semverV1, '2013', (err, info) => {
t.strictEqual(err, null)
t.deepEqual(info.versionYear, 2013)
assert.strictEqual(err, null)
assert.deepStrictEqual(info.versionYear, 2013)
})
allVsVersions(t, finder)
allVsVersions(finder)
finder.findVisualStudio()
})
test('look for VS2013 by installation path', function (t) {
t.plan(2)
it('look for VS2013 by installation path', function () {
const finder = new TestVisualStudioFinder(semverV1, 'C:\\VS2013',
(err, info) => {
t.strictEqual(err, null)
t.deepEqual(info.path, 'C:\\VS2013')
assert.strictEqual(err, null)
assert.deepStrictEqual(info.path, 'C:\\VS2013')
})
allVsVersions(t, finder)
allVsVersions(finder)
finder.findVisualStudio()
})
test('look for VS2015 by version number', function (t) {
t.plan(2)
it('look for VS2015 by version number', function () {
const finder = new TestVisualStudioFinder(semverV1, '2015', (err, info) => {
t.strictEqual(err, null)
t.deepEqual(info.versionYear, 2015)
assert.strictEqual(err, null)
assert.deepStrictEqual(info.versionYear, 2015)
})
allVsVersions(t, finder)
allVsVersions(finder)
finder.findVisualStudio()
})
test('look for VS2015 by installation path', function (t) {
t.plan(2)
it('look for VS2015 by installation path', function () {
const finder = new TestVisualStudioFinder(semverV1, 'C:\\VS2015',
(err, info) => {
t.strictEqual(err, null)
t.deepEqual(info.path, 'C:\\VS2015')
assert.strictEqual(err, null)
assert.deepStrictEqual(info.path, 'C:\\VS2015')
})
allVsVersions(t, finder)
allVsVersions(finder)
finder.findVisualStudio()
})
test('look for VS2017 by version number', function (t) {
t.plan(2)
it('look for VS2017 by version number', function () {
const finder = new TestVisualStudioFinder(semverV1, '2017', (err, info) => {
t.strictEqual(err, null)
t.deepEqual(info.versionYear, 2017)
assert.strictEqual(err, null)
assert.deepStrictEqual(info.versionYear, 2017)
})
allVsVersions(t, finder)
allVsVersions(finder)
finder.findVisualStudio()
})
test('look for VS2017 by installation path', function (t) {
t.plan(2)
it('look for VS2017 by installation path', function () {
const finder = new TestVisualStudioFinder(semverV1,
'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community',
(err, info) => {
t.strictEqual(err, null)
t.deepEqual(info.path,
assert.strictEqual(err, null)
assert.deepStrictEqual(info.path,
'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community')
})
allVsVersions(t, finder)
allVsVersions(finder)
finder.findVisualStudio()
})
test('look for VS2019 by version number', function (t) {
t.plan(2)
it('look for VS2019 by version number', function () {
const finder = new TestVisualStudioFinder(semverV1, '2019', (err, info) => {
t.strictEqual(err, null)
t.deepEqual(info.versionYear, 2019)
assert.strictEqual(err, null)
assert.deepStrictEqual(info.versionYear, 2019)
})
allVsVersions(t, finder)
allVsVersions(finder)
finder.findVisualStudio()
})
test('look for VS2019 by installation path', function (t) {
t.plan(2)
it('look for VS2019 by installation path', function () {
const finder = new TestVisualStudioFinder(semverV1,
'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools',
(err, info) => {
t.strictEqual(err, null)
t.deepEqual(info.path,
assert.strictEqual(err, null)
assert.deepStrictEqual(info.path,
'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools')
})
allVsVersions(t, finder)
allVsVersions(finder)
finder.findVisualStudio()
})
test('look for VS2022 by version number', function (t) {
t.plan(2)
it('look for VS2022 by version number', function () {
const finder = new TestVisualStudioFinder(semverV1, '2022', (err, info) => {
t.strictEqual(err, null)
t.deepEqual(info.versionYear, 2022)
assert.strictEqual(err, null)
assert.deepStrictEqual(info.versionYear, 2022)
})
finder.msBuildPathExists = (path) => {
return true
}
allVsVersions(t, finder)
allVsVersions(finder)
finder.findVisualStudio()
})
test('msvs_version match should be case insensitive', function (t) {
t.plan(2)
it('msvs_version match should be case insensitive', function () {
const finder = new TestVisualStudioFinder(semverV1,
'c:\\program files (x86)\\microsoft visual studio\\2019\\BUILDTOOLS',
(err, info) => {
t.strictEqual(err, null)
t.deepEqual(info.path,
assert.strictEqual(err, null)
assert.deepStrictEqual(info.path,
'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools')
})
allVsVersions(t, finder)
allVsVersions(finder)
finder.findVisualStudio()
})
test('latest version should be found by default', function (t) {
t.plan(2)
it('latest version should be found by default', function () {
const finder = new TestVisualStudioFinder(semverV1, null, (err, info) => {
t.strictEqual(err, null)
t.deepEqual(info.versionYear, 2022)
assert.strictEqual(err, null)
assert.deepStrictEqual(info.versionYear, 2022)
})
finder.msBuildPathExists = (path) => {
return true
}
allVsVersions(t, finder)
allVsVersions(finder)
finder.findVisualStudio()
})
test('run on a usable VS Command Prompt', function (t) {
t.plan(2)
it('run on a usable VS Command Prompt', function () {
process.env.VCINSTALLDIR = 'C:\\VS2015\\VC'
// VSINSTALLDIR is not defined on Visual C++ Build Tools 2015
delete process.env.VSINSTALLDIR
const finder = new TestVisualStudioFinder(semverV1, null, (err, info) => {
t.strictEqual(err, null)
t.deepEqual(info.path, 'C:\\VS2015')
assert.strictEqual(err, null)
assert.deepStrictEqual(info.path, 'C:\\VS2015')
})
allVsVersions(t, finder)
allVsVersions(finder)
finder.findVisualStudio()
})
test('VCINSTALLDIR match should be case insensitive', function (t) {
t.plan(2)
it('VCINSTALLDIR match should be case insensitive', function () {
process.env.VCINSTALLDIR =
'c:\\program files (x86)\\microsoft visual studio\\2019\\BUILDTOOLS\\VC'
const finder = new TestVisualStudioFinder(semverV1, null, (err, info) => {
t.strictEqual(err, null)
t.deepEqual(info.path,
assert.strictEqual(err, null)
assert.deepStrictEqual(info.path,
'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools')
})
allVsVersions(t, finder)
allVsVersions(finder)
finder.findVisualStudio()
})
test('run on a unusable VS Command Prompt', function (t) {
t.plan(2)
it('run on a unusable VS Command Prompt', function () {
process.env.VCINSTALLDIR =
'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildToolsUnusable\\VC'
const finder = new TestVisualStudioFinder(semverV1, null, (err, info) => {
t.ok(/find .* Visual Studio/i.test(err), 'expect error')
t.false(info, 'no data')
assert.ok(/find .* Visual Studio/i.test(err), 'expect error')
assert.ok(!info, 'no data')
})
allVsVersions(t, finder)
allVsVersions(finder)
finder.findVisualStudio()
})
test('run on a VS Command Prompt with matching msvs_version', function (t) {
t.plan(2)
it('run on a VS Command Prompt with matching msvs_version', function () {
process.env.VCINSTALLDIR = 'C:\\VS2015\\VC'
const finder = new TestVisualStudioFinder(semverV1, 'C:\\VS2015',
(err, info) => {
t.strictEqual(err, null)
t.deepEqual(info.path, 'C:\\VS2015')
assert.strictEqual(err, null)
assert.deepStrictEqual(info.path, 'C:\\VS2015')
})
allVsVersions(t, finder)
allVsVersions(finder)
finder.findVisualStudio()
})
test('run on a VS Command Prompt with mismatched msvs_version', function (t) {
t.plan(2)
it('run on a VS Command Prompt with mismatched msvs_version', function () {
process.env.VCINSTALLDIR =
'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC'
const finder = new TestVisualStudioFinder(semverV1, 'C:\\VS2015',
(err, info) => {
t.ok(/find .* Visual Studio/i.test(err), 'expect error')
t.false(info, 'no data')
assert.ok(/find .* Visual Studio/i.test(err), 'expect error')
assert.ok(!info, 'no data')
})
allVsVersions(t, finder)
allVsVersions(finder)
finder.findVisualStudio()
})
})

View file

@ -1,6 +1,7 @@
'use strict'
const { test } = require('tap')
const { describe, it, after } = require('mocha')
const assert = require('assert')
const path = require('path')
const os = require('os')
const util = require('util')
@ -14,15 +15,14 @@ const streamPipeline = util.promisify(stream.pipeline)
log.level = 'error' // we expect a warning
test('EACCES retry once', async (t) => {
t.plan(3)
describe('install', function () {
it('EACCES retry once', async () => {
const fs = {
promises: {
stat (_) {
const err = new Error()
err.code = 'EACCES'
t.ok(true)
assert.ok(true)
throw err
}
}
@ -46,9 +46,9 @@ test('EACCES retry once', async (t) => {
try {
await install(fs, Gyp, [])
} catch (err) {
t.ok(true)
assert.ok(true)
if (/"pre" versions of node cannot be installed/.test(err.message)) {
t.ok(true)
assert.ok(true)
}
}
})
@ -59,12 +59,12 @@ const skipParallelInstallTests = process.env.FAST_TEST ||
semver.prerelease(process.version) !== null ||
semver.satisfies(process.version, '<10')
async function parallelInstallsTest (t, fs, devDir, prog) {
async function parallelInstallsTest (test, fs, devDir, prog) {
if (skipParallelInstallTests) {
return t.skip('Skipping parallel installs test due to test environment configuration')
return test.skip('Skipping parallel installs test due to test environment configuration')
}
t.tearDown(async () => {
after(async () => {
await util.promisify(rimraf)(devDir)
})
@ -85,7 +85,9 @@ async function parallelInstallsTest (t, fs, devDir, prog) {
])
}
test('parallel installs (ensure=true)', async (t) => {
it('parallel installs (ensure=true)', async function () {
this.timeout(600000)
const fs = require('graceful-fs')
const devDir = await util.promisify(fs.mkdtemp)(path.join(os.tmpdir(), 'node-gyp-test-'))
@ -95,10 +97,12 @@ test('parallel installs (ensure=true)', async (t) => {
prog.opts.ensure = true
log.level = 'warn'
await parallelInstallsTest(t, fs, devDir, prog)
await parallelInstallsTest(this, fs, devDir, prog)
})
test('parallel installs (ensure=false)', async (t) => {
it('parallel installs (ensure=false)', async function () {
this.timeout(600000)
const fs = require('graceful-fs')
const devDir = await util.promisify(fs.mkdtemp)(path.join(os.tmpdir(), 'node-gyp-test-'))
@ -108,10 +112,12 @@ test('parallel installs (ensure=false)', async (t) => {
prog.opts.ensure = false
log.level = 'warn'
await parallelInstallsTest(t, fs, devDir, prog)
await parallelInstallsTest(this, fs, devDir, prog)
})
test('parallel installs (tarball)', async (t) => {
it('parallel installs (tarball)', async function () {
this.timeout(600000)
const fs = require('graceful-fs')
const devDir = await util.promisify(fs.mkdtemp)(path.join(os.tmpdir(), 'node-gyp-test-'))
@ -122,9 +128,10 @@ test('parallel installs (tarball)', async (t) => {
log.level = 'warn'
await streamPipeline(
(await download(prog, 'https://nodejs.org/dist/v16.0.0/node-v16.0.0.tar.gz')).body,
(await download(prog, `https://nodejs.org/dist/${process.version}/node-${process.version}.tar.gz`)).body,
fs.createWriteStream(prog.opts.tarball)
)
await parallelInstallsTest(t, fs, devDir, prog)
await parallelInstallsTest(this, fs, devDir, prog)
})
})

View file

@ -1,11 +1,11 @@
'use strict'
const test = require('tap').test
const { describe, it } = require('mocha')
const assert = require('assert')
const gyp = require('../lib/node-gyp')
test('options in environment', (t) => {
t.plan(1)
describe('options', function () {
it('options in environment', () => {
// `npm test` dumps a ton of npm_config_* variables in the environment.
Object.keys(process.env)
.filter((key) => /^npm_config_/.test(key))
@ -27,16 +27,15 @@ test('options in environment', (t) => {
const g = gyp()
g.parseArgv(['rebuild']) // Also sets opts.argv.
t.deepEqual(Object.keys(g.opts).sort(), keys.sort())
assert.deepStrictEqual(Object.keys(g.opts).sort(), keys.sort())
})
test('options with spaces in environment', (t) => {
t.plan(1)
it('options with spaces in environment', () => {
process.env.npm_config_force_process_config = 'true'
const g = gyp()
g.parseArgv(['rebuild']) // Also sets opts.argv.
t.equal(g.opts['force-process-config'], 'true')
assert.strictEqual(g.opts['force-process-config'], 'true')
})
})

View file

@ -1,17 +1,17 @@
'use strict'
const test = require('tap').test
const { describe, it } = require('mocha')
const assert = require('assert')
const processRelease = require('../lib/process-release')
test('test process release - process.version = 0.8.20', function (t) {
t.plan(2)
describe('process-release', function () {
it('test process release - process.version = 0.8.20', function () {
var release = processRelease([], { opts: {} }, 'v0.8.20', null)
t.equal(release.semver.version, '0.8.20')
assert.strictEqual(release.semver.version, '0.8.20')
delete release.semver
t.deepEqual(release, {
assert.deepStrictEqual(release, {
version: '0.8.20',
name: 'node',
baseUrl: 'https://nodejs.org/dist/v0.8.20/',
@ -24,15 +24,13 @@ test('test process release - process.version = 0.8.20', function (t) {
})
})
test('test process release - process.version = 0.10.21', function (t) {
t.plan(2)
it('test process release - process.version = 0.10.21', function () {
var release = processRelease([], { opts: {} }, 'v0.10.21', null)
t.equal(release.semver.version, '0.10.21')
assert.strictEqual(release.semver.version, '0.10.21')
delete release.semver
t.deepEqual(release, {
assert.deepStrictEqual(release, {
version: '0.10.21',
name: 'node',
baseUrl: 'https://nodejs.org/dist/v0.10.21/',
@ -46,15 +44,13 @@ test('test process release - process.version = 0.10.21', function (t) {
})
// prior to -headers.tar.gz
test('test process release - process.version = 0.12.9', function (t) {
t.plan(2)
it('test process release - process.version = 0.12.9', function () {
var release = processRelease([], { opts: {} }, 'v0.12.9', null)
t.equal(release.semver.version, '0.12.9')
assert.strictEqual(release.semver.version, '0.12.9')
delete release.semver
t.deepEqual(release, {
assert.deepStrictEqual(release, {
version: '0.12.9',
name: 'node',
baseUrl: 'https://nodejs.org/dist/v0.12.9/',
@ -68,15 +64,13 @@ test('test process release - process.version = 0.12.9', function (t) {
})
// prior to -headers.tar.gz
test('test process release - process.version = 0.10.41', function (t) {
t.plan(2)
it('test process release - process.version = 0.10.41', function () {
var release = processRelease([], { opts: {} }, 'v0.10.41', null)
t.equal(release.semver.version, '0.10.41')
assert.strictEqual(release.semver.version, '0.10.41')
delete release.semver
t.deepEqual(release, {
assert.deepStrictEqual(release, {
version: '0.10.41',
name: 'node',
baseUrl: 'https://nodejs.org/dist/v0.10.41/',
@ -90,15 +84,13 @@ test('test process release - process.version = 0.10.41', function (t) {
})
// has -headers.tar.gz
test('test process release - process.release ~ node@0.10.42', function (t) {
t.plan(2)
it('test process release - process.release ~ node@0.10.42', function () {
var release = processRelease([], { opts: {} }, 'v0.10.42', null)
t.equal(release.semver.version, '0.10.42')
assert.strictEqual(release.semver.version, '0.10.42')
delete release.semver
t.deepEqual(release, {
assert.deepStrictEqual(release, {
version: '0.10.42',
name: 'node',
baseUrl: 'https://nodejs.org/dist/v0.10.42/',
@ -112,15 +104,13 @@ test('test process release - process.release ~ node@0.10.42', function (t) {
})
// has -headers.tar.gz
test('test process release - process.release ~ node@0.12.10', function (t) {
t.plan(2)
it('test process release - process.release ~ node@0.12.10', function () {
var release = processRelease([], { opts: {} }, 'v0.12.10', null)
t.equal(release.semver.version, '0.12.10')
assert.strictEqual(release.semver.version, '0.12.10')
delete release.semver
t.deepEqual(release, {
assert.deepStrictEqual(release, {
version: '0.12.10',
name: 'node',
baseUrl: 'https://nodejs.org/dist/v0.12.10/',
@ -133,18 +123,16 @@ test('test process release - process.release ~ node@0.12.10', function (t) {
})
})
test('test process release - process.release ~ node@4.1.23', function (t) {
t.plan(2)
it('test process release - process.release ~ node@4.1.23', function () {
var release = processRelease([], { opts: {} }, 'v4.1.23', {
name: 'node',
headersUrl: 'https://nodejs.org/dist/v4.1.23/node-v4.1.23-headers.tar.gz'
})
t.equal(release.semver.version, '4.1.23')
assert.strictEqual(release.semver.version, '4.1.23')
delete release.semver
t.deepEqual(release, {
assert.deepStrictEqual(release, {
version: '4.1.23',
name: 'node',
baseUrl: 'https://nodejs.org/dist/v4.1.23/',
@ -157,18 +145,16 @@ test('test process release - process.release ~ node@4.1.23', function (t) {
})
})
test('test process release - process.release ~ node@4.1.23 / corp build', function (t) {
t.plan(2)
it('test process release - process.release ~ node@4.1.23 / corp build', function () {
var release = processRelease([], { opts: {} }, 'v4.1.23', {
name: 'node',
headersUrl: 'https://some.custom.location/node-v4.1.23-headers.tar.gz'
})
t.equal(release.semver.version, '4.1.23')
assert.strictEqual(release.semver.version, '4.1.23')
delete release.semver
t.deepEqual(release, {
assert.deepStrictEqual(release, {
version: '4.1.23',
name: 'node',
baseUrl: 'https://some.custom.location/',
@ -181,9 +167,7 @@ test('test process release - process.release ~ node@4.1.23 / corp build', functi
})
})
test('test process release - process.release ~ node@12.8.0 Windows', function (t) {
t.plan(2)
it('test process release - process.release ~ node@12.8.0 Windows', function () {
var release = processRelease([], { opts: {} }, 'v12.8.0', {
name: 'node',
sourceUrl: 'https://nodejs.org/download/release/v12.8.0/node-v12.8.0.tar.gz',
@ -191,10 +175,10 @@ test('test process release - process.release ~ node@12.8.0 Windows', function (t
libUrl: 'https://nodejs.org/download/release/v12.8.0/win-x64/node.lib'
})
t.equal(release.semver.version, '12.8.0')
assert.strictEqual(release.semver.version, '12.8.0')
delete release.semver
t.deepEqual(release, {
assert.deepStrictEqual(release, {
version: '12.8.0',
name: 'node',
baseUrl: 'https://nodejs.org/download/release/v12.8.0/',
@ -207,9 +191,7 @@ test('test process release - process.release ~ node@12.8.0 Windows', function (t
})
})
test('test process release - process.release ~ node@12.8.0 Windows ARM64', function (t) {
t.plan(2)
it('test process release - process.release ~ node@12.8.0 Windows ARM64', function () {
var release = processRelease([], { opts: {} }, 'v12.8.0', {
name: 'node',
sourceUrl: 'https://unofficial-builds.nodejs.org/download/release/v12.8.0/node-v12.8.0.tar.gz',
@ -217,10 +199,10 @@ test('test process release - process.release ~ node@12.8.0 Windows ARM64', funct
libUrl: 'https://unofficial-builds.nodejs.org/download/release/v12.8.0/win-arm64/node.lib'
})
t.equal(release.semver.version, '12.8.0')
assert.strictEqual(release.semver.version, '12.8.0')
delete release.semver
t.deepEqual(release, {
assert.deepStrictEqual(release, {
version: '12.8.0',
name: 'node',
baseUrl: 'https://unofficial-builds.nodejs.org/download/release/v12.8.0/',
@ -233,18 +215,16 @@ test('test process release - process.release ~ node@12.8.0 Windows ARM64', funct
})
})
test('test process release - process.release ~ node@4.1.23 --target=0.10.40', function (t) {
t.plan(2)
it('test process release - process.release ~ node@4.1.23 --target=0.10.40', function () {
var release = processRelease([], { opts: { target: '0.10.40' } }, 'v4.1.23', {
name: 'node',
headersUrl: 'https://nodejs.org/dist/v4.1.23/node-v4.1.23-headers.tar.gz'
})
t.equal(release.semver.version, '0.10.40')
assert.strictEqual(release.semver.version, '0.10.40')
delete release.semver
t.deepEqual(release, {
assert.deepStrictEqual(release, {
version: '0.10.40',
name: 'node',
baseUrl: 'https://nodejs.org/dist/v0.10.40/',
@ -257,18 +237,16 @@ test('test process release - process.release ~ node@4.1.23 --target=0.10.40', fu
})
})
test('test process release - process.release ~ node@4.1.23 --dist-url=https://foo.bar/baz', function (t) {
t.plan(2)
it('test process release - process.release ~ node@4.1.23 --dist-url=https://foo.bar/baz', function () {
var release = processRelease([], { opts: { 'dist-url': 'https://foo.bar/baz' } }, 'v4.1.23', {
name: 'node',
headersUrl: 'https://nodejs.org/dist/v4.1.23/node-v4.1.23-headers.tar.gz'
})
t.equal(release.semver.version, '4.1.23')
assert.strictEqual(release.semver.version, '4.1.23')
delete release.semver
t.deepEqual(release, {
assert.deepStrictEqual(release, {
version: '4.1.23',
name: 'node',
baseUrl: 'https://foo.bar/baz/v4.1.23/',
@ -281,18 +259,16 @@ test('test process release - process.release ~ node@4.1.23 --dist-url=https://fo
})
})
test('test process release - process.release ~ frankenstein@4.1.23', function (t) {
t.plan(2)
it('test process release - process.release ~ frankenstein@4.1.23', function () {
var release = processRelease([], { opts: {} }, 'v4.1.23', {
name: 'frankenstein',
headersUrl: 'https://frankensteinjs.org/dist/v4.1.23/frankenstein-v4.1.23-headers.tar.gz'
})
t.equal(release.semver.version, '4.1.23')
assert.strictEqual(release.semver.version, '4.1.23')
delete release.semver
t.deepEqual(release, {
assert.deepStrictEqual(release, {
version: '4.1.23',
name: 'frankenstein',
baseUrl: 'https://frankensteinjs.org/dist/v4.1.23/',
@ -305,18 +281,16 @@ test('test process release - process.release ~ frankenstein@4.1.23', function (t
})
})
test('test process release - process.release ~ frankenstein@4.1.23 --dist-url=http://foo.bar/baz/', function (t) {
t.plan(2)
it('test process release - process.release ~ frankenstein@4.1.23 --dist-url=http://foo.bar/baz/', function () {
var release = processRelease([], { opts: { 'dist-url': 'http://foo.bar/baz/' } }, 'v4.1.23', {
name: 'frankenstein',
headersUrl: 'https://frankensteinjs.org/dist/v4.1.23/frankenstein-v4.1.23.tar.gz'
})
t.equal(release.semver.version, '4.1.23')
assert.strictEqual(release.semver.version, '4.1.23')
delete release.semver
t.deepEqual(release, {
assert.deepStrictEqual(release, {
version: '4.1.23',
name: 'frankenstein',
baseUrl: 'http://foo.bar/baz/v4.1.23/',
@ -329,18 +303,16 @@ test('test process release - process.release ~ frankenstein@4.1.23 --dist-url=ht
})
})
test('test process release - process.release ~ node@4.0.0-rc.4', function (t) {
t.plan(2)
it('test process release - process.release ~ node@4.0.0-rc.4', function () {
var release = processRelease([], { opts: {} }, 'v4.0.0-rc.4', {
name: 'node',
headersUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/node-v4.0.0-rc.4-headers.tar.gz'
})
t.equal(release.semver.version, '4.0.0-rc.4')
assert.strictEqual(release.semver.version, '4.0.0-rc.4')
delete release.semver
t.deepEqual(release, {
assert.deepStrictEqual(release, {
version: '4.0.0-rc.4',
name: 'node',
baseUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/',
@ -353,9 +325,7 @@ test('test process release - process.release ~ node@4.0.0-rc.4', function (t) {
})
})
test('test process release - process.release ~ node@4.0.0-rc.4 passed as argv[0]', function (t) {
t.plan(2)
it('test process release - process.release ~ node@4.0.0-rc.4 passed as argv[0]', function () {
// note the missing 'v' on the arg, it should normalise when checking
// whether we're on the default or not
var release = processRelease(['4.0.0-rc.4'], { opts: {} }, 'v4.0.0-rc.4', {
@ -363,10 +333,10 @@ test('test process release - process.release ~ node@4.0.0-rc.4 passed as argv[0]
headersUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/node-v4.0.0-rc.4-headers.tar.gz'
})
t.equal(release.semver.version, '4.0.0-rc.4')
assert.strictEqual(release.semver.version, '4.0.0-rc.4')
delete release.semver
t.deepEqual(release, {
assert.deepStrictEqual(release, {
version: '4.0.0-rc.4',
name: 'node',
baseUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/',
@ -379,9 +349,7 @@ test('test process release - process.release ~ node@4.0.0-rc.4 passed as argv[0]
})
})
test('test process release - process.release ~ node@4.0.0-rc.4 - bogus string passed as argv[0]', function (t) {
t.plan(2)
it('test process release - process.release ~ node@4.0.0-rc.4 - bogus string passed as argv[0]', function () {
// additional arguments can be passed in on the commandline that should be ignored if they
// are not specifying a valid version @ position 0
var release = processRelease(['this is no version!'], { opts: {} }, 'v4.0.0-rc.4', {
@ -389,10 +357,10 @@ test('test process release - process.release ~ node@4.0.0-rc.4 - bogus string pa
headersUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/node-v4.0.0-rc.4-headers.tar.gz'
})
t.equal(release.semver.version, '4.0.0-rc.4')
assert.strictEqual(release.semver.version, '4.0.0-rc.4')
delete release.semver
t.deepEqual(release, {
assert.deepStrictEqual(release, {
version: '4.0.0-rc.4',
name: 'node',
baseUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/',
@ -405,9 +373,7 @@ test('test process release - process.release ~ node@4.0.0-rc.4 - bogus string pa
})
})
test('test process release - NODEJS_ORG_MIRROR', function (t) {
t.plan(2)
it('test process release - NODEJS_ORG_MIRROR', function () {
process.env.NODEJS_ORG_MIRROR = 'http://foo.bar'
var release = processRelease([], { opts: {} }, 'v4.1.23', {
@ -415,10 +381,10 @@ test('test process release - NODEJS_ORG_MIRROR', function (t) {
headersUrl: 'https://nodejs.org/dist/v4.1.23/node-v4.1.23-headers.tar.gz'
})
t.equal(release.semver.version, '4.1.23')
assert.strictEqual(release.semver.version, '4.1.23')
delete release.semver
t.deepEqual(release, {
assert.deepStrictEqual(release, {
version: '4.1.23',
name: 'node',
baseUrl: 'http://foo.bar/v4.1.23/',
@ -432,3 +398,4 @@ test('test process release - NODEJS_ORG_MIRROR', function (t) {
delete process.env.NODEJS_ORG_MIRROR
})
})