This commit is contained in:
lalBi94
2023-03-05 13:23:23 +01:00
commit 7bc56c09b5
14034 changed files with 1834369 additions and 0 deletions

3
node_modules/node-gyp/test/common.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
const envPaths = require('env-paths')
module.exports.devDir = () => envPaths('node-gyp', { suffix: '' }).cache

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

40
node_modules/node-gyp/test/fixtures/ca-bundle.crt generated vendored Normal file
View File

@@ -0,0 +1,40 @@
-----BEGIN CERTIFICATE-----
MIIDJjCCAg4CAhnOMA0GCSqGSIb3DQEBBQUAMH0xCzAJBgNVBAYTAlVTMQswCQYD
VQQIDAJDQTEWMBQGA1UEBwwNU2FuIEZyYW5jaXNjbzEZMBcGA1UECgwQU3Ryb25n
TG9vcCwgSW5jLjESMBAGA1UECwwJU3Ryb25nT3BzMRowGAYDVQQDDBFjYS5zdHJv
bmdsb29wLmNvbTAeFw0xNTEyMDgyMzM1MzNaFw00MzA0MjQyMzM1MzNaMBkxFzAV
BgNVBAMMDnN0cm9uZ2xvb3AuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
CgKCAQEAwOYI7OZ2FX/YjRgLZoDQlbPc5UZXU/j0e1wwiJNPtPEax9Y5Uoza0Pnt
Ikzkc2SfvQ+IJrhXo385tI0W5juuqbHnE7UrjUuPjUX6NHevkxcs/flmjan5wnZM
cPsGhH71WDuUEEflvZihf2Se2x+xgZtMhc5XGmVmRuZFYKvkgUhA2/w8/QrK+jPT
n9QRJxZjWNh2RBdC1B7u4jffSmOSUljYFH1I2eTeY+Rdi6YUIYSU9gEoZxsv3Tia
SomfMF5jt2Mouo6MzA+IhLvvFjcrcph1Qxgi9RkfdCMMd+Ipm9YWELkyG1bDRpQy
0iyHD4gvVsAqz1Y2KdRSdc3Kt+nTqwIDAQABoxkwFzAVBgNVHREEDjAMhwQAAAAA
hwR/AAABMA0GCSqGSIb3DQEBBQUAA4IBAQAhy4J0hML3NgmDRHdL5/iTucBe22Mf
jJjg2aifD1S187dHm+Il4qZNO2plWwAhN0h704f+8wpsaALxUvBIu6nvlvcMP5PH
jGN5JLe2Km3UaPvYOQU2SgacLilu+uBcIo2JSHLV6O7ziqUj5Gior6YxDLCtEZie
Ea8aX5/YjuACtEMJ1JjRqjgkM66XAoUe0E8onOK3FgTIO3tGoTJwRp0zS50pFuP0
PsZtT04ck6mmXEXXknNoAyBCvPypfms9OHqcUIW9fiQnrGbS/Ri4QSQYj0DtFk/1
na4fY1gf3zTHxH8259b/TOOaPfTnCEsOQtjUrWNR4xhmVZ+HJy4yytUW
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIDbzCCAlcCAmm6MA0GCSqGSIb3DQEBCwUAMH0xCzAJBgNVBAYTAlVTMQswCQYD
VQQIDAJDQTEWMBQGA1UEBwwNU2FuIEZyYW5jaXNjbzEZMBcGA1UECgwQU3Ryb25n
TG9vcCwgSW5jLjESMBAGA1UECwwJU3Ryb25nT3BzMRowGAYDVQQDDBFjYS5zdHJv
bmdsb29wLmNvbTAeFw0xNTEyMDgyMzM1MzNaFw00MzA0MjQyMzM1MzNaMH0xCzAJ
BgNVBAYTAlVTMQswCQYDVQQIDAJDQTEWMBQGA1UEBwwNU2FuIEZyYW5jaXNjbzEZ
MBcGA1UECgwQU3Ryb25nTG9vcCwgSW5jLjESMBAGA1UECwwJU3Ryb25nT3BzMRow
GAYDVQQDDBFjYS5zdHJvbmdsb29wLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEP
ADCCAQoCggEBANfj86jkvvYDjHBgiqWhk9Cj+bqiMq3MqnV0CBO4iuK33Fo6XssE
H+yVdXlIBFbFe6t655MdBVOR2Sfj7WqNh96vhu6PyDHiwcQlTaiLU6nhIed1J4Wv
lvnJHFmp8Wbtx5AgLT4UYu03ftvXEl2DLi3vhSL2tRM1ebXHB/KPbRWkb25DPX0P
foOHot3f2dgNe2x6kponf7E/QDmAu3s7Nlkfh+ryDhgGU7wocXEhXbprNqRqOGNo
xbXgUI+/9XDxYT/7Gn5LF/fPjtN+aB0SKMnTsDhprVlZie83mlqJ46fOOrR+vrsQ
mi/1m/TadrARtZoIExC/cQRdVM05EK4tUa8CAwEAATANBgkqhkiG9w0BAQsFAAOC
AQEAQ7k5WhyhDTIGYCNzRnrMHWSzGqa1y4tJMW06wafJNRqTm1cthq1ibc6Hfq5a
K10K0qMcgauRTfQ1MWrVCTW/KnJ1vkhiTOH+RvxapGn84gSaRmV6KZen0+gMsgae
KEGe/3Hn+PmDVV+PTamHgPACfpTww38WHIe/7Ce9gHfG7MZ8cKHNZhDy0IAYPln+
YRwMLd7JNQffHAbWb2CE1mcea4H/12U8JZW5tHCF6y9V+7IuDzqwIrLKcW3lG17n
VUG6ODF/Ryqn3V5X+TL91YyXi6c34y34IpC7MQDV/67U7+5Bp5CfeDPWW2wVSrW+
uGZtfEvhbNm6m2i4UNmpCXxUZQ==
-----END CERTIFICATE-----

21
node_modules/node-gyp/test/fixtures/ca.crt generated vendored Normal file
View File

@@ -0,0 +1,21 @@
-----BEGIN CERTIFICATE-----
MIIDZDCCAkwCCQCAzfCLqrJvuTANBgkqhkiG9w0BAQsFADB0MQswCQYDVQQGEwJV
UzELMAkGA1UECAwCQ0ExEDAOBgNVBAoMB05vZGUuanMxETAPBgNVBAsMCG5vZGUt
Z3lwMRIwEAYDVQQDDAlsb2NhbGhvc3QxHzAdBgkqhkiG9w0BCQEWEGJ1aWxkQG5v
ZGVqcy5vcmcwHhcNMTkwNjIyMDYyMjMzWhcNMjIwNDExMDYyMjMzWjB0MQswCQYD
VQQGEwJVUzELMAkGA1UECAwCQ0ExEDAOBgNVBAoMB05vZGUuanMxETAPBgNVBAsM
CG5vZGUtZ3lwMRIwEAYDVQQDDAlsb2NhbGhvc3QxHzAdBgkqhkiG9w0BCQEWEGJ1
aWxkQG5vZGVqcy5vcmcwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDS
CHjvtVW4HdbbUwZ/ZV9s6U4x0KSoyNQrsCZjB8kRpFPe50DS5mfmu2SNBGYKRgzk
4QEEwFB9N2o8YTWsCefSRl6ti4ToPZqulU4hhRKYrEGtMJcRzi3IN7s200JaO3UH
01Su8ruO0NESb5zEU1Ykfh8Lub8TGEAINmgI61d/5d5Aq3kDjUHQJt1Ekw03Ylnu
juQyCGZxLxnngu0mIvwzyL/UeeUgsfQLzvppUk6In7tC1zzMjSPWo0c8qu6KvrW4
bKYnkZkzdQifzbpO5ERMEsh5HWq0uHa6+dgcVHFvlhdqF4Uat87ygNplVf0txsZB
MNVqbz1k6xkZYMnzDoydAgMBAAEwDQYJKoZIhvcNAQELBQADggEBADspZGtKpWxy
J1W3FA1aeQhMvequQTcMRz4avkm4K4HfTdV1iVD4CbvdezBphouBlyLVLDFJP7RZ
m7dBJVgBwnxufoFLne8cR2MGqDRoySbFT1AtDJdxabE6Fg+QGUpgOQfeBJ6ANlSB
+qJ+HG4QA+Ouh5hxz9mgYwkIsMUABHiwENdZ/kT8Edw4xKgd3uH0YP4iiePMD66c
rzW3uXH5J1jnKgBlpxtog4P6dHCcoq+PZJ17W5bdXNyqC1LPzQqniZ2BNcEZ4ix3
slAZAOWD1zLLGJhBPMV1fa0sHNBWc6oicr3YK/IDb0cp9kiLvnUu1pHy+LWQGqtC
rceJuGsnJEQ=
-----END CERTIFICATE-----

