0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 07:00:59 +01:00

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: https://github.com/nodejs/node/pull/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>
This commit is contained in:
Myles Borins 2018-02-15 18:47:10 -05:00 committed by James M Snell
parent 6ab288f3b8
commit 1fd69872e6
14 changed files with 49 additions and 12 deletions

View File

@ -353,6 +353,11 @@ Path to the 'root' directory. either `/` or `c:\\` (windows)
Logs '1..0 # Skipped: ' + `msg` and exits with exit code `0`.
### skipIfEslintMissing()
Skip the rest of the tests in the current file when `ESLint` is not available
at `tools/node_modules/eslint`
### skipIfInspectorDisabled()
Skip the rest of the tests in the current file when the Inspector

View File

@ -494,6 +494,14 @@ exports.fileExists = function(pathname) {
}
};
exports.skipIfEslintMissing = function() {
if (!exports.fileExists(
path.join('..', '..', 'tools', 'node_modules', 'eslint')
)) {
exports.skip('missing ESLint');
}
};
exports.canCreateSymLink = function() {
// On Windows, creating symlinks requires admin privileges.
// We'll only try to run symlink test if we have enough privileges.

View File

@ -1,6 +1,8 @@
'use strict';
require('../common');
const common = require('../common');
common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/crypto-check');

View File

@ -1,6 +1,8 @@
'use strict';
require('../common');
const common = require('../common');
common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/lowercase-name-for-primitive');

View File

@ -1,6 +1,8 @@
'use strict';
require('../common');
const common = require('../common');
common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/no-let-in-for-declaration');

View File

@ -1,6 +1,8 @@
'use strict';
require('../common');
const common = require('../common');
common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/no-unescaped-regexp-dot');

View File

@ -1,6 +1,8 @@
'use strict';
require('../common');
const common = require('../common');
common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/number-isnan');

View File

@ -1,6 +1,8 @@
'use strict';
require('../common');
const common = require('../common');
common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/prefer-assert-iferror');

View File

@ -1,6 +1,8 @@
'use strict';
require('../common');
const common = require('../common');
common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/prefer-assert-methods');

View File

@ -1,6 +1,8 @@
'use strict';
require('../common');
const common = require('../common');
common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/prefer-common-expectserror');

View File

@ -1,6 +1,8 @@
'use strict';
require('../common');
const common = require('../common');
common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/prefer-common-mustnotcall');

View File

@ -2,7 +2,9 @@
/* eslint-disable no-template-curly-in-string */
require('../common');
const common = require('../common');
common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/prefer-util-format-errors');

View File

@ -1,6 +1,8 @@
'use strict';
require('../common');
const common = require('../common');
common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/require-buffer');

View File

@ -1,6 +1,8 @@
'use strict';
require('../common');
const common = require('../common');
common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/required-modules');