Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0eead8c

Browse filesBrowse files
committed
test: add common.skipIfEslintMissing
We've added a number of tests that hook into ESLint which can error when running the test suite with the distributed tarball. This PR adds a new test helper `common.skipIfEslintMissing` and will skip remaining tests in a file when `ESLint` is not available at `tools/node_modules/eslint` PR-URL: #18807 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 840a2ea commit 0eead8c
Copy full SHA for 0eead8c
Expand file treeCollapse file tree

14 files changed

+49
-12
lines changed
Open diff view settings
Collapse file

‎test/common/README.md‎

Copy file name to clipboardExpand all lines: test/common/README.md
+5Lines changed: 5 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,11 @@ Path to the project directory.
358358

359359
Logs '1..0 # Skipped: ' + `msg` and exits with exit code `0`.
360360

361+
### skipIfEslintMissing()
362+
363+
Skip the rest of the tests in the current file when `ESLint` is not available
364+
at `tools/node_modules/eslint`
365+
361366
### skipIfInspectorDisabled()
362367

363368
Skip the rest of the tests in the current file when the Inspector
Collapse file

‎test/common/index.js‎

Copy file name to clipboardExpand all lines: test/common/index.js
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,14 @@ exports.fileExists = function(pathname) {
494494
}
495495
};
496496

497+
exports.skipIfEslintMissing = function() {
498+
if (!exports.fileExists(
499+
path.join('..', '..', 'tools', 'node_modules', 'eslint')
500+
)) {
501+
exports.skip('missing ESLint');
502+
}
503+
};
504+
497505
exports.canCreateSymLink = function() {
498506
// On Windows, creating symlinks requires admin privileges.
499507
// We'll only try to run symlink test if we have enough privileges.
Collapse file

‎test/parallel/test-eslint-crypto-check.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-eslint-crypto-check.js
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
'use strict';
22

3-
require('../common');
3+
const common = require('../common');
4+
5+
common.skipIfEslintMissing();
46

57
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
68
const rule = require('../../tools/eslint-rules/crypto-check');
Collapse file

‎test/parallel/test-eslint-lowercase-name-for-primitive.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-eslint-lowercase-name-for-primitive.js
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
'use strict';
22

3-
require('../common');
3+
const common = require('../common');
4+
5+
common.skipIfEslintMissing();
46

57
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
68
const rule = require('../../tools/eslint-rules/lowercase-name-for-primitive');
Collapse file

‎test/parallel/test-eslint-no-let-in-for-declaration.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-eslint-no-let-in-for-declaration.js
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
'use strict';
22

3-
require('../common');
3+
const common = require('../common');
4+
5+
common.skipIfEslintMissing();
46

57
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
68
const rule = require('../../tools/eslint-rules/no-let-in-for-declaration');
Collapse file

‎test/parallel/test-eslint-no-unescaped-regexp-dot.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-eslint-no-unescaped-regexp-dot.js
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
'use strict';
22

3-
require('../common');
3+
const common = require('../common');
4+
5+
common.skipIfEslintMissing();
46

57
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
68
const rule = require('../../tools/eslint-rules/no-unescaped-regexp-dot');
Collapse file

‎test/parallel/test-eslint-number-isnan.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-eslint-number-isnan.js
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
'use strict';
22

3-
require('../common');
3+
const common = require('../common');
4+
5+
common.skipIfEslintMissing();
46

57
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
68
const rule = require('../../tools/eslint-rules/number-isnan');
Collapse file

‎test/parallel/test-eslint-prefer-assert-iferror.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-eslint-prefer-assert-iferror.js
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
'use strict';
22

3-
require('../common');
3+
const common = require('../common');
4+
5+
common.skipIfEslintMissing();
46

57
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
68
const rule = require('../../tools/eslint-rules/prefer-assert-iferror');
Collapse file

‎test/parallel/test-eslint-prefer-assert-methods.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-eslint-prefer-assert-methods.js
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
'use strict';
22

3-
require('../common');
3+
const common = require('../common');
4+
5+
common.skipIfEslintMissing();
46

57
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
68
const rule = require('../../tools/eslint-rules/prefer-assert-methods');
Collapse file

‎test/parallel/test-eslint-prefer-common-expectserror.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-eslint-prefer-common-expectserror.js
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
'use strict';
22

3-
require('../common');
3+
const common = require('../common');
4+
5+
common.skipIfEslintMissing();
46

57
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
68
const rule = require('../../tools/eslint-rules/prefer-common-expectserror');

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.