View File

@@ -0,0 +1,6 @@
# Test configuration
{
'variables': {
'build_with_electron': true
}
}

21
node_modules/node-gyp/test/fixtures/server.crt generated vendored Normal file
View File

@@ -0,0 +1,21 @@
-----BEGIN CERTIFICATE-----
MIIDYjCCAkoCCQCSlmGR7KzZGTANBgkqhkiG9w0BAQsFADB0MQswCQYDVQQGEwJV
UzELMAkGA1UECAwCQ0ExEDAOBgNVBAoMB05vZGUuanMxETAPBgNVBAsMCG5vZGUt
Z3lwMRIwEAYDVQQDDAlsb2NhbGhvc3QxHzAdBgkqhkiG9w0BCQEWEGJ1aWxkQG5v
ZGVqcy5vcmcwHhcNMTkwNjIyMDYyNTU1WhcNMjkwNjE5MDYyNTU1WjByMQswCQYD
VQQGEwJVUzELMAkGA1UECAwCQ0ExEDAOBgNVBAoMB05vZGUuanMxETAPBgNVBAsM
CG5vZGUtZ3lwMRIwEAYDVQQDDAlsb2NhbGhvc3QxHTAbBgkqhkiG9w0BCQEWDmJ1
aWxkQGlvanMub3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6S1E
2WchgmbJYqCnpN7310ZgHjIOqeJe6MpSue2u6z6mTNd5izgvQNaANmn3xLFCS5zs
uZaTvdPYPkcmSQzb1YcZSUYnAxZifjYARc6kb5GSBl3q+O70ELyFrimXfZ4JI+bd
IG9KiHY17DlvZZZj/csGYVWWg0mkeH3O5LPX6/DXQVh/9+gZ02/cdIBCAtZHQwqx
7tF/qZA/kD4GZNFpU1DYHzf9H6g9htoCqmNHQWrV2T9yFybt6mbZp9kglBmyKYCc
7hmQnb7N/mHn1yIuwhBsirCJTfKH86gN81u8M3+SVHA2VUHDllcNhpDWlmInXA+I
tHdGZHCp95ohqpCPgQIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQCdvYj6CD0ZLwT2
3t1r+deC3TJuHlNVSeKeT7wIfFnh2FW5riGV0q/w6eXPLTHjuiS6YmpAAbdNUgX/
sq64FqI2RLpX6pgY5yB0SKopMcJxMLKqmF4zHpIHxtYN5EmN3PR0vehneBR/nZ2T
3ikvWD5JeXlm7Dfw+tjijdxM/sEoDWErGup4mMKMd1s5s830p+ITJUa50d0DLFdH
mqPSbUZF8mMPwGJd+nu1Ht3gTLtK7+gYJgGtXMJmGC0Qg77EJHDB2NbotgDGNmSU
1H9BpAeFHHIcbh2Rr7kkTvnh/c03vFe+CsDZmezcmRpRzW1fKj3YbfqBxU4XwJrL
a5T/N9xU
-----END CERTIFICATE-----

27
node_modules/node-gyp/test/fixtures/server.key generated vendored Normal file
View File

@@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEA6S1E2WchgmbJYqCnpN7310ZgHjIOqeJe6MpSue2u6z6mTNd5
izgvQNaANmn3xLFCS5zsuZaTvdPYPkcmSQzb1YcZSUYnAxZifjYARc6kb5GSBl3q
+O70ELyFrimXfZ4JI+bdIG9KiHY17DlvZZZj/csGYVWWg0mkeH3O5LPX6/DXQVh/
9+gZ02/cdIBCAtZHQwqx7tF/qZA/kD4GZNFpU1DYHzf9H6g9htoCqmNHQWrV2T9y
Fybt6mbZp9kglBmyKYCc7hmQnb7N/mHn1yIuwhBsirCJTfKH86gN81u8M3+SVHA2
VUHDllcNhpDWlmInXA+ItHdGZHCp95ohqpCPgQIDAQABAoIBABW8R4ewalo6dJlB
+n6O3jFt+PW3mtBRLqGqgm2cb0q0a1IMX+MPWLBFjmwEErl+AH0F4rcmBx2Ryr17
amEy1qcf0caXyHksNAApznqzWXag7iizxnxv4cZRnHBwphNqkNWM5p3oYd04j6w2
amDg1O9KZozaKo6QZclpiMiezwjKG+PVZLT8p7afswjv+yDWPDByhlcGiye9QD1T
VuZ0QCoXp6N/8JxW0gdkLp9NqFvGeGFzJ5h6L+d7A6BWw8akXrBRHHcKkyvVYBfd
myhSzSK4FPFMaxaEY/65FlVSyAO6ezGm3Umx4g7mkFjLdwKWaIOjkBkPeFgl3Pp4
7Lo5X3UCgYEA/FrrIwmEU5ayulBVScEMKeavu5eNY4r0Sqbpov2oyTdYe8G49Pzy
ryMXfunY43moLKpajGwgTKRGvdqFtK08AAkaCssiAPkP3rZuZvMTF4sLo/vlWrjP
3er+tUqj22BzXi5XV0BAvH8Y3TL8KQ3he/8JxDvkC811/DQ9Y/Da3U8CgYEA7Itw
UM37URma08Bj9VTMoL9ZCyURewX+ZLDb2+O8sXGXJs28i1RkE6PTBlnRmedn+Jjk
byzQ5Cs5wA5uMbhYTA7kgXOs1bvgQqmlLmyL6FfHkucoMhr2Di7VeGf4OxE26JZ8
JdY4+1MOyI3A2rR8WU+GmHxy0ay4K2xe6W0vsi8CgYBoGLEKIPDe8jkDtgOYivOT
jT9MaLXALB+dc8DIpU4swpHTaxP6qyUIrbcReTEolJSU6Ci16BxiwRkVU8D3yMYJ
VbfSX/zE3fh37FUaToa/nXHN0SjJBZdpeXhcHE//PIgaf48zxKNvnhYJmPB/luQ+
m/PRaMsnOzfCM2JniYEe7QKBgGwjnxhB4tgDtaWCue/pcZc3gzS2IJS2e8N6mzie
l6Ajhu+FdOHZldrotUuc+la61OxwsVYmDeWR4VftAPGYDj3PPSX1RRl9R5wSRGLB
2wBASQvew6CMdNqtDIh8N56BUzHnwh/mHKzBHuwO6hDSHFsUITtLAY7bwGKRq55Z
fUmfAoGBANOYFyoJoDLcl+Jd750lyqfCifcGtkRdmZMtrPXaYnD8ZGme9vz1vsK/
4iUkV3mi7Z9s1LXMa/tPPfKdVhCM1PXost3/si0+u1Bz5yKqEPXlyy2ltpIVyGu8
yiy7y75asp8Iii/1cgtwyp9+VeSif8wJ+MHQoGdGxvAQP80R3EjF
-----END RSA PRIVATE KEY-----

