diff --git a/README.md b/README.md index 6b12faad7..aa874d41e 100644 --- a/README.md +++ b/README.md @@ -143,6 +143,7 @@ For syntax, see [lookup.json](./lib/lookup.json), the available attributes are: "useGitClone": true Use a shallow git clone instead of downloading the module "ignoreGitHead": Ignore the gitHead field if it exists and fallback to using github tags "yarn": Install and test the project using yarn instead of npm +"timeout": Number of milliseconds before timeout. Applies separately to `install` and `test` ``` If you want to pass options to npm, eg `--registry`, you can usually define an diff --git a/bin/citgm-all.js b/bin/citgm-all.js index 6f5d41981..9f8362df7 100755 --- a/bin/citgm-all.js +++ b/bin/citgm-all.js @@ -68,7 +68,7 @@ const options = { failFlaky: app.failFlaky, level: app.verbose, npmLevel: app.npmLoglevel, - timeoutLength: app.timeout, + timeout: app.timeout, tmpDir: app.tmpDir, customTest: app.customTest, yarn: app.yarn, diff --git a/bin/citgm.js b/bin/citgm.js index 5ec6a181b..199093f5b 100755 --- a/bin/citgm.js +++ b/bin/citgm.js @@ -45,7 +45,7 @@ const options = { testPath: app.testPath, level: app.verbose, npmLevel: app.npmLoglevel, - timeoutLength: app.timeout, + timeout: app.timeout, sha: app.sha, tmpDir: app.tmpDir, customTest: app.customTest, diff --git a/lib/common-args.js b/lib/common-args.js index 6df75001b..c6979607f 100644 --- a/lib/common-args.js +++ b/lib/common-args.js @@ -73,8 +73,7 @@ module.exports = function commonArgs(app) { .option('timeout', { alias: 'o', type: 'number', - description: 'Set timeout for npm install', - default: 1000 * 60 * 10 + description: 'Set timeout for `install` and `test` phases' }) .option('yarn', { alias: 'y', diff --git a/lib/grab-project.js b/lib/grab-project.js index 25f46451c..4dadbf597 100644 --- a/lib/grab-project.js +++ b/lib/grab-project.js @@ -38,7 +38,7 @@ async function grabProject(context) { // Default timeout to 10 minutes if not provided const timeout = setTimeout( cleanup, - context.options.timeoutLength || 1000 * 60 * 10 + context.options.timeout || 1000 * 60 * 10 ); function cleanup() { diff --git a/lib/lookup.js b/lib/lookup.js index e98aa02d3..c4543e0ec 100644 --- a/lib/lookup.js +++ b/lib/lookup.js @@ -162,6 +162,9 @@ function resolve(context) { if (rep.yarn) { context.module.useYarn = true; } + if (rep.timeout) { + context.module.timeout = rep.timeout; + } context.module.flaky = context.options.failFlaky ? false : isMatch(rep.flaky); diff --git a/lib/package-manager/install.js b/lib/package-manager/install.js index 0fd994ad6..fe89e6b8b 100644 --- a/lib/package-manager/install.js +++ b/lib/package-manager/install.js @@ -43,6 +43,7 @@ function install(packageManager, context) { const proc = spawn(packageManagerBin, args, options); const finish = timeout( + packageManager, context, proc, (err) => { diff --git a/lib/package-manager/test.js b/lib/package-manager/test.js index 2e923ee30..c88e0a381 100644 --- a/lib/package-manager/test.js +++ b/lib/package-manager/test.js @@ -105,7 +105,14 @@ async function test(packageManager, context) { ); const proc = spawn(bin, args, options); - const finish = timeout(context, proc, runScript, 'Test'); + const finish = timeout( + packageManager, + context, + proc, + runScript, + 'Test', + context.module.timeout + ); proc.stdout.on('data', (data) => { context.testOutput.append(data); diff --git a/lib/timeout.js b/lib/timeout.js index 7b4a0f2cf..c595a8de0 100644 --- a/lib/timeout.js +++ b/lib/timeout.js @@ -3,9 +3,17 @@ // Default timeout to 10 minutes if not provided const kDefaultTimeout = 1000 * 60 * 10; -function timeout(context, proc, next, step) { +function timeout( + packageManager, + context, + proc, + next, + step, + moduleConfigTimeout +) { let hasRun = false; - const delay = context.options.timeoutLength || kDefaultTimeout; + const delay = + context.options.timeout || moduleConfigTimeout || kDefaultTimeout; // Third arg === `true` is the way to signal `finish` that this is a timeout. // Otherwise it acts like a "regular" callback, i.e. `(err, ret) => {}`. // `if (timedOut)` will overwrite `err` & `ret`, so first 2 args are ignored. @@ -28,8 +36,8 @@ function timeout(context, proc, next, step) { context.emit( 'data', 'error', - `${context.module.name} npm:`, - `npm-${step.toLowerCase()} Timed Out` + `${context.module.name} ${packageManager}:`, + `${packageManager}-${step.toLowerCase()} Timed Out` ); proc.kill(); err = new Error(`${step} Timed Out`); diff --git a/test/npm/test-npm-install.js b/test/npm/test-npm-install.js index b6ef23513..9a743969c 100644 --- a/test/npm/test-npm-install.js +++ b/test/npm/test-npm-install.js @@ -89,7 +89,7 @@ test('npm-install: timeout', async (t) => { sandbox, { npmLevel: 'silly', - timeoutLength: 100 + timeout: 100 } ); try { diff --git a/test/npm/test-npm-test.js b/test/npm/test-npm-test.js index 164cb0f67..b6ac92ce8 100644 --- a/test/npm/test-npm-test.js +++ b/test/npm/test-npm-test.js @@ -126,7 +126,7 @@ test('npm-test: timeout', async (t) => { sandbox, { npmLevel: 'silly', - timeoutLength: 100 + timeout: 100 } ); try { diff --git a/test/test-grab-project.js b/test/test-grab-project.js index 2692adcbd..b55f4129c 100644 --- a/test/test-grab-project.js +++ b/test/test-grab-project.js @@ -159,7 +159,7 @@ test('grab-project: timeout', async (t) => { meta: {}, options: { npmLevel: 'silly', - timeoutLength: 10 + timeout: 10 } }; try { diff --git a/test/test-timeout.js b/test/test-timeout.js index e04be6a6b..5b1e4736c 100644 --- a/test/test-timeout.js +++ b/test/test-timeout.js @@ -24,7 +24,7 @@ test('timeout:', (t) => { sandbox, { npmLevel: 'silly', - timeoutLength: 100 + timeout: 100 } ); const proc = { @@ -39,7 +39,7 @@ test('timeout:', (t) => { err = e; ret = r; }; - const finish = timeout(context, proc, next, 'Tap'); + const finish = timeout('npm', context, proc, next, 'Tap'); setTimeout(() => { t.notOk(context.module.flaky, 'Time out should not mark module flaky'); t.equals(proc.killed, 1); @@ -61,7 +61,7 @@ test('timeout:', (t) => { sandbox, { npmLevel: 'silly', - timeoutLength: 100 + timeout: 100 } ); const proc = { @@ -80,7 +80,7 @@ test('timeout:', (t) => { ret = r; return sentinel1; }; - const finish = timeout(context, proc, next, 'Tap'); + const finish = timeout('npm', context, proc, next, 'Tap'); const r = finish(sentinel2, sentinel3); t.equals(r, sentinel1); t.equals(proc.killed, 0); diff --git a/test/yarn/test-yarn-install.js b/test/yarn/test-yarn-install.js index 244025d4c..23f48ccfb 100644 --- a/test/yarn/test-yarn-install.js +++ b/test/yarn/test-yarn-install.js @@ -65,7 +65,7 @@ test('yarn-install: timeout', async (t) => { packageManagers, sandbox, { - timeoutLength: 100 + timeout: 100 } ); try { diff --git a/test/yarn/test-yarn-test.js b/test/yarn/test-yarn-test.js index 3f082f71b..b56cadf4c 100644 --- a/test/yarn/test-yarn-test.js +++ b/test/yarn/test-yarn-test.js @@ -121,7 +121,7 @@ test('yarn-test: timeout', async (t) => { packageManagers, sandbox, { - timeoutLength: 100 + timeout: 100 } ); try {