Skip to content

Commit

Permalink
test: add common.skipIfEslintMissing
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Yuta Hiroto <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
  • Loading branch information
MylesBorins committed Feb 21, 2018
1 parent dc45685 commit f960ad4
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 12 deletions.
5 changes: 5 additions & 0 deletions test/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,11 @@ Path to the project directory.

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
Expand Down
8 changes: 8 additions & 0 deletions test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-eslint-crypto-check.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-eslint-lowercase-name-for-primitive.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-eslint-no-let-in-for-declaration.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-eslint-no-unescaped-regexp-dot.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-eslint-number-isnan.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-eslint-prefer-assert-iferror.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-eslint-prefer-assert-methods.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-eslint-prefer-common-expectserror.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-eslint-prefer-common-mustnotcall.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-eslint-prefer-util-format-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-eslint-require-buffer.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-eslint-required-modules.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down

0 comments on commit f960ad4

Please sign in to comment.