31
node_modules/node-gyp/test/fixtures/test-charmap.py generated vendored Normal file
View File

@@ -0,0 +1,31 @@
import sys
import locale
try:
reload(sys)
except NameError: # Python 3
pass
def main():
encoding = locale.getdefaultlocale()[1]
if not encoding:
return False
try:
sys.setdefaultencoding(encoding)
except AttributeError: # Python 3
pass
textmap = {
"cp936": "\u4e2d\u6587",
"cp1252": "Lat\u012Bna",
"cp932": "\u306b\u307b\u3093\u3054",
}
if encoding in textmap:
print(textmap[encoding])
return True
if __name__ == "__main__":
print(main())

140
node_modules/node-gyp/test/process-exec-sync.js generated vendored Normal file
View File

@@ -0,0 +1,140 @@
'use strict'
const fs = require('graceful-fs')
const childProcess = require('child_process')
function startsWith (str, search, pos) {
if (String.prototype.startsWith) {
return str.startsWith(search, pos)
}
return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search
}
function processExecSync (file, args, options) {
var child, error, timeout, tmpdir, command
command = makeCommand(file, args)
/*
this function emulates child_process.execSync for legacy node <= 0.10.x
derived from https://github.com/gvarsanyi/sync-exec/blob/master/js/sync-exec.js
*/
options = options || {}
// init timeout
timeout = Date.now() + options.timeout
// init tmpdir
var osTempBase = '/tmp'
var os = determineOS()
osTempBase = '/tmp'
if (process.env.TMP) {
osTempBase = process.env.TMP
}
if (osTempBase[osTempBase.length - 1] !== '/') {
osTempBase += '/'
}
tmpdir = osTempBase + 'processExecSync.' + Date.now() + Math.random()
fs.mkdirSync(tmpdir)
// init command
if (os === 'linux') {
command = '(' + command + ' > ' + tmpdir + '/stdout 2> ' + tmpdir +
'/stderr); echo $? > ' + tmpdir + '/status'
} else {
command = '(' + command + ' > ' + tmpdir + '/stdout 2> ' + tmpdir +
'/stderr) | echo %errorlevel% > ' + tmpdir + '/status | exit'
}
// init child
child = childProcess.exec(command, options)
var maxTry = 100000 // increases the test time by 6 seconds on win-2016-node-0.10
var tryCount = 0
while (tryCount < maxTry) {
try {
var x = fs.readFileSync(tmpdir + '/status')
if (x.toString() === '0') {
break
}
} catch (ignore) {}
tryCount++
if (Date.now() > timeout) {
error = child
break
}
}
['stdout', 'stderr', 'status'].forEach(function (file) {
child[file] = fs.readFileSync(tmpdir + '/' + file, options.encoding)
setTimeout(unlinkFile, 500, tmpdir + '/' + file)
})
child.status = Number(child.status)
if (child.status !== 0) {
error = child
}
try {
fs.rmdirSync(tmpdir)
} catch (ignore) {}
if (error) {
throw error
}
return child.stdout
}
function makeCommand (file, args) {
var command, quote
command = file
if (args.length > 0) {
for (var i in args) {
command = command + ' '
if (args[i][0] === '-') {
command = command + args[i]
} else {
if (!quote) {
command = command + '"'
quote = true
}
command = command + args[i]
if (quote) {
if (args.length === (parseInt(i) + 1)) {
command = command + '"'
}
}
}
}
}
return command
}
function determineOS () {
var os = ''
var tmpVar = ''
if (process.env.OSTYPE) {
tmpVar = process.env.OSTYPE
} else if (process.env.OS) {
tmpVar = process.env.OS
} else {
// default is linux
tmpVar = 'linux'
}
if (startsWith(tmpVar, 'linux')) {
os = 'linux'
}
if (startsWith(tmpVar, 'win')) {
os = 'win'
}
return os
}
function unlinkFile (file) {
fs.unlinkSync(file)
}
module.exports = processExecSync

27
node_modules/node-gyp/test/simple-proxy.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
'use strict'
const http = require('http')
const https = require('https')
const server = http.createServer(handler)
const port = +process.argv[2]
const prefix = process.argv[3]
const upstream = process.argv[4]
var calls = 0
server.listen(port)
function handler (req, res) {
if (req.url.indexOf(prefix) !== 0) {
throw new Error('request url [' + req.url + '] does not start with [' + prefix + ']')
}
var upstreamUrl = upstream + req.url.substring(prefix.length)
https.get(upstreamUrl, function (ures) {
ures.on('end', function () {
if (++calls === 2) {
server.close()
}
})
ures.pipe(res)
})
}

150
node_modules/node-gyp/test/test-addon.js generated vendored Normal file
View File

@@ -0,0 +1,150 @@
'use strict'
const test = require('tap').test
const path = require('path')
const fs = require('graceful-fs')
const childProcess = require('child_process')
const os = require('os')
const addonPath = path.resolve(__dirname, 'node_modules', 'hello_world')
const nodeGyp = path.resolve(__dirname, '..', 'bin', 'node-gyp.js')
const execFileSync = childProcess.execFileSync || require('./process-exec-sync')
const execFile = childProcess.execFile
function runHello (hostProcess) {
if (!hostProcess) {
hostProcess = process.execPath
}
var testCode = "console.log(require('hello_world').hello())"
return execFileSync(hostProcess, ['-e', testCode], { cwd: __dirname }).toString()
}
function getEncoding () {
var code = 'import locale;print(locale.getdefaultlocale()[1])'
return execFileSync('python', ['-c', code]).toString().trim()
}
function checkCharmapValid () {
var data
try {
data = execFileSync('python', ['fixtures/test-charmap.py'],
{ cwd: __dirname })
} catch (err) {
return false
}
var lines = data.toString().trim().split('\n')
return lines.pop() === 'True'
}
test('build simple addon', function (t) {
t.plan(3)
// 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')
})
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)
if (!checkCharmapValid()) {
return t.skip('python console app can\'t encode non-ascii character.')
}
var testDirNames = {
cp936: '文件夹',
cp1252: 'Latīna',
cp932: 'フォルダ'
}
// Select non-ascii characters by current encoding
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')
}
t.plan(3)
var data
var configPath = path.join(addonPath, 'build', 'config.gypi')
try {
data = fs.readFileSync(configPath, 'utf8')
} catch (err) {
t.error(err)
return
}
var config = JSON.parse(data.replace(/#.+\n/, ''))
var nodeDir = config.variables.nodedir
var testNodeDir = path.join(addonPath, testDirName)
// Create symbol link to path with non-ascii characters
try {
fs.symlinkSync(nodeDir, testNodeDir, 'dir')
} catch (err) {
switch (err.code) {
case 'EEXIST': break
case 'EPERM':
t.error(err, 'Please try to running console as an administrator')
return
default:
t.error(err)
return
}
}
var cmd = [
nodeGyp,
'rebuild',
'-C',
addonPath,
'--loglevel=verbose',
'-nodedir=' + testNodeDir
]
var proc = execFile(process.execPath, cmd, function (err, stdout, stderr) {
try {
fs.unlink(testNodeDir)
} catch (err) {
t.error(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')
})
proc.stdout.setEncoding('utf-8')
proc.stderr.setEncoding('utf-8')
})
test('addon works with renamed host executable', function (t) {
// No `fs.copyFileSync` before node8.
if (process.version.substr(1).split('.')[0] < 8) {
t.skip('skipping test for old node version')
t.end()
return
}
t.plan(3)
var notNodePath = path.join(os.tmpdir(), 'notnode' + path.extname(process.execPath))
fs.copyFileSync(process.execPath, notNodePath)
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(notNodePath).trim(), 'world')
fs.unlinkSync(notNodePath)
})
proc.stdout.setEncoding('utf-8')
proc.stderr.setEncoding('utf-8')
})

