From df2777b32bdc9215ae0359da8d139971e464733c Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Mon, 30 May 2016 01:45:20 +0200 Subject: [PATCH] test: fix tests for non-crypto builds Fix running the tests when node was compiled without crypto support. Some of these are cleanup after 52bae222a3a8480b2, where common was used before it was required. --- test/parallel/test-async-wrap-check-providers.js | 5 +++++ test/parallel/test-async-wrap-post-did-throw.js | 7 ++++++- test/parallel/test-async-wrap-throw-from-callback.js | 7 ++++++- test/parallel/test-crypto-rsa-dsa.js | 2 +- test/parallel/test-http-invalid-urls.js | 7 ++++++- test/parallel/test-https-agent-getname.js | 7 ++++++- test/parallel/test-https-connect-address-family.js | 5 +++++ test/parallel/test-https-resume-after-renew.js | 7 ++++++- test/parallel/test-net-access-byteswritten.js | 6 +++++- test/parallel/test-npm-install.js | 4 ++++ test/parallel/test-stream-base-no-abort.js | 7 ++++++- test/parallel/test-tls-async-cb-after-socket-end.js | 11 +++++------ test/parallel/test-tls-basic-validations.js | 7 ++++++- test/parallel/test-tls-connect-address-family.js | 5 +++++ test/parallel/test-tls-connect-stream-writes.js | 5 +++++ test/parallel/test-tls-npn-server-client.js | 2 +- test/parallel/test-tls-parse-cert-string.js | 6 +++++- test/parallel/test-tls-securepair-fiftharg.js | 5 +++++ test/parallel/test-tls-sni-option.js | 2 +- test/parallel/test-tls-sni-server-client.js | 2 +- test/parallel/test-tls-two-cas-one-string.js | 5 +++++ test/parallel/test-tls-wrap-no-abort.js | 7 ++++++- 22 files changed, 101 insertions(+), 20 deletions(-) diff --git a/test/parallel/test-async-wrap-check-providers.js b/test/parallel/test-async-wrap-check-providers.js index 4b5447b82cbfab..5125890f99d06f 100644 --- a/test/parallel/test-async-wrap-check-providers.js +++ b/test/parallel/test-async-wrap-check-providers.js @@ -1,6 +1,11 @@ 'use strict'; const common = require('../common'); +if (!common.hasCrypto) { + common.skip('missing crypto'); + return; +} + const assert = require('assert'); const crypto = require('crypto'); const dgram = require('dgram'); diff --git a/test/parallel/test-async-wrap-post-did-throw.js b/test/parallel/test-async-wrap-post-did-throw.js index 9781983f58987e..37f18b649da139 100644 --- a/test/parallel/test-async-wrap-post-did-throw.js +++ b/test/parallel/test-async-wrap-post-did-throw.js @@ -1,6 +1,11 @@ 'use strict'; -require('../common'); +const common = require('../common'); +if (!common.hasCrypto) { + common.skip('missing crypto'); + return; +} + const assert = require('assert'); const async_wrap = process.binding('async_wrap'); var asyncThrows = 0; diff --git a/test/parallel/test-async-wrap-throw-from-callback.js b/test/parallel/test-async-wrap-throw-from-callback.js index bfbe32c38b021a..8b8316a65f9c2a 100644 --- a/test/parallel/test-async-wrap-throw-from-callback.js +++ b/test/parallel/test-async-wrap-throw-from-callback.js @@ -1,6 +1,11 @@ 'use strict'; -require('../common'); +const common = require('../common'); +if (!common.hasCrypto) { + common.skip('missing crypto'); + return; +} + const async_wrap = process.binding('async_wrap'); const assert = require('assert'); const crypto = require('crypto'); diff --git a/test/parallel/test-crypto-rsa-dsa.js b/test/parallel/test-crypto-rsa-dsa.js index 2e29cd723d2677..15b56c642ba356 100644 --- a/test/parallel/test-crypto-rsa-dsa.js +++ b/test/parallel/test-crypto-rsa-dsa.js @@ -2,12 +2,12 @@ var common = require('../common'); var assert = require('assert'); var fs = require('fs'); -var constants = require('crypto').constants; if (!common.hasCrypto) { common.skip('missing crypto'); return; } +var constants = require('crypto').constants; var crypto = require('crypto'); // Test certificates diff --git a/test/parallel/test-http-invalid-urls.js b/test/parallel/test-http-invalid-urls.js index 678e8eceeb2d46..65cca822f9b2a5 100644 --- a/test/parallel/test-http-invalid-urls.js +++ b/test/parallel/test-http-invalid-urls.js @@ -1,6 +1,11 @@ 'use strict'; -require('../common'); +const common = require('../common'); +if (!common.hasCrypto) { + common.skip('missing crypto'); + return; +} + const assert = require('assert'); const http = require('http'); const https = require('https'); diff --git a/test/parallel/test-https-agent-getname.js b/test/parallel/test-https-agent-getname.js index 63473775b0e0f6..49c1dcef4fb5fb 100644 --- a/test/parallel/test-https-agent-getname.js +++ b/test/parallel/test-https-agent-getname.js @@ -1,6 +1,11 @@ 'use strict'; -require('../common'); +const common = require('../common'); +if (!common.hasCrypto) { + common.skip('missing crypto'); + return; +} + const assert = require('assert'); const https = require('https'); diff --git a/test/parallel/test-https-connect-address-family.js b/test/parallel/test-https-connect-address-family.js index b2f3c233cfd720..5bfb7d851c5c50 100644 --- a/test/parallel/test-https-connect-address-family.js +++ b/test/parallel/test-https-connect-address-family.js @@ -1,5 +1,10 @@ 'use strict'; const common = require('../common'); +if (!common.hasCrypto) { + common.skip('missing crypto'); + return; +} + const assert = require('assert'); const https = require('https'); diff --git a/test/parallel/test-https-resume-after-renew.js b/test/parallel/test-https-resume-after-renew.js index 6a1238f6e8a7be..a1fb93194f4347 100644 --- a/test/parallel/test-https-resume-after-renew.js +++ b/test/parallel/test-https-resume-after-renew.js @@ -1,5 +1,10 @@ 'use strict'; -var common = require('../common'); +const common = require('../common'); +if (!common.hasCrypto) { + common.skip('missing crypto'); + return; +} + var fs = require('fs'); var https = require('https'); var crypto = require('crypto'); diff --git a/test/parallel/test-net-access-byteswritten.js b/test/parallel/test-net-access-byteswritten.js index 362d533bbb87c1..5b734e7c6dc853 100644 --- a/test/parallel/test-net-access-byteswritten.js +++ b/test/parallel/test-net-access-byteswritten.js @@ -1,6 +1,10 @@ 'use strict'; -require('../common'); +const common = require('../common'); +if (!common.hasCrypto) { + common.skip('missing crypto'); + return; +} const assert = require('assert'); const net = require('net'); const tls = require('tls'); diff --git a/test/parallel/test-npm-install.js b/test/parallel/test-npm-install.js index c716e48aefedab..6fc5151d383383 100644 --- a/test/parallel/test-npm-install.js +++ b/test/parallel/test-npm-install.js @@ -1,5 +1,9 @@ 'use strict'; const common = require('../common'); +if (!common.hasCrypto) { + common.skip('missing crypto'); + return; +} const path = require('path'); const spawn = require('child_process').spawn; diff --git a/test/parallel/test-stream-base-no-abort.js b/test/parallel/test-stream-base-no-abort.js index d2d87026768d3c..fa33bfb019c03d 100644 --- a/test/parallel/test-stream-base-no-abort.js +++ b/test/parallel/test-stream-base-no-abort.js @@ -1,9 +1,14 @@ 'use strict'; +const common = require('../common'); +if (!common.hasCrypto) { + common.skip('missing crypto'); + return; +} + const async_wrap = process.binding('async_wrap'); const uv = process.binding('uv'); const assert = require('assert'); -const common = require('../common'); const dgram = require('dgram'); const fs = require('fs'); const net = require('net'); diff --git a/test/parallel/test-tls-async-cb-after-socket-end.js b/test/parallel/test-tls-async-cb-after-socket-end.js index f43f7e9441e28b..34621053e929d7 100644 --- a/test/parallel/test-tls-async-cb-after-socket-end.js +++ b/test/parallel/test-tls-async-cb-after-socket-end.js @@ -1,16 +1,15 @@ 'use strict'; -var common = require('../common'); - -var path = require('path'); -var fs = require('fs'); -const SSL_OP_NO_TICKET = require('crypto').constants.SSL_OP_NO_TICKET; - +const common = require('../common'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } +const path = require('path'); +const fs = require('fs'); +const SSL_OP_NO_TICKET = require('crypto').constants.SSL_OP_NO_TICKET; + var tls = require('tls'); var options = { diff --git a/test/parallel/test-tls-basic-validations.js b/test/parallel/test-tls-basic-validations.js index a741f3b49c47ac..fa0165b3706225 100644 --- a/test/parallel/test-tls-basic-validations.js +++ b/test/parallel/test-tls-basic-validations.js @@ -1,6 +1,11 @@ 'use strict'; -require('../common'); +const common = require('../common'); +if (!common.hasCrypto) { + common.skip('missing crypto'); + return; +} + const assert = require('assert'); const tls = require('tls'); diff --git a/test/parallel/test-tls-connect-address-family.js b/test/parallel/test-tls-connect-address-family.js index 665a71dfe666d9..59a5c579efb281 100644 --- a/test/parallel/test-tls-connect-address-family.js +++ b/test/parallel/test-tls-connect-address-family.js @@ -1,5 +1,10 @@ 'use strict'; const common = require('../common'); +if (!common.hasCrypto) { + common.skip('missing crypto'); + return; +} + const assert = require('assert'); const tls = require('tls'); diff --git a/test/parallel/test-tls-connect-stream-writes.js b/test/parallel/test-tls-connect-stream-writes.js index 811967a8967f73..7a7bc7a70849c8 100644 --- a/test/parallel/test-tls-connect-stream-writes.js +++ b/test/parallel/test-tls-connect-stream-writes.js @@ -1,5 +1,10 @@ 'use strict'; const common = require('../common'); +if (!common.hasCrypto) { + common.skip('missing crypto'); + return; +} + const assert = require('assert'); const fs = require('fs'); const tls = require('tls'); diff --git a/test/parallel/test-tls-npn-server-client.js b/test/parallel/test-tls-npn-server-client.js index 446d249c60856d..d6fcb5956cd58f 100644 --- a/test/parallel/test-tls-npn-server-client.js +++ b/test/parallel/test-tls-npn-server-client.js @@ -1,11 +1,11 @@ 'use strict'; +const common = require('../common'); if (!process.features.tls_npn) { common.skip('node compiled without OpenSSL or ' + 'with old OpenSSL version.'); return; } -const common = require('../common'); const assert = require('assert'); const fs = require('fs'); diff --git a/test/parallel/test-tls-parse-cert-string.js b/test/parallel/test-tls-parse-cert-string.js index 2a3c44948130d7..b90fa2b32cf373 100644 --- a/test/parallel/test-tls-parse-cert-string.js +++ b/test/parallel/test-tls-parse-cert-string.js @@ -1,6 +1,10 @@ 'use strict'; +const common = require('../common'); +if (!common.hasCrypto) { + common.skip('missing crypto'); + return; +} -require('../common'); const assert = require('assert'); const tls = require('tls'); diff --git a/test/parallel/test-tls-securepair-fiftharg.js b/test/parallel/test-tls-securepair-fiftharg.js index b4610117889cc2..99564055efb807 100644 --- a/test/parallel/test-tls-securepair-fiftharg.js +++ b/test/parallel/test-tls-securepair-fiftharg.js @@ -1,6 +1,11 @@ 'use strict'; const common = require('../common'); +if (!common.hasCrypto) { + common.skip('missing crypto'); + return; +} + const assert = require('assert'); const fs = require('fs'); const tls = require('tls'); diff --git a/test/parallel/test-tls-sni-option.js b/test/parallel/test-tls-sni-option.js index c548e2f4247649..f0742d7e1fb325 100644 --- a/test/parallel/test-tls-sni-option.js +++ b/test/parallel/test-tls-sni-option.js @@ -1,11 +1,11 @@ 'use strict'; +const common = require('../common'); if (!process.features.tls_sni) { common.skip('node compiled without OpenSSL or ' + 'with old OpenSSL version.'); return; } -const common = require('../common'); const assert = require('assert'); const fs = require('fs'); diff --git a/test/parallel/test-tls-sni-server-client.js b/test/parallel/test-tls-sni-server-client.js index e228b76bea2abc..422f7e1fb7ead3 100644 --- a/test/parallel/test-tls-sni-server-client.js +++ b/test/parallel/test-tls-sni-server-client.js @@ -1,11 +1,11 @@ 'use strict'; +const common = require('../common'); if (!process.features.tls_sni) { common.skip('node compiled without OpenSSL or ' + 'with old OpenSSL version.'); return; } -const common = require('../common'); const assert = require('assert'); const fs = require('fs'); diff --git a/test/parallel/test-tls-two-cas-one-string.js b/test/parallel/test-tls-two-cas-one-string.js index ba9b3609c2653d..b5fe57801708f7 100644 --- a/test/parallel/test-tls-two-cas-one-string.js +++ b/test/parallel/test-tls-two-cas-one-string.js @@ -1,6 +1,11 @@ 'use strict'; const common = require('../common'); +if (!common.hasCrypto) { + common.skip('missing crypto'); + return; +} + const tls = require('tls'); const fs = require('fs'); diff --git a/test/parallel/test-tls-wrap-no-abort.js b/test/parallel/test-tls-wrap-no-abort.js index a64aea0b0593e3..c18b17a6406321 100644 --- a/test/parallel/test-tls-wrap-no-abort.js +++ b/test/parallel/test-tls-wrap-no-abort.js @@ -1,6 +1,11 @@ 'use strict'; -require('../common'); +const common = require('../common'); +if (!common.hasCrypto) { + common.skip('missing crypto'); + return; +} + const util = require('util'); const TLSWrap = process.binding('tls_wrap').TLSWrap;