Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lookup: add jsdom #740

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -148,6 +148,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
"timeoutLength": Number of milliseconds before timeout
```

If you want to pass options to npm, eg `--registry`, you can usually define an
Expand Down
3 changes: 1 addition & 2 deletions lib/common-args.js
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the default not be kept / how come the removal is necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the default is set at this point it overrides the module-specific timeout later on at https://github.com/nodejs/citgm/pull/740/files#diff-166959275b22802c268f62f152801cbcR9.

If --timeout is not provided, it falls back to kDefaultTimeout (which previously seems to have been redundant).

description: 'Set timeout for npm install'
})
.option('yarn', {
alias: 'y',
Expand Down
3 changes: 3 additions & 0 deletions lib/lookup.js
Expand Up @@ -162,6 +162,9 @@ function resolve(context) {
if (rep.yarn) {
context.module.useYarn = true;
}
if (rep.timeoutLength) {
context.module.timeoutLength = rep.timeoutLength;
}
context.module.flaky = context.options.failFlaky
? false
: isMatch(rep.flaky);
Expand Down
6 changes: 6 additions & 0 deletions lib/lookup.json
Expand Up @@ -237,6 +237,12 @@
"maintainers": "jeresig",
"ignoreGitHead": true
},
"jsdom": {
"maintainers": ["domenic", "Zirro"],
"timeoutLength": 1200000,
"useGitClone": true,
"yarn": true
},
"koa": {
"flaky": "ubuntu",
"maintainers": "tj"
Expand Down
8 changes: 7 additions & 1 deletion lib/package-manager/test.js
Expand Up @@ -106,7 +106,13 @@ async function test(packageManager, context) {
);

const proc = spawn(bin, args, options);
const finish = timeout(context, proc, runScript, 'Test');
const finish = timeout(
context,
proc,
runScript,
'Test',
context.module.timeoutLength
);

proc.stdout.on('data', (data) => {
context.testOutput.append(data);
Expand Down
5 changes: 3 additions & 2 deletions lib/timeout.js
Expand Up @@ -3,9 +3,10 @@
// Default timeout to 10 minutes if not provided
const kDefaultTimeout = 1000 * 60 * 10;

function timeout(context, proc, next, step) {
function timeout(context, proc, next, step, moduleConfigTimeout) {
let hasRun = false;
const delay = context.options.timeoutLength || kDefaultTimeout;
const delay =
context.options.timeoutLength || 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.
Expand Down