82
node_modules/node-gyp/test/test-configure-python.js generated vendored Normal file
View File

@@ -0,0 +1,82 @@
'use strict'
const test = require('tap').test
const path = require('path')
const devDir = require('./common').devDir()
const gyp = require('../lib/node-gyp')
const requireInject = require('require-inject')
const configure = requireInject('../lib/configure', {
'graceful-fs': {
openSync: function () { return 0 },
closeSync: function () { },
writeFile: function (file, data, cb) { cb() },
stat: function (file, cb) { cb(null, {}) },
mkdir: function (dir, options, cb) { cb() },
promises: {
writeFile: function (file, data) { return Promise.resolve(null) }
}
}
})
const EXPECTED_PYPATH = path.join(__dirname, '..', 'gyp', 'pylib')
const SEPARATOR = process.platform === 'win32' ? ';' : ':'
const SPAWN_RESULT = { on: function () { } }
require('npmlog').level = 'warn'
test('configure PYTHONPATH with no existing env', function (t) {
t.plan(1)
delete process.env.PYTHONPATH
var prog = gyp()
prog.parseArgv([])
prog.spawn = function () {
t.equal(process.env.PYTHONPATH, EXPECTED_PYPATH)
return SPAWN_RESULT
}
prog.devDir = devDir
configure(prog, [], t.fail)
})
test('configure PYTHONPATH with existing env of one dir', function (t) {
t.plan(2)
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))
var dirs = process.env.PYTHONPATH.split(SEPARATOR)
t.deepEqual(dirs, [EXPECTED_PYPATH, existingPath])
return SPAWN_RESULT
}
prog.devDir = devDir
configure(prog, [], t.fail)
})
test('configure PYTHONPATH with existing env of multiple dirs', function (t) {
t.plan(2)
var pythonDir1 = path.join('a', 'b')
var pythonDir2 = path.join('b', 'c')
var existingPath = [pythonDir1, pythonDir2].join(SEPARATOR)
process.env.PYTHONPATH = existingPath
var prog = gyp()
prog.parseArgv([])
prog.spawn = function () {
t.equal(process.env.PYTHONPATH, [EXPECTED_PYPATH, existingPath].join(SEPARATOR))
var dirs = process.env.PYTHONPATH.split(SEPARATOR)
t.deepEqual(dirs, [EXPECTED_PYPATH, pythonDir1, pythonDir2])
return SPAWN_RESULT
}
prog.devDir = devDir
configure(prog, [], t.fail)
})

70
node_modules/node-gyp/test/test-create-config-gypi.js generated vendored Normal file
View File

@@ -0,0 +1,70 @@
'use strict'
const path = require('path')
const { test } = require('tap')
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)
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)
})
test('config.gypi with --debug', async function (t) {
t.plan(1)
const prog = gyp()
prog.parseArgv(['_', '_', '--debug'])
const config = await getCurrentConfigGypi({ gyp: prog, vsInfo: {} })
t.equal(config.target_defaults.default_configuration, 'Debug')
})
test('config.gypi with custom options', async function (t) {
t.plan(1)
const prog = gyp()
prog.parseArgv(['_', '_', '--shared-libxml2'])
const config = await getCurrentConfigGypi({ gyp: prog, vsInfo: {} })
t.equal(config.variables.shared_libxml2, true)
})
test('config.gypi with nodedir', async function (t) {
t.plan(1)
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)
})
test('config.gypi with --force-process-config', async function (t) {
t.plan(1)
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)
})
test('config.gypi parsing', function (t) {
t.plan(1)
const str = "# Some comments\n{'variables': {'multiline': 'A'\n'B'}}"
const config = parseConfigGypi(str)
t.deepEqual(config, { variables: { multiline: 'AB' } })
})

207
node_modules/node-gyp/test/test-download.js generated vendored Normal file
View File

@@ -0,0 +1,207 @@
'use strict'
const { test } = require('tap')
const fs = require('fs')
const path = require('path')
const util = require('util')
const http = require('http')
const https = require('https')
const install = require('../lib/install')
const semver = require('semver')
const devDir = require('./common').devDir()
const rimraf = require('rimraf')
const gyp = require('../lib/node-gyp')
const log = require('npmlog')
log.level = 'warn'
test('download over http', async (t) => {
t.plan(2)
const server = http.createServer((req, res) => {
t.strictEqual(req.headers['user-agent'], `node-gyp v42 (node ${process.version})`)
res.end('ok')
})
t.tearDown(() => new Promise((resolve) => server.close(resolve)))
const host = 'localhost'
await new Promise((resolve) => server.listen(0, host, resolve))
const { port } = server.address()
const gyp = {
opts: {},
version: '42'
}
const url = `http://${host}:${port}`
const res = await install.test.download(gyp, url)
t.strictEqual(await res.text(), 'ok')
})
test('download over https with custom ca', async (t) => {
t.plan(3)
const cafile = path.join(__dirname, '/fixtures/ca.crt')
const [cert, key, ca] = await Promise.all([
fs.promises.readFile(path.join(__dirname, 'fixtures/server.crt'), 'utf8'),
fs.promises.readFile(path.join(__dirname, 'fixtures/server.key'), 'utf8'),
install.test.readCAFile(cafile)
])
t.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})`)
res.end('ok')
})
t.tearDown(() => new Promise((resolve) => server.close(resolve)))
server.on('clientError', (err) => { throw err })
const host = 'localhost'
await new Promise((resolve) => server.listen(0, host, resolve))
const { port } = server.address()
const gyp = {
opts: { cafile },
version: '42'
}
const url = `https://${host}:${port}`
const res = await install.test.download(gyp, url)
t.strictEqual(await res.text(), 'ok')
})
test('download over http with proxy', async (t) => {
t.plan(2)
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})`)
res.end('proxy ok')
})
t.tearDown(() => Promise.all([
new Promise((resolve) => server.close(resolve)),
new Promise((resolve) => pserver.close(resolve))
]))
const host = 'localhost'
await new Promise((resolve) => server.listen(0, host, resolve))
const { port } = server.address()
await new Promise((resolve) => pserver.listen(port + 1, host, resolve))
const gyp = {
opts: {
proxy: `http://${host}:${port + 1}`,
noproxy: 'bad'
},
version: '42'
}
const url = `http://${host}:${port}`
const res = await install.test.download(gyp, url)
t.strictEqual(await res.text(), 'proxy ok')
})
test('download over http with noproxy', async (t) => {
t.plan(2)
const server = http.createServer((req, res) => {
t.strictEqual(req.headers['user-agent'], `node-gyp v42 (node ${process.version})`)
res.end('ok')
})
const pserver = http.createServer((_, res) => {
res.end('proxy ok')
})
t.tearDown(() => Promise.all([
new Promise((resolve) => server.close(resolve)),
new Promise((resolve) => pserver.close(resolve))
]))
const host = 'localhost'
await new Promise((resolve) => server.listen(0, host, resolve))
const { port } = server.address()
await new Promise((resolve) => pserver.listen(port + 1, host, resolve))
const gyp = {
opts: {
proxy: `http://${host}:${port + 1}`,
noproxy: host
},
version: '42'
}
const url = `http://${host}:${port}`
const res = await install.test.download(gyp, url)
t.strictEqual(await res.text(), 'ok')
})
test('download with missing cafile', async (t) => {
t.plan(1)
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))
}
})
test('check certificate splitting', async (t) => {
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])
})
// only run this test if we are running a version of Node with predictable version path behavior
test('download headers (actual)', async (t) => {
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')
}
t.plan(12)
const expectedDir = path.join(devDir, process.version.replace(/^v/, ''))
await util.promisify(rimraf)(expectedDir)
const prog = gyp()
prog.parseArgv([])
prog.devDir = devDir
log.level = 'warn'
await util.promisify(install)(prog, [])
const data = await fs.promises.readFile(path.join(expectedDir, 'installVersion'), 'utf8')
t.strictEqual(data, '9\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'))
const lines = (await fs.promises.readFile(path.join(expectedDir, 'include/node/node_version.h'), 'utf8')).split('\n')
// extract the 3 version parts from the defines to build a valid version string and
// and check them against our current env version
const version = ['major', 'minor', 'patch'].reduce((version, type) => {
const re = new RegExp(`^#define\\sNODE_${type.toUpperCase()}_VERSION`)
const line = lines.find((l) => re.test(l))
const i = line ? parseInt(line.replace(/^[^0-9]+([0-9]+).*$/, '$1'), 10) : 'ERROR'
return `${version}${type !== 'major' ? '.' : 'v'}${i}`
}, '')
t.strictEqual(version, process.version)
})

