Skip to content

Commit 50dad38

Browse files
eregonmislav
andcommitted
Improve test for building OpenSSL under macOS
Co-authored-by: Mislav Marohnić <git@mislav.net>
1 parent c7a51ea commit 50dad38

File tree

1 file changed

+50
-2
lines changed

1 file changed

+50
-2
lines changed

test/build.bats

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ make install
369369
OUT
370370
}
371371

372-
@test "install bundled OpenSSL" {
372+
@test "install bundled OpenSSL on Linux" {
373373
cached_tarball "openssl-1.1.1w" config
374374
cached_tarball "ruby-3.2.0" configure
375375

@@ -393,7 +393,10 @@ DEF
393393
unstub uname
394394
unstub brew
395395
unstub cc
396-
# unstub openssl
396+
# Depending on certain system certificate files being present under /etc/,
397+
# `openssl version -d` might not have been called, so avoid unstubbing it
398+
# since that would verify the number of invocations.
399+
#unstub openssl
397400
unstub make
398401

399402
assert_build_log <<OUT
@@ -406,6 +409,51 @@ make install
406409
OUT
407410
}
408411

412+
@test "install bundled OpenSSL on macOS" {
413+
cached_tarball "openssl-1.1.1w" config
414+
cached_tarball "ruby-3.2.0" configure
415+
416+
stub_repeated uname '-s : echo Darwin'
417+
stub security \
418+
'find-certificate -a -p /Library/Keychains/System.keychain : echo "System.keychain"' \
419+
'find-certificate -a -p /System/Library/Keychains/SystemRootCertificates.keychain : echo "SystemRootCertificates.keychain"'
420+
stub_repeated brew false
421+
stub cc
422+
stub openssl
423+
stub_make_install "install_sw"
424+
stub_make_install
425+
426+
mkdir -p "$INSTALL_ROOT"/openssl/ssl # OPENSSLDIR
427+
run_inline_definition <<DEF
428+
install_package "openssl-1.1.1w" "https://www.openssl.org/source/openssl-1.1.1w.tar.gz" openssl --if needs_openssl_102_300
429+
install_package "ruby-3.2.0" "http://ruby-lang.org/ruby/2.0/ruby-3.2.0.tar.gz"
430+
DEF
431+
assert_success
432+
433+
unstub uname
434+
unstub security
435+
unstub brew
436+
unstub cc
437+
unstub openssl
438+
unstub make
439+
440+
# No rpath on macOS, OpenSSL sets it itself: https://wiki.openssl.org/index.php/Compilation_and_Installation#Using_RPATHs
441+
assert_build_log <<OUT
442+
openssl-1.1.1w: [--prefix=${INSTALL_ROOT}/openssl,--openssldir=${INSTALL_ROOT}/openssl/ssl,--libdir=lib,zlib-dynamic,no-ssl3,shared]
443+
make -j 2
444+
make install_sw install_ssldirs
445+
ruby-3.2.0: [--prefix=$INSTALL_ROOT,--with-openssl-dir=$INSTALL_ROOT/openssl,--with-ext=openssl,psych,+] PKG_CONFIG_PATH=${TMP}/install/openssl/lib/pkgconfig
446+
PKG_CONFIG_PATH=${TMP}/install/openssl/lib/pkgconfig make -j 2
447+
make install
448+
OUT
449+
450+
run cat "$INSTALL_ROOT"/openssl/ssl/cert.pem
451+
assert_output <<PEM
452+
System.keychain
453+
SystemRootCertificates.keychain
454+
PEM
455+
}
456+
409457
@test "skip bundling OpenSSL if custom openssl dir was specified" {
410458
cached_tarball "ruby-3.2.0" configure
411459

0 commit comments

Comments
 (0)