From a3f7471d352872472c2e59de97eb5bb5f3f55c5e Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Mon, 18 Feb 2019 13:20:58 +0100 Subject: [PATCH] build,test: guard eslint with crypto check Currently, configuring --without-ssl will cause the lint-js target to fail with the following error: $ make lint-js Running JS linter... internal/util.js:101 throw new ERR_NO_CRYPTO(); ^ Error [ERR_NO_CRYPTO]: Node.js is not compiled with OpenSSL crypto support at assertCrypto (internal/util.js:101:11) at crypto.js:31:1 ... (/node/tools/node_modules/eslint/node_modules/file-entry-cache/ cache.js:2:14) at Module._compile (internal/modules/cjs/loader.js:746:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:757:10) make: *** [lint-js] Error 1 There are also a number of tests that are affected in a similar way. This commit adds crypto checks to allow for lint-js and the affected tests to be skipped when configured --without-ssl. PR-URL: https://github.com/nodejs/node/pull/26182 Reviewed-By: Richard Lau Reviewed-By: Colin Ihrig Reviewed-By: Refael Ackermann Reviewed-By: Ruben Bridgewater --- Makefile | 8 ++++++-- test/parallel/test-eslint-alphabetize-errors.js | 2 ++ test/parallel/test-eslint-crypto-check.js | 2 ++ test/parallel/test-eslint-documented-errors.js | 2 ++ test/parallel/test-eslint-duplicate-requires.js | 2 ++ test/parallel/test-eslint-eslint-check.js | 2 ++ test/parallel/test-eslint-inspector-check.js | 2 ++ test/parallel/test-eslint-lowercase-name-for-primitive.js | 2 ++ test/parallel/test-eslint-no-let-in-for-declaration.js | 2 ++ test/parallel/test-eslint-no-unescaped-regexp-dot.js | 2 ++ test/parallel/test-eslint-number-isnan.js | 2 ++ test/parallel/test-eslint-prefer-assert-iferror.js | 2 ++ test/parallel/test-eslint-prefer-assert-methods.js | 2 ++ test/parallel/test-eslint-prefer-common-expectserror.js | 2 ++ test/parallel/test-eslint-prefer-common-mustnotcall.js | 2 ++ test/parallel/test-eslint-prefer-util-format-errors.js | 2 ++ test/parallel/test-eslint-require-buffer.js | 2 ++ test/parallel/test-eslint-required-modules.js | 2 ++ 18 files changed, 40 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index c3c9bdf6f765e4..3d8ef4dc5764bb 100644 --- a/Makefile +++ b/Makefile @@ -1184,8 +1184,12 @@ lint-js-fix: # Note that on the CI `lint-js-ci` is run instead. # Lints the JavaScript code with eslint. lint-js: - @echo "Running JS linter..." - @$(call available-node,$(run-lint-js)) + @if [ "$(shell $(node_use_openssl))" != "true" ]; then \ + echo "Skipping $@ (no crypto)"; \ + else \ + echo "Running JS linter..."; \ + $(call available-node,$(run-lint-js)) \ + fi jslint: lint-js @echo "Please use lint-js instead of jslint" diff --git a/test/parallel/test-eslint-alphabetize-errors.js b/test/parallel/test-eslint-alphabetize-errors.js index 3f2a5b3fd35c8f..a9bc26d7f0540a 100644 --- a/test/parallel/test-eslint-alphabetize-errors.js +++ b/test/parallel/test-eslint-alphabetize-errors.js @@ -1,6 +1,8 @@ 'use strict'; const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); common.skipIfEslintMissing(); const RuleTester = require('../../tools/node_modules/eslint').RuleTester; diff --git a/test/parallel/test-eslint-crypto-check.js b/test/parallel/test-eslint-crypto-check.js index 2325a04354c53b..0a973f4c9c951d 100644 --- a/test/parallel/test-eslint-crypto-check.js +++ b/test/parallel/test-eslint-crypto-check.js @@ -1,6 +1,8 @@ 'use strict'; const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); common.skipIfEslintMissing(); diff --git a/test/parallel/test-eslint-documented-errors.js b/test/parallel/test-eslint-documented-errors.js index 533b829e78a298..a047ecd35847e0 100644 --- a/test/parallel/test-eslint-documented-errors.js +++ b/test/parallel/test-eslint-documented-errors.js @@ -1,6 +1,8 @@ 'use strict'; const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); common.skipIfEslintMissing(); const RuleTester = require('../../tools/node_modules/eslint').RuleTester; diff --git a/test/parallel/test-eslint-duplicate-requires.js b/test/parallel/test-eslint-duplicate-requires.js index c7edaeed2b6b6e..5932fac48e0991 100644 --- a/test/parallel/test-eslint-duplicate-requires.js +++ b/test/parallel/test-eslint-duplicate-requires.js @@ -1,6 +1,8 @@ 'use strict'; const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); common.skipIfEslintMissing(); diff --git a/test/parallel/test-eslint-eslint-check.js b/test/parallel/test-eslint-eslint-check.js index 46e2a6a4a2ce47..c1ee3d501f0eec 100644 --- a/test/parallel/test-eslint-eslint-check.js +++ b/test/parallel/test-eslint-eslint-check.js @@ -1,6 +1,8 @@ 'use strict'; const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); common.skipIfEslintMissing(); diff --git a/test/parallel/test-eslint-inspector-check.js b/test/parallel/test-eslint-inspector-check.js index ae71c004029771..cf9f60e94505b8 100644 --- a/test/parallel/test-eslint-inspector-check.js +++ b/test/parallel/test-eslint-inspector-check.js @@ -1,6 +1,8 @@ 'use strict'; const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); common.skipIfEslintMissing(); const RuleTester = require('../../tools/node_modules/eslint').RuleTester; diff --git a/test/parallel/test-eslint-lowercase-name-for-primitive.js b/test/parallel/test-eslint-lowercase-name-for-primitive.js index f196f3f45ce82a..11cba8f3f8e697 100644 --- a/test/parallel/test-eslint-lowercase-name-for-primitive.js +++ b/test/parallel/test-eslint-lowercase-name-for-primitive.js @@ -1,6 +1,8 @@ 'use strict'; const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); common.skipIfEslintMissing(); diff --git a/test/parallel/test-eslint-no-let-in-for-declaration.js b/test/parallel/test-eslint-no-let-in-for-declaration.js index ed8f306eea8ad5..3afabf72f54dcb 100644 --- a/test/parallel/test-eslint-no-let-in-for-declaration.js +++ b/test/parallel/test-eslint-no-let-in-for-declaration.js @@ -1,6 +1,8 @@ 'use strict'; const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); common.skipIfEslintMissing(); diff --git a/test/parallel/test-eslint-no-unescaped-regexp-dot.js b/test/parallel/test-eslint-no-unescaped-regexp-dot.js index e6f09291b0838d..69600d80731302 100644 --- a/test/parallel/test-eslint-no-unescaped-regexp-dot.js +++ b/test/parallel/test-eslint-no-unescaped-regexp-dot.js @@ -1,6 +1,8 @@ 'use strict'; const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); common.skipIfEslintMissing(); diff --git a/test/parallel/test-eslint-number-isnan.js b/test/parallel/test-eslint-number-isnan.js index b290a48a8957e7..73359be3bcd37f 100644 --- a/test/parallel/test-eslint-number-isnan.js +++ b/test/parallel/test-eslint-number-isnan.js @@ -1,6 +1,8 @@ 'use strict'; const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); common.skipIfEslintMissing(); diff --git a/test/parallel/test-eslint-prefer-assert-iferror.js b/test/parallel/test-eslint-prefer-assert-iferror.js index 7dc3bbe7bcda4d..342459f0b77ce4 100644 --- a/test/parallel/test-eslint-prefer-assert-iferror.js +++ b/test/parallel/test-eslint-prefer-assert-iferror.js @@ -1,6 +1,8 @@ 'use strict'; const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); common.skipIfEslintMissing(); diff --git a/test/parallel/test-eslint-prefer-assert-methods.js b/test/parallel/test-eslint-prefer-assert-methods.js index 3ad1cd5c376e9b..a5829cdce3054f 100644 --- a/test/parallel/test-eslint-prefer-assert-methods.js +++ b/test/parallel/test-eslint-prefer-assert-methods.js @@ -1,6 +1,8 @@ 'use strict'; const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); common.skipIfEslintMissing(); diff --git a/test/parallel/test-eslint-prefer-common-expectserror.js b/test/parallel/test-eslint-prefer-common-expectserror.js index e0d208b68bb743..9829b2adb8ea21 100644 --- a/test/parallel/test-eslint-prefer-common-expectserror.js +++ b/test/parallel/test-eslint-prefer-common-expectserror.js @@ -1,6 +1,8 @@ 'use strict'; const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); common.skipIfEslintMissing(); diff --git a/test/parallel/test-eslint-prefer-common-mustnotcall.js b/test/parallel/test-eslint-prefer-common-mustnotcall.js index e6e9d1d2f88332..dba244a2a9fa89 100644 --- a/test/parallel/test-eslint-prefer-common-mustnotcall.js +++ b/test/parallel/test-eslint-prefer-common-mustnotcall.js @@ -1,6 +1,8 @@ 'use strict'; const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); common.skipIfEslintMissing(); diff --git a/test/parallel/test-eslint-prefer-util-format-errors.js b/test/parallel/test-eslint-prefer-util-format-errors.js index 560222438b9aee..762fec28b1f1d8 100644 --- a/test/parallel/test-eslint-prefer-util-format-errors.js +++ b/test/parallel/test-eslint-prefer-util-format-errors.js @@ -3,6 +3,8 @@ /* eslint-disable no-template-curly-in-string */ const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); common.skipIfEslintMissing(); diff --git a/test/parallel/test-eslint-require-buffer.js b/test/parallel/test-eslint-require-buffer.js index d928c435480e5e..e0abd0c2d8d524 100644 --- a/test/parallel/test-eslint-require-buffer.js +++ b/test/parallel/test-eslint-require-buffer.js @@ -1,6 +1,8 @@ 'use strict'; const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); common.skipIfEslintMissing(); diff --git a/test/parallel/test-eslint-required-modules.js b/test/parallel/test-eslint-required-modules.js index dbdc135ccf633f..6b2b0d95028d73 100644 --- a/test/parallel/test-eslint-required-modules.js +++ b/test/parallel/test-eslint-required-modules.js @@ -1,6 +1,8 @@ 'use strict'; const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); common.skipIfEslintMissing();