View File

@@ -0,0 +1,84 @@
'use strict'
const test = require('tap').test
const path = require('path')
const requireInject = require('require-inject')
const configure = requireInject('../lib/configure', {
'graceful-fs': {
closeSync: function () { return undefined },
openSync: function (path) {
if (readableFiles.some(function (f) { return f === path })) {
return 0
} else {
var error = new Error('ENOENT - not found')
throw error
}
}
}
})
const dir = path.sep + 'testdir'
const readableFile = 'readable_file'
const anotherReadableFile = 'another_readable_file'
const readableFileInDir = 'somedir' + path.sep + readableFile
const readableFiles = [
path.resolve(dir, readableFile),
path.resolve(dir, anotherReadableFile),
path.resolve(dir, readableFileInDir)
]
test('find accessible - empty array', function (t) {
t.plan(1)
var candidates = []
var found = configure.test.findAccessibleSync('test', dir, candidates)
t.strictEqual(found, undefined)
})
test('find accessible - single item array, readable', function (t) {
t.plan(1)
var candidates = [readableFile]
var found = configure.test.findAccessibleSync('test', dir, candidates)
t.strictEqual(found, path.resolve(dir, readableFile))
})
test('find accessible - single item array, readable in subdir', function (t) {
t.plan(1)
var candidates = [readableFileInDir]
var found = configure.test.findAccessibleSync('test', dir, candidates)
t.strictEqual(found, path.resolve(dir, readableFileInDir))
})
test('find accessible - single item array, unreadable', function (t) {
t.plan(1)
var candidates = ['unreadable_file']
var found = configure.test.findAccessibleSync('test', dir, candidates)
t.strictEqual(found, undefined)
})
test('find accessible - multi item array, no matches', function (t) {
t.plan(1)
var candidates = ['non_existent_file', 'unreadable_file']
var found = configure.test.findAccessibleSync('test', dir, candidates)
t.strictEqual(found, undefined)
})
test('find accessible - multi item array, single match', function (t) {
t.plan(1)
var candidates = ['non_existent_file', readableFile]
var found = configure.test.findAccessibleSync('test', dir, candidates)
t.strictEqual(found, path.resolve(dir, readableFile))
})
test('find accessible - multi item array, return first match', function (t) {
t.plan(1)
var candidates = ['non_existent_file', anotherReadableFile, readableFile]
var found = configure.test.findAccessibleSync('test', dir, candidates)
t.strictEqual(found, path.resolve(dir, anotherReadableFile))
})

119
node_modules/node-gyp/test/test-find-node-directory.js generated vendored Normal file
View File

@@ -0,0 +1,119 @@
'use strict'
const test = require('tap').test
const path = require('path')
const findNodeDirectory = require('../lib/find-node-directory')
const platforms = ['darwin', 'freebsd', 'linux', 'sunos', 'win32', 'aix']
// 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)
for (var next = 0; next < platforms.length; next++) {
var processObj = { execPath: '/x/y/bin/node', platform: platforms[next] }
t.equal(
findNodeDirectory('/x/deps/npm/node_modules/node-gyp/lib', processObj),
path.join('/x'))
}
})
// we should find the directory based on the directory
// the script is running in and it should match the layout
// 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)
for (var next = 0; next < platforms.length; next++) {
var processObj = { execPath: '/x/y/bin/node', platform: platforms[next] }
if (platforms[next] === 'win32') {
t.equal(
findNodeDirectory('/y/node_modules/npm/node_modules/node-gyp/lib',
processObj), path.join('/y'))
} else {
t.equal(
findNodeDirectory('/y/lib/node_modules/npm/node_modules/node-gyp/lib',
processObj), path.join('/y'))
}
}
})
// 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)
for (var next = 0; next < platforms.length; next++) {
var processObj = { execPath: '/x/y/bin/node', platform: platforms[next] }
t.equal(
findNodeDirectory('/nothere/npm/node_modules/node-gyp/lib', processObj),
path.join('/x/y'))
}
})
// 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)
for (var next = 0; next < platforms.length; next++) {
var processObj
if (platforms[next] === 'win32') {
processObj = { execPath: '/x/y/Release/node', platform: platforms[next] }
} else {
processObj = {
execPath: '/x/y/out/Release/node',
platform: platforms[next]
}
}
t.equal(
findNodeDirectory('/nothere/npm/node_modules/node-gyp/lib', processObj),
path.join('/x/y'))
}
})
// 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)
for (var next = 0; next < platforms.length; next++) {
var processObj
if (platforms[next] === 'win32') {
processObj = { execPath: '/a/b/Debug/node', platform: platforms[next] }
} else {
processObj = { execPath: '/a/b/out/Debug/node', platform: platforms[next] }
}
t.equal(
findNodeDirectory('/nothere/npm/node_modules/node-gyp/lib', processObj),
path.join('/a/b'))
}
})
// 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)
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), '')
}
})
// 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
// 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)
for (var next = 0; next < platforms.length; next++) {
var processObj = { execPath: '/x/y/bin/node', platform: platforms[next] }
t.equal(
findNodeDirectory('/x/y/z/a/b/c/deps/npm/node_modules/node-gyp/lib',
processObj), path.join('/x/y/z/a/b/c'))
}
})

226
node_modules/node-gyp/test/test-find-python.js generated vendored Normal file
View File

