mirror of
https://github.com/electron/node-gyp.git
synced 2025-08-15 04:48:20 +02:00
chore: use platform specific timeouts in tests
This commit is contained in:
parent
4e0ed99256
commit
a68586a67d
4 changed files with 21 additions and 14 deletions
|
@ -22,3 +22,12 @@ module.exports.FULL_TEST =
|
|||
process.env.FULL_TEST === '1' &&
|
||||
process.release.name === 'node' &&
|
||||
semver.prerelease(process.version) === null
|
||||
|
||||
module.exports.platformTimeout = (def, obj) => {
|
||||
for (const [key, value] of Object.entries(obj)) {
|
||||
if (process.platform === key) {
|
||||
return value * 60 * 1000
|
||||
}
|
||||
}
|
||||
return def * 60 * 1000
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ const fs = require('graceful-fs')
|
|||
const os = require('os')
|
||||
const cp = require('child_process')
|
||||
const util = require('../lib/util')
|
||||
const { platformTimeout } = require('./common')
|
||||
|
||||
const addonPath = path.resolve(__dirname, 'node_modules', 'hello_world')
|
||||
const nodeGyp = path.resolve(__dirname, '..', 'bin', 'node-gyp.js')
|
||||
|
@ -41,9 +42,9 @@ function checkCharmapValid () {
|
|||
}
|
||||
|
||||
describe('addon', function () {
|
||||
this.timeout(300000)
|
||||
|
||||
it('build simple addon', async function () {
|
||||
this.timeout(platformTimeout(1, { win32: 5 }))
|
||||
|
||||
// Set the loglevel otherwise the output disappears when run via 'npm test'
|
||||
const cmd = [nodeGyp, 'rebuild', '-C', addonPath, '--loglevel=verbose']
|
||||
const [err, logLines] = await execFile(cmd)
|
||||
|
@ -69,15 +70,14 @@ describe('addon', function () {
|
|||
return this.skip('no need to test')
|
||||
}
|
||||
|
||||
this.timeout(300000)
|
||||
this.timeout(platformTimeout(1, { win32: 5 }))
|
||||
|
||||
let data
|
||||
const configPath = path.join(addonPath, 'build', 'config.gypi')
|
||||
try {
|
||||
data = fs.readFileSync(configPath, 'utf8')
|
||||
} catch (err) {
|
||||
assert.fail(err)
|
||||
return
|
||||
return assert.fail(err)
|
||||
}
|
||||
const config = JSON.parse(data.replace(/#.+\n/, ''))
|
||||
const nodeDir = config.variables.nodedir
|
||||
|
@ -89,11 +89,9 @@ describe('addon', function () {
|
|||
switch (err.code) {
|
||||
case 'EEXIST': break
|
||||
case 'EPERM':
|
||||
assert.fail(err, null, 'Please try to running console as an administrator')
|
||||
return
|
||||
return assert.fail(err, null, 'Please try to running console as an administrator')
|
||||
default:
|
||||
assert.fail(err)
|
||||
return
|
||||
return assert.fail(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,7 +116,7 @@ describe('addon', function () {
|
|||
})
|
||||
|
||||
it('addon works with renamed host executable', async function () {
|
||||
this.timeout(300000)
|
||||
this.timeout(platformTimeout(1, { win32: 5 }))
|
||||
|
||||
const notNodePath = path.join(os.tmpdir(), 'notnode' + path.extname(process.execPath))
|
||||
fs.copyFileSync(process.execPath, notNodePath)
|
||||
|
|
|
@ -8,7 +8,7 @@ const http = require('http')
|
|||
const https = require('https')
|
||||
const install = require('../lib/install')
|
||||
const { download, readCAFile } = require('../lib/download')
|
||||
const { FULL_TEST, devDir } = require('./common')
|
||||
const { FULL_TEST, devDir, platformTimeout } = require('./common')
|
||||
const gyp = require('../lib/node-gyp')
|
||||
const certs = require('./fixtures/certs')
|
||||
|
||||
|
@ -160,7 +160,7 @@ describe('download', function () {
|
|||
return this.skip('Skipping actual download of headers due to test environment configuration')
|
||||
}
|
||||
|
||||
this.timeout(300000)
|
||||
this.timeout(platformTimeout(1, { win32: 5 }))
|
||||
|
||||
const expectedDir = path.join(devDir, process.version.replace(/^v/, ''))
|
||||
await fs.rm(expectedDir, { recursive: true, force: true })
|
||||
|
|
|
@ -8,7 +8,7 @@ const path = require('path')
|
|||
const os = require('os')
|
||||
const { pipeline: streamPipeline } = require('stream/promises')
|
||||
const requireInject = require('require-inject')
|
||||
const { FULL_TEST } = require('./common')
|
||||
const { FULL_TEST, platformTimeout } = require('./common')
|
||||
const gyp = require('../lib/node-gyp')
|
||||
const install = require('../lib/install')
|
||||
const { download } = require('../lib/download')
|
||||
|
@ -74,7 +74,7 @@ describe('install', function () {
|
|||
}
|
||||
|
||||
return it(name, async function () {
|
||||
this.timeout(600000)
|
||||
this.timeout(platformTimeout(1, { win32: 20 }))
|
||||
const start = Date.now()
|
||||
await fn.call(this)
|
||||
const expectedDir = path.join(prog.devDir, process.version.replace(/^v/, ''))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue