Skip to content

Commit 1402fef

Browse files
committed
test: make tests pass when configured without-ssl
Currently when node is build --without-ssl and the test are run, there are a number of failing test due to tests expecting crypto support to be available. This commit fixes fixes the failure and instead skips the tests that expect crypto to be available. PR-URL: #11631 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 9352528 commit 1402fef

17 files changed

+67
-28
lines changed

test/addons/openssl-binding/binding.gyp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
'targets': [
33
{
44
'target_name': 'binding',
5-
'sources': ['binding.cc'],
6-
'include_dirs': ['../../../deps/openssl/openssl/include'],
5+
'conditions': [
6+
['node_use_openssl=="true"', {
7+
'sources': ['binding.cc'],
8+
'include_dirs': ['../../../deps/openssl/openssl/include'],
9+
}]
10+
]
711
},
812
]
913
}

test/addons/openssl-binding/test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
'use strict';
22

33
const common = require('../../common');
4+
if (!common.hasCrypto) {
5+
common.skip('missing crypto');
6+
process.exit(0);
7+
}
48
const assert = require('assert');
59
const binding = require(`./build/${common.buildType}/binding`);
610
const bytes = new Uint8Array(1024);

test/common.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,3 +638,10 @@ exports.expectsError = function expectsError({code, type, message}) {
638638
return true;
639639
};
640640
};
641+
642+
exports.skipIfInspectorDisabled = function skipIfInspectorDisabled() {
643+
if (!exports.hasCrypto) {
644+
exports.skip('missing ssl support so inspector is disabled');
645+
process.exit(0);
646+
}
647+
};

test/fixtures/tls-connect.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,15 @@
66
const common = require('../common');
77
const fs = require('fs');
88
const join = require('path').join;
9+
// Check if Node was compiled --without-ssl and if so exit early
10+
// as the require of tls will otherwise throw an Error.
11+
if (!common.hasCrypto) {
12+
common.skip('missing crypto');
13+
process.exit(0);
14+
}
915
const tls = require('tls');
1016
const util = require('util');
1117

12-
module.exports = exports = checkCrypto;
13-
14-
function checkCrypto() {
15-
if (!common.hasCrypto) {
16-
common.skip('missing crypto');
17-
process.exit(0);
18-
}
19-
return exports;
20-
}
21-
2218
exports.assert = require('assert');
2319
exports.debug = util.debuglog('test');
2420
exports.tls = tls;

test/inspector/test-inspector.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict';
2-
require('../common');
2+
const common = require('../common');
3+
common.skipIfInspectorDisabled();
34
const assert = require('assert');
45
const helper = require('./inspector-helper.js');
56

test/inspector/test-not-blocked-on-idle.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict';
2-
require('../common');
2+
const common = require('../common');
3+
common.skipIfInspectorDisabled();
34
const helper = require('./inspector-helper.js');
45

56
function shouldShutDown(session) {

test/parallel/test-cluster-inspector-debug-port.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22
// Flags: --inspect={PORT}
33
const common = require('../common');
4+
common.skipIfInspectorDisabled();
45
const assert = require('assert');
56
const cluster = require('cluster');
67
const debuggerPort = common.PORT;

test/parallel/test-tls-addca.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const common = require('../common');
88
const join = require('path').join;
99
const {
1010
assert, connect, keys, tls
11-
} = require(join(common.fixturesDir, 'tls-connect'))();
11+
} = require(join(common.fixturesDir, 'tls-connect'));
1212

1313
const contextWithoutCert = tls.createSecureContext({});
1414
const contextWithCert = tls.createSecureContext({});

test/parallel/test-tls-ca-concat.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const common = require('../common');
77
const join = require('path').join;
88
const {
99
assert, connect, keys
10-
} = require(join(common.fixturesDir, 'tls-connect'))();
10+
} = require(join(common.fixturesDir, 'tls-connect'));
1111

1212
connect({
1313
client: {

test/parallel/test-tls-cert-chains-concat.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const common = require('../common');
77
const join = require('path').join;
88
const {
99
assert, connect, debug, keys
10-
} = require(join(common.fixturesDir, 'tls-connect'))();
10+
} = require(join(common.fixturesDir, 'tls-connect'));
1111

1212
// agent6-cert.pem includes cert for agent6 and ca3
1313
connect({

0 commit comments

Comments
 (0)