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 <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>
  • Loading branch information
MylesBorins committed Feb 26, 2018
1 parent 8cc0ea7 commit 474d776
Show file tree
Hide file tree
Showing 15 changed files with 52 additions and 13 deletions.
5 changes: 5 additions & 0 deletions test/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,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 @@ -551,6 +551,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-alphabetize-errors.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/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/alphabetize-errors');
Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-eslint-buffer-constructor.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/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/buffer-constructor');
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/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/crypto-check');
Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-eslint-inspector-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/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/inspector-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/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/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/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/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/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/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-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/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/prefer-common-mustnotcall');
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/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/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/required-modules');
Expand Down

0 comments on commit 474d776

Please sign in to comment.