@@ -0,0 +1,226 @@
'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
require('npmlog').level = 'warn'
test('find python', function (t) {
t.plan(4)
findPython.test.findPython(null, function (err, found) {
t.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, '')
})
proc.stdout.setEncoding('utf-8')
proc.stderr.setEncoding('utf-8')
})
})
function poison (object, property) {
function fail () {
console.error(Error(`Property ${property} should not have been accessed.`))
process.abort()
}
var descriptor = {
configurable: false,
enumerable: false,
get: fail,
set: fail
}
Object.defineProperty(object, property, descriptor)
}
function TestPythonFinder () {
PythonFinder.apply(this, arguments)
}
TestPythonFinder.prototype = Object.create(PythonFinder.prototype)
// Silence npmlog - remove for debugging
TestPythonFinder.prototype.log = {
silly: () => {},
verbose: () => {},
info: () => {},
warn: () => {},
error: () => {}
}
delete TestPythonFinder.prototype.env.NODE_GYP_FORCE_PYTHON
test('find python - python', function (t) {
t.plan(6)
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]))
cb(null, '3.9.1')
}
t.strictEqual(program,
process.platform === 'win32' ? '"python"' : 'python')
t.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')
}
})
test('find python - python too old', function (t) {
t.plan(2)
var f = new TestPythonFinder(null, done)
f.execFile = function (program, args, opts, cb) {
if (/sys\.executable/.test(args[args.length - 1])) {
cb(null, '/path/python')
} else if (/sys\.version_info/.test(args[args.length - 1])) {
cb(null, '2.3.4')
} else {
t.fail()
}
}
f.findPython()
function done (err) {
t.ok(/Could not find any Python/.test(err))
t.ok(/not supported/i.test(f.errorLog))
}
})
test('find python - no python', function (t) {
t.plan(2)
var f = new TestPythonFinder(null, done)
f.execFile = function (program, args, opts, cb) {
if (/sys\.executable/.test(args[args.length - 1])) {
cb(new Error('not found'))
} else if (/sys\.version_info/.test(args[args.length - 1])) {
cb(new Error('not a Python executable'))
} else {
t.fail()
}
}
f.findPython()
function done (err) {
t.ok(/Could not find any Python/.test(err))
t.ok(/not in PATH/.test(f.errorLog))
}
})
test('find python - no python2, no python, unix', function (t) {
t.plan(2)
var f = new TestPythonFinder(null, done)
f.checkPyLauncher = t.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()
}
}
f.findPython()
function done (err) {
t.ok(/Could not find any Python/.test(err))
t.ok(/not in PATH/.test(f.errorLog))
}
})
test('find python - no python, use python launcher', function (t) {
t.plan(4)
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)
return cb(null, 'Z:\\snake.exe')
}
if (/sys\.executable/.test(args[args.length - 1])) {
cb(new Error('not found'))
} else if (f.winDefaultLocations.includes(program)) {
cb(new Error('not found'))
} else if (/sys\.version_info/.test(args[args.length - 1])) {
if (program === 'Z:\\snake.exe') {
cb(null, '3.9.0')
} else {
t.fail()
}
} else {
t.fail()
}
}
f.findPython()
function done (err, python) {
t.strictEqual(err, null)
t.strictEqual(python, 'Z:\\snake.exe')
}
})
test('find python - no python, no python launcher, good guess', function (t) {
t.plan(2)
var f = new TestPythonFinder(null, done)
f.win = true
const expectedProgram = f.winDefaultLocations[0]
f.execFile = function (program, args, opts, cb) {
if (program === 'py.exe') {
return cb(new Error('not found'))
}
if (/sys\.executable/.test(args[args.length - 1])) {
cb(new Error('not found'))
} else if (program === expectedProgram &&
/sys\.version_info/.test(args[args.length - 1])) {
cb(null, '3.7.3')
} else {
t.fail()
}
}
f.findPython()
function done (err, python) {
t.strictEqual(err, null)
t.ok(python === expectedProgram)
}
})
test('find python - no python, no python launcher, bad guess', function (t) {
t.plan(2)
var f = new TestPythonFinder(null, done)
f.win = true
f.execFile = function (program, args, opts, cb) {
if (/sys\.executable/.test(args[args.length - 1])) {
cb(new Error('not found'))
} else if (/sys\.version_info/.test(args[args.length - 1])) {
cb(new Error('not a Python executable'))
} else {
t.fail()
}
}
f.findPython()
function done (err) {
t.ok(/Could not find any Python/.test(err))
t.ok(/not in PATH/.test(f.errorLog))
}
})

676
node_modules/node-gyp/test/test-find-visualstudio.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

46
node_modules/node-gyp/test/test-install.js generated vendored Normal file
View File

@@ -0,0 +1,46 @@
'use strict'
const { test } = require('tap')
const { test: { install } } = require('../lib/install')
const log = require('npmlog')
log.level = 'error' // we expect a warning
test('EACCES retry once', async (t) => {
t.plan(3)
const fs = {
promises: {
stat (_) {
const err = new Error()
err.code = 'EACCES'
t.ok(true)
throw err
}
}
}
const Gyp = {
devDir: __dirname,
opts: {
ensure: true
},
commands: {
install (argv, cb) {
install(fs, Gyp, argv).then(cb, cb)
},
remove (_, cb) {
cb()
}
}
}
try {
await install(fs, Gyp, [])
} catch (err) {
t.ok(true)
if (/"pre" versions of node cannot be installed/.test(err.message)) {
t.ok(true)
}
}
})

31
node_modules/node-gyp/test/test-options.js generated vendored Normal file
View File

@@ -0,0 +1,31 @@
'use strict'
const test = require('tap').test
const gyp = require('../lib/node-gyp')
test('options in environment', (t) => {
t.plan(1)
// `npm test` dumps a ton of npm_config_* variables in the environment.
Object.keys(process.env)
.filter((key) => /^npm_config_/.test(key))
.forEach((key) => { delete process.env[key] })
// in some platforms, certain keys are stubborn and cannot be removed
const keys = Object.keys(process.env)
.filter((key) => /^npm_config_/.test(key))
.map((key) => key.substring('npm_config_'.length))
.concat('argv', 'x')
// Zero-length keys should get filtered out.
process.env.npm_config_ = '42'
// Other keys should get added.
process.env.npm_config_x = '42'
// Except loglevel.
process.env.npm_config_loglevel = 'debug'
const g = gyp()
g.parseArgv(['rebuild']) // Also sets opts.argv.
t.deepEqual(Object.keys(g.opts).sort(), keys.sort())
})

434
node_modules/node-gyp/test/test-process-release.js generated vendored Normal file
View File

