rbenv-ruby-build/test/compiler.bats
Mislav Marohnić 6250069ccb
Instruct Ruby to fail the build if openssl or psych are missing
Normally, Ruby `make` step will print a warning about any missing
extensions, but will not abort the build and instead proceed as normal.

Since Ruby installations without openssl or psych are essentially
broken, ruby-build used to have a `verify_openssl` build step to test if
the newly built Ruby can load these extensions, and print helpful
information and abort the build on errors:

    Loading the Ruby openssl extension failed
    ERROR: Ruby install aborted due to missing extensions

The `verify_opensl` implementation was necessary to provide a good
experience for ruby-build users, but was hacky and I would prefer to
eliminate it.

It appears that passing `--with-ext=openssl,psych` to the Ruby configure
step marks those extensions as mandatory and fails the `make` process if
they failed to build. This is exactly the behavior we want, so this
enables the configure option for all Ruby builds.
2023-11-21 17:12:53 +01:00

45 lines
905 B
Bash
Executable file

#!/usr/bin/env bats
load test_helper
export MAKE=make
export MAKE_OPTS='-j 2'
export -n CFLAGS
export -n CC
export -n RUBY_CONFIGURE_OPTS
@test "CC=clang by default on OS X 10.10" {
mkdir -p "$INSTALL_ROOT"
cd "$INSTALL_ROOT"
stub_repeated uname '-s : echo Darwin'
stub sw_vers '-productVersion : echo 10.10'
stub_repeated brew 'false'
# shellcheck disable=SC2016
stub_repeated make 'echo "make $(inspect_args "$@")" >> build.log'
cat > ./configure <<CON
#!${BASH}
echo ./configure "\$@" > build.log
echo CC=\$CC >> build.log
echo CFLAGS=\${CFLAGS-no} >> build.log
CON
chmod +x ./configure
run_inline_definition <<DEF
build_package_standard ruby
DEF
assert_success
run cat build.log
assert_output <<OUT
./configure --prefix=$INSTALL_ROOT --with-ext=openssl,psych,+
CC=clang
CFLAGS=no
make -j 2
make install
OUT
unstub uname
unstub sw_vers
unstub brew
unstub make
}