@@ -0,0 +1,434 @@
'use strict'
const test = require('tap').test
const processRelease = require('../lib/process-release')
test('test process release - process.version = 0.8.20', function (t) {
t.plan(2)
var release = processRelease([], { opts: {} }, 'v0.8.20', null)
t.equal(release.semver.version, '0.8.20')
delete release.semver
t.deepEqual(release, {
version: '0.8.20',
name: 'node',
baseUrl: 'https://nodejs.org/dist/v0.8.20/',
tarballUrl: 'https://nodejs.org/dist/v0.8.20/node-v0.8.20.tar.gz',
shasumsUrl: 'https://nodejs.org/dist/v0.8.20/SHASUMS256.txt',
versionDir: '0.8.20',
ia32: { libUrl: 'https://nodejs.org/dist/v0.8.20/node.lib', libPath: 'node.lib' },
x64: { libUrl: 'https://nodejs.org/dist/v0.8.20/x64/node.lib', libPath: 'x64/node.lib' },
arm64: { libUrl: 'https://nodejs.org/dist/v0.8.20/arm64/node.lib', libPath: 'arm64/node.lib' }
})
})
test('test process release - process.version = 0.10.21', function (t) {
t.plan(2)
var release = processRelease([], { opts: {} }, 'v0.10.21', null)
t.equal(release.semver.version, '0.10.21')
delete release.semver
t.deepEqual(release, {
version: '0.10.21',
name: 'node',
baseUrl: 'https://nodejs.org/dist/v0.10.21/',
tarballUrl: 'https://nodejs.org/dist/v0.10.21/node-v0.10.21.tar.gz',
shasumsUrl: 'https://nodejs.org/dist/v0.10.21/SHASUMS256.txt',
versionDir: '0.10.21',
ia32: { libUrl: 'https://nodejs.org/dist/v0.10.21/node.lib', libPath: 'node.lib' },
x64: { libUrl: 'https://nodejs.org/dist/v0.10.21/x64/node.lib', libPath: 'x64/node.lib' },
arm64: { libUrl: 'https://nodejs.org/dist/v0.10.21/arm64/node.lib', libPath: 'arm64/node.lib' }
})
})
// prior to -headers.tar.gz
test('test process release - process.version = 0.12.9', function (t) {
t.plan(2)
var release = processRelease([], { opts: {} }, 'v0.12.9', null)
t.equal(release.semver.version, '0.12.9')
delete release.semver
t.deepEqual(release, {
version: '0.12.9',
name: 'node',
baseUrl: 'https://nodejs.org/dist/v0.12.9/',
tarballUrl: 'https://nodejs.org/dist/v0.12.9/node-v0.12.9.tar.gz',
shasumsUrl: 'https://nodejs.org/dist/v0.12.9/SHASUMS256.txt',
versionDir: '0.12.9',
ia32: { libUrl: 'https://nodejs.org/dist/v0.12.9/node.lib', libPath: 'node.lib' },
x64: { libUrl: 'https://nodejs.org/dist/v0.12.9/x64/node.lib', libPath: 'x64/node.lib' },
arm64: { libUrl: 'https://nodejs.org/dist/v0.12.9/arm64/node.lib', libPath: 'arm64/node.lib' }
})
})
// prior to -headers.tar.gz
test('test process release - process.version = 0.10.41', function (t) {
t.plan(2)
var release = processRelease([], { opts: {} }, 'v0.10.41', null)
t.equal(release.semver.version, '0.10.41')
delete release.semver
t.deepEqual(release, {
version: '0.10.41',
name: 'node',
baseUrl: 'https://nodejs.org/dist/v0.10.41/',
tarballUrl: 'https://nodejs.org/dist/v0.10.41/node-v0.10.41.tar.gz',
shasumsUrl: 'https://nodejs.org/dist/v0.10.41/SHASUMS256.txt',
versionDir: '0.10.41',
ia32: { libUrl: 'https://nodejs.org/dist/v0.10.41/node.lib', libPath: 'node.lib' },
x64: { libUrl: 'https://nodejs.org/dist/v0.10.41/x64/node.lib', libPath: 'x64/node.lib' },
arm64: { libUrl: 'https://nodejs.org/dist/v0.10.41/arm64/node.lib', libPath: 'arm64/node.lib' }
})
})
// has -headers.tar.gz
test('test process release - process.release ~ node@0.10.42', function (t) {
t.plan(2)
var release = processRelease([], { opts: {} }, 'v0.10.42', null)
t.equal(release.semver.version, '0.10.42')
delete release.semver
t.deepEqual(release, {
version: '0.10.42',
name: 'node',
baseUrl: 'https://nodejs.org/dist/v0.10.42/',
tarballUrl: 'https://nodejs.org/dist/v0.10.42/node-v0.10.42-headers.tar.gz',
shasumsUrl: 'https://nodejs.org/dist/v0.10.42/SHASUMS256.txt',
versionDir: '0.10.42',
ia32: { libUrl: 'https://nodejs.org/dist/v0.10.42/node.lib', libPath: 'node.lib' },
x64: { libUrl: 'https://nodejs.org/dist/v0.10.42/x64/node.lib', libPath: 'x64/node.lib' },
arm64: { libUrl: 'https://nodejs.org/dist/v0.10.42/arm64/node.lib', libPath: 'arm64/node.lib' }
})
})
// has -headers.tar.gz
test('test process release - process.release ~ node@0.12.10', function (t) {
t.plan(2)
var release = processRelease([], { opts: {} }, 'v0.12.10', null)
t.equal(release.semver.version, '0.12.10')
delete release.semver
t.deepEqual(release, {
version: '0.12.10',
name: 'node',
baseUrl: 'https://nodejs.org/dist/v0.12.10/',
tarballUrl: 'https://nodejs.org/dist/v0.12.10/node-v0.12.10-headers.tar.gz',
shasumsUrl: 'https://nodejs.org/dist/v0.12.10/SHASUMS256.txt',
versionDir: '0.12.10',
ia32: { libUrl: 'https://nodejs.org/dist/v0.12.10/node.lib', libPath: 'node.lib' },
x64: { libUrl: 'https://nodejs.org/dist/v0.12.10/x64/node.lib', libPath: 'x64/node.lib' },
arm64: { libUrl: 'https://nodejs.org/dist/v0.12.10/arm64/node.lib', libPath: 'arm64/node.lib' }
})
})
test('test process release - process.release ~ node@4.1.23', function (t) {
t.plan(2)
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')
delete release.semver
t.deepEqual(release, {
version: '4.1.23',
name: 'node',
baseUrl: 'https://nodejs.org/dist/v4.1.23/',
tarballUrl: 'https://nodejs.org/dist/v4.1.23/node-v4.1.23-headers.tar.gz',
shasumsUrl: 'https://nodejs.org/dist/v4.1.23/SHASUMS256.txt',
versionDir: '4.1.23',
ia32: { libUrl: 'https://nodejs.org/dist/v4.1.23/win-x86/node.lib', libPath: 'win-x86/node.lib' },
x64: { libUrl: 'https://nodejs.org/dist/v4.1.23/win-x64/node.lib', libPath: 'win-x64/node.lib' },
arm64: { libUrl: 'https://nodejs.org/dist/v4.1.23/win-arm64/node.lib', libPath: 'win-arm64/node.lib' }
})
})
test('test process release - process.release ~ node@4.1.23 / corp build', function (t) {
t.plan(2)
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')
delete release.semver
t.deepEqual(release, {
version: '4.1.23',
name: 'node',
baseUrl: 'https://some.custom.location/',
tarballUrl: 'https://some.custom.location/node-v4.1.23-headers.tar.gz',
shasumsUrl: 'https://some.custom.location/SHASUMS256.txt',
versionDir: '4.1.23',
ia32: { libUrl: 'https://some.custom.location/win-x86/node.lib', libPath: 'win-x86/node.lib' },
x64: { libUrl: 'https://some.custom.location/win-x64/node.lib', libPath: 'win-x64/node.lib' },
arm64: { libUrl: 'https://some.custom.location/win-arm64/node.lib', libPath: 'win-arm64/node.lib' }
})
})
test('test process release - process.release ~ node@12.8.0 Windows', function (t) {
t.plan(2)
var release = processRelease([], { opts: {} }, 'v12.8.0', {
name: 'node',
sourceUrl: 'https://nodejs.org/download/release/v12.8.0/node-v12.8.0.tar.gz',
headersUrl: 'https://nodejs.org/download/release/v12.8.0/node-v12.8.0-headers.tar.gz',
libUrl: 'https://nodejs.org/download/release/v12.8.0/win-x64/node.lib'
})
t.equal(release.semver.version, '12.8.0')
delete release.semver
t.deepEqual(release, {
version: '12.8.0',
name: 'node',
baseUrl: 'https://nodejs.org/download/release/v12.8.0/',
tarballUrl: 'https://nodejs.org/download/release/v12.8.0/node-v12.8.0-headers.tar.gz',
shasumsUrl: 'https://nodejs.org/download/release/v12.8.0/SHASUMS256.txt',
versionDir: '12.8.0',
ia32: { libUrl: 'https://nodejs.org/download/release/v12.8.0/win-x86/node.lib', libPath: 'win-x86/node.lib' },
x64: { libUrl: 'https://nodejs.org/download/release/v12.8.0/win-x64/node.lib', libPath: 'win-x64/node.lib' },
arm64: { libUrl: 'https://nodejs.org/download/release/v12.8.0/win-arm64/node.lib', libPath: 'win-arm64/node.lib' }
})
})
test('test process release - process.release ~ node@12.8.0 Windows ARM64', function (t) {
t.plan(2)
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',
headersUrl: 'https://unofficial-builds.nodejs.org/download/release/v12.8.0/node-v12.8.0-headers.tar.gz',
libUrl: 'https://unofficial-builds.nodejs.org/download/release/v12.8.0/win-arm64/node.lib'
})
t.equal(release.semver.version, '12.8.0')
delete release.semver
t.deepEqual(release, {
version: '12.8.0',
name: 'node',
baseUrl: 'https://unofficial-builds.nodejs.org/download/release/v12.8.0/',
tarballUrl: 'https://unofficial-builds.nodejs.org/download/release/v12.8.0/node-v12.8.0-headers.tar.gz',
shasumsUrl: 'https://unofficial-builds.nodejs.org/download/release/v12.8.0/SHASUMS256.txt',
versionDir: '12.8.0',
ia32: { libUrl: 'https://unofficial-builds.nodejs.org/download/release/v12.8.0/win-x86/node.lib', libPath: 'win-x86/node.lib' },
x64: { libUrl: 'https://unofficial-builds.nodejs.org/download/release/v12.8.0/win-x64/node.lib', libPath: 'win-x64/node.lib' },
arm64: { libUrl: 'https://unofficial-builds.nodejs.org/download/release/v12.8.0/win-arm64/node.lib', libPath: 'win-arm64/node.lib' }
})
})
test('test process release - process.release ~ node@4.1.23 --target=0.10.40', function (t) {
t.plan(2)
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')
delete release.semver
t.deepEqual(release, {
version: '0.10.40',
name: 'node',
baseUrl: 'https://nodejs.org/dist/v0.10.40/',
tarballUrl: 'https://nodejs.org/dist/v0.10.40/node-v0.10.40.tar.gz',
shasumsUrl: 'https://nodejs.org/dist/v0.10.40/SHASUMS256.txt',
versionDir: '0.10.40',
ia32: { libUrl: 'https://nodejs.org/dist/v0.10.40/node.lib', libPath: 'node.lib' },
x64: { libUrl: 'https://nodejs.org/dist/v0.10.40/x64/node.lib', libPath: 'x64/node.lib' },
arm64: { libUrl: 'https://nodejs.org/dist/v0.10.40/arm64/node.lib', libPath: 'arm64/node.lib' }
})
})
test('test process release - process.release ~ node@4.1.23 --dist-url=https://foo.bar/baz', function (t) {
t.plan(2)
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')
delete release.semver
t.deepEqual(release, {
version: '4.1.23',
name: 'node',
baseUrl: 'https://foo.bar/baz/v4.1.23/',
tarballUrl: 'https://foo.bar/baz/v4.1.23/node-v4.1.23-headers.tar.gz',
shasumsUrl: 'https://foo.bar/baz/v4.1.23/SHASUMS256.txt',
versionDir: '4.1.23',
ia32: { libUrl: 'https://foo.bar/baz/v4.1.23/win-x86/node.lib', libPath: 'win-x86/node.lib' },
x64: { libUrl: 'https://foo.bar/baz/v4.1.23/win-x64/node.lib', libPath: 'win-x64/node.lib' },
arm64: { libUrl: 'https://foo.bar/baz/v4.1.23/win-arm64/node.lib', libPath: 'win-arm64/node.lib' }
})
})
test('test process release - process.release ~ frankenstein@4.1.23', function (t) {
t.plan(2)
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')
delete release.semver
t.deepEqual(release, {
version: '4.1.23',
name: 'frankenstein',
baseUrl: 'https://frankensteinjs.org/dist/v4.1.23/',
tarballUrl: 'https://frankensteinjs.org/dist/v4.1.23/frankenstein-v4.1.23-headers.tar.gz',
shasumsUrl: 'https://frankensteinjs.org/dist/v4.1.23/SHASUMS256.txt',
versionDir: 'frankenstein-4.1.23',
ia32: { libUrl: 'https://frankensteinjs.org/dist/v4.1.23/win-x86/frankenstein.lib', libPath: 'win-x86/frankenstein.lib' },
x64: { libUrl: 'https://frankensteinjs.org/dist/v4.1.23/win-x64/frankenstein.lib', libPath: 'win-x64/frankenstein.lib' },
arm64: { libUrl: 'https://frankensteinjs.org/dist/v4.1.23/win-arm64/frankenstein.lib', libPath: 'win-arm64/frankenstein.lib' }
})
})
test('test process release - process.release ~ frankenstein@4.1.23 --dist-url=http://foo.bar/baz/', function (t) {
t.plan(2)
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')
delete release.semver
t.deepEqual(release, {
version: '4.1.23',
name: 'frankenstein',
baseUrl: 'http://foo.bar/baz/v4.1.23/',
tarballUrl: 'http://foo.bar/baz/v4.1.23/frankenstein-v4.1.23-headers.tar.gz',
shasumsUrl: 'http://foo.bar/baz/v4.1.23/SHASUMS256.txt',
versionDir: 'frankenstein-4.1.23',
ia32: { libUrl: 'http://foo.bar/baz/v4.1.23/win-x86/frankenstein.lib', libPath: 'win-x86/frankenstein.lib' },
x64: { libUrl: 'http://foo.bar/baz/v4.1.23/win-x64/frankenstein.lib', libPath: 'win-x64/frankenstein.lib' },
arm64: { libUrl: 'http://foo.bar/baz/v4.1.23/win-arm64/frankenstein.lib', libPath: 'win-arm64/frankenstein.lib' }
})
})
test('test process release - process.release ~ node@4.0.0-rc.4', function (t) {
t.plan(2)
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')
delete release.semver
t.deepEqual(release, {
version: '4.0.0-rc.4',
name: 'node',
baseUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/',
tarballUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/node-v4.0.0-rc.4-headers.tar.gz',
shasumsUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/SHASUMS256.txt',
versionDir: '4.0.0-rc.4',
ia32: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x86/node.lib', libPath: 'win-x86/node.lib' },
x64: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x64/node.lib', libPath: 'win-x64/node.lib' },
arm64: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-arm64/node.lib', libPath: 'win-arm64/node.lib' }
})
})
test('test process release - process.release ~ node@4.0.0-rc.4 passed as argv[0]', function (t) {
t.plan(2)
// 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', {
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')
delete release.semver
t.deepEqual(release, {
version: '4.0.0-rc.4',
name: 'node',
baseUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/',
tarballUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/node-v4.0.0-rc.4-headers.tar.gz',
shasumsUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/SHASUMS256.txt',
versionDir: '4.0.0-rc.4',
ia32: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x86/node.lib', libPath: 'win-x86/node.lib' },
x64: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x64/node.lib', libPath: 'win-x64/node.lib' },
arm64: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-arm64/node.lib', libPath: 'win-arm64/node.lib' }
})
})
test('test process release - process.release ~ node@4.0.0-rc.4 - bogus string passed as argv[0]', function (t) {
t.plan(2)
// 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', {
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')
delete release.semver
t.deepEqual(release, {
version: '4.0.0-rc.4',
name: 'node',
baseUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/',
tarballUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/node-v4.0.0-rc.4-headers.tar.gz',
shasumsUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/SHASUMS256.txt',
versionDir: '4.0.0-rc.4',
ia32: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x86/node.lib', libPath: 'win-x86/node.lib' },
x64: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x64/node.lib', libPath: 'win-x64/node.lib' },
arm64: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-arm64/node.lib', libPath: 'win-arm64/node.lib' }
})
})
test('test process release - NODEJS_ORG_MIRROR', function (t) {
t.plan(2)
process.env.NODEJS_ORG_MIRROR = 'http://foo.bar'
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')
delete release.semver
t.deepEqual(release, {
version: '4.1.23',
name: 'node',
baseUrl: 'http://foo.bar/v4.1.23/',
tarballUrl: 'http://foo.bar/v4.1.23/node-v4.1.23-headers.tar.gz',
shasumsUrl: 'http://foo.bar/v4.1.23/SHASUMS256.txt',
versionDir: '4.1.23',
ia32: { libUrl: 'http://foo.bar/v4.1.23/win-x86/node.lib', libPath: 'win-x86/node.lib' },
x64: { libUrl: 'http://foo.bar/v4.1.23/win-x64/node.lib', libPath: 'win-x64/node.lib' },
arm64: { libUrl: 'http://foo.bar/v4.1.23/win-arm64/node.lib', libPath: 'win-arm64/node.lib' }
})
delete process.env.NODEJS_ORG_MIRROR
})