Loading test/build.bats +24 −20 Original line number Diff line number Diff line Loading @@ -61,8 +61,8 @@ assert_build_log() { cached_tarball "yaml-0.1.6" cached_tarball "ruby-2.0.0" stub uname '-s : echo Linux' stub brew false stub_repeated uname '-s : echo Linux' stub_repeated brew false stub_make_install stub_make_install Loading @@ -70,6 +70,7 @@ assert_build_log() { assert_success unstub uname unstub brew unstub make assert_build_log <<OUT Loading @@ -86,8 +87,8 @@ OUT cached_tarball "yaml-0.1.6" cached_tarball "ruby-2.0.0" stub uname '-s : echo Linux' stub brew false stub_repeated uname '-s : echo Linux' stub_repeated brew false stub_make_install stub_make_install stub patch ' : echo patch "$@" | sed -E "s/\.[[:alnum:]]+$/.XXX/" >> build.log' Loading @@ -100,6 +101,7 @@ PATCH assert_success unstub uname unstub brew unstub make unstub patch Loading @@ -118,8 +120,8 @@ OUT cached_tarball "yaml-0.1.6" cached_tarball "ruby-2.0.0" stub uname '-s : echo Linux' stub brew false stub_repeated uname '-s : echo Linux' stub_repeated brew false stub_make_install stub_make_install stub patch ' : echo patch "$@" | sed -E "s/\.[[:alnum:]]+$/.XXX/" >> build.log' Loading @@ -132,6 +134,7 @@ PATCH assert_success unstub uname unstub brew unstub make unstub patch Loading @@ -150,8 +153,8 @@ OUT cached_tarball "yaml-0.1.6" cached_tarball "ruby-2.0.0" stub uname '-s : echo Linux' stub brew false stub_repeated uname '-s : echo Linux' stub_repeated brew false stub_make_install stub_make_install stub patch ' : echo patch "$@" | sed -E "s/\.[[:alnum:]]+$/.XXX/" >> build.log' Loading @@ -165,6 +168,7 @@ PATCH assert_success unstub uname unstub brew unstub make unstub patch Loading @@ -185,8 +189,8 @@ OUT brew_libdir="$TMP/homebrew-yaml" mkdir -p "$brew_libdir" stub uname '-s : echo Linux' stub brew false "--prefix libyaml : echo '$brew_libdir'" false stub_repeated uname '-s : echo Linux' stub_repeated brew "--prefix libyaml : echo '$brew_libdir'" stub_make_install run_inline_definition <<DEF Loading @@ -211,7 +215,7 @@ OUT gmp_libdir="$TMP/homebrew-gmp" mkdir -p "$gmp_libdir" stub brew false "--prefix gmp : echo '$gmp_libdir'" stub_repeated brew "--prefix gmp : echo '$gmp_libdir'" stub_make_install run_inline_definition <<DEF Loading @@ -235,7 +239,7 @@ OUT readline_libdir="$TMP/homebrew-readline" mkdir -p "$readline_libdir" stub brew "--prefix readline : echo '$readline_libdir'" false stub_repeated brew "--prefix readline : echo '$readline_libdir'" stub_make_install run_inline_definition <<DEF Loading @@ -256,7 +260,7 @@ OUT @test "readline is not linked from Homebrew when explicitly defined" { cached_tarball "ruby-2.0.0" stub brew false stub_repeated brew false stub_make_install export RUBY_CONFIGURE_OPTS='--with-readline-dir=/custom' Loading @@ -278,7 +282,7 @@ OUT @test "number of CPU cores defaults to 2" { cached_tarball "ruby-2.0.0" stub uname '-s : echo Darwin' false stub_repeated uname '-s : echo Darwin' stub sysctl false stub_make_install Loading @@ -301,7 +305,7 @@ OUT @test "number of CPU cores is detected on Mac" { cached_tarball "ruby-2.0.0" stub uname '-s : echo Darwin' false stub_repeated uname '-s : echo Darwin' stub sysctl '-n hw.ncpu : echo 4' stub_make_install Loading @@ -325,7 +329,7 @@ OUT @test "number of CPU cores is detected on FreeBSD" { cached_tarball "ruby-2.0.0" stub uname '-s : echo FreeBSD' false stub_repeated uname '-s : echo FreeBSD' stub sysctl '-n hw.ncpu : echo 1' stub_make_install Loading @@ -349,7 +353,7 @@ OUT @test "setting RUBY_MAKE_INSTALL_OPTS to a multi-word string" { cached_tarball "ruby-2.0.0" stub uname '-s : echo Linux' stub_repeated uname '-s : echo Linux' stub_make_install export RUBY_MAKE_INSTALL_OPTS="DOGE=\"such wow\"" Loading @@ -371,7 +375,7 @@ OUT @test "setting MAKE_INSTALL_OPTS to a multi-word string" { cached_tarball "ruby-2.0.0" stub uname '-s : echo Linux' stub_repeated uname '-s : echo Linux' stub_make_install export MAKE_INSTALL_OPTS="DOGE=\"such wow\"" Loading Loading @@ -402,7 +406,7 @@ OUT @test "make on FreeBSD defaults to gmake" { cached_tarball "ruby-2.0.0" stub uname "-s : echo FreeBSD" false stub_repeated uname "-s : echo FreeBSD" MAKE=gmake stub_make_install MAKE= install_fixture definitions/vanilla-ruby Loading @@ -421,7 +425,7 @@ apply -p1 -i /my/patch.diff exec ./configure "\$@" CONF stub uname '-s : echo Linux' stub_repeated uname '-s : echo Linux' stub apply 'echo apply "$@" >> build.log' stub_make_install Loading test/compiler.bats +20 −10 Original line number Diff line number Diff line Loading @@ -8,9 +8,9 @@ export -n CC export -n RUBY_CONFIGURE_OPTS @test "require_gcc on OS X 10.9" { stub uname '-s : echo Darwin' stub_repeated uname '-s : echo Darwin' stub sw_vers '-productVersion : echo 10.9.5' stub gcc '--version : echo 4.2.1' '--version : echo 4.2.1' stub_repeated gcc '--version : echo 4.2.1' run_inline_definition <<DEF require_gcc Loading @@ -22,12 +22,16 @@ DEF CC=${TMP}/bin/gcc MACOSX_DEPLOYMENT_TARGET=no OUT unstub uname unstub sw_vers unstub gcc } @test "require_gcc on OS X 10.10" { stub uname '-s : echo Darwin' stub_repeated uname '-s : echo Darwin' stub sw_vers '-productVersion : echo 10.10' stub gcc '--version : echo 4.2.1' '--version : echo 4.2.1' stub_repeated gcc '--version : echo 4.2.1' run_inline_definition <<DEF require_gcc Loading @@ -39,6 +43,10 @@ DEF CC=${TMP}/bin/gcc MACOSX_DEPLOYMENT_TARGET=10.9 OUT unstub uname unstub sw_vers unstub gcc } @test "require_gcc silences warnings" { Loading @@ -55,13 +63,10 @@ DEF mkdir -p "$INSTALL_ROOT" cd "$INSTALL_ROOT" stub uname '-s : echo Darwin' '-s : echo Darwin' stub_repeated uname '-s : echo Darwin' stub sw_vers '-productVersion : echo 10.10' stub cc 'false' stub brew 'false' stub make \ 'echo make $@' \ 'echo make $@' stub_repeated brew 'false' stub_repeated make 'echo make $@' cat > ./configure <<CON #!${BASH} Loading @@ -83,4 +88,9 @@ CFLAGS=no make -j 2 make install OUT unstub uname unstub sw_vers unstub brew unstub make } test/rbenv.bats +2 −1 Original line number Diff line number Diff line Loading @@ -77,7 +77,7 @@ OUT } @test "nonexistent version" { stub brew false stub_repeated brew false stub_ruby_build 'echo ERROR >&2 && exit 2' \ "--definitions : echo 1.8.7 1.9.3-p0 1.9.3-p194 2.1.2 | tr ' ' $'\\n'" Loading @@ -97,6 +97,7 @@ If the version you need is missing, try upgrading ruby-build: git -C ${BATS_TEST_DIRNAME}/.. pull OUT unstub brew unstub ruby-build } Loading test/stubs/stub +6 −4 Original line number Diff line number Diff line #!/usr/bin/env bash set -e status=0 status=127 program="${0##*/}" PROGRAM="$(echo "$program" | tr a-z- A-Z_)" [ -n "$TMPDIR" ] || TMPDIR="/tmp" Loading @@ -9,6 +9,7 @@ PROGRAM="$(echo "$program" | tr a-z- A-Z_)" _STUB_PLAN="${PROGRAM}_STUB_PLAN" _STUB_RUN="${PROGRAM}_STUB_RUN" _STUB_INDEX="${PROGRAM}_STUB_INDEX" _STUB_NOINDEX="${PROGRAM}_STUB_NOINDEX" _STUB_RESULT="${PROGRAM}_STUB_RESULT" _STUB_END="${PROGRAM}_STUB_END" _STUB_DEBUG="${PROGRAM}_STUB_DEBUG" Loading @@ -32,7 +33,7 @@ index=0 while IFS= read -r line; do index=$(($index + 1)) if [ -z "${!_STUB_END}" ] && [ $index -eq "${!_STUB_INDEX}" ]; then if [[ -z "${!_STUB_END}" && -n "${!_STUB_NOINDEX}" || $index -eq "${!_STUB_INDEX}" ]]; then # We found the plan line we're interested in. # Start off by assuming success. result=0 Loading Loading @@ -72,7 +73,8 @@ while IFS= read -r line; do ( eval "$command" ) status="$?" set -e else [ -z "${!_STUB_NOINDEX}" ] || break elif [ -z "${!_STUB_NOINDEX}" ]; then eval "${_STUB_RESULT}"=1 fi fi Loading @@ -95,7 +97,7 @@ if [ -n "${!_STUB_END}" ]; then else # If the requested index is larger than the number # of lines in the plan file, we failed. if [ "${!_STUB_INDEX}" -gt $index ]; then if [[ -z "${!_STUB_NOINDEX}" && "${!_STUB_INDEX}" -gt $index ]]; then eval "${_STUB_RESULT}"=1 fi Loading test/test_helper.bash +7 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,13 @@ stub() { for arg in "$@"; do printf "%s\n" "$arg" >> "${TMP}/${program}-stub-plan"; done } stub_repeated() { local program="$1" local prefix="$(echo "$program" | tr a-z- A-Z_)" export "${prefix}_STUB_NOINDEX"=1 stub "$@" } unstub() { local program="$1" local prefix="$(echo "$program" | tr a-z- A-Z_)" Loading Loading
test/build.bats +24 −20 Original line number Diff line number Diff line Loading @@ -61,8 +61,8 @@ assert_build_log() { cached_tarball "yaml-0.1.6" cached_tarball "ruby-2.0.0" stub uname '-s : echo Linux' stub brew false stub_repeated uname '-s : echo Linux' stub_repeated brew false stub_make_install stub_make_install Loading @@ -70,6 +70,7 @@ assert_build_log() { assert_success unstub uname unstub brew unstub make assert_build_log <<OUT Loading @@ -86,8 +87,8 @@ OUT cached_tarball "yaml-0.1.6" cached_tarball "ruby-2.0.0" stub uname '-s : echo Linux' stub brew false stub_repeated uname '-s : echo Linux' stub_repeated brew false stub_make_install stub_make_install stub patch ' : echo patch "$@" | sed -E "s/\.[[:alnum:]]+$/.XXX/" >> build.log' Loading @@ -100,6 +101,7 @@ PATCH assert_success unstub uname unstub brew unstub make unstub patch Loading @@ -118,8 +120,8 @@ OUT cached_tarball "yaml-0.1.6" cached_tarball "ruby-2.0.0" stub uname '-s : echo Linux' stub brew false stub_repeated uname '-s : echo Linux' stub_repeated brew false stub_make_install stub_make_install stub patch ' : echo patch "$@" | sed -E "s/\.[[:alnum:]]+$/.XXX/" >> build.log' Loading @@ -132,6 +134,7 @@ PATCH assert_success unstub uname unstub brew unstub make unstub patch Loading @@ -150,8 +153,8 @@ OUT cached_tarball "yaml-0.1.6" cached_tarball "ruby-2.0.0" stub uname '-s : echo Linux' stub brew false stub_repeated uname '-s : echo Linux' stub_repeated brew false stub_make_install stub_make_install stub patch ' : echo patch "$@" | sed -E "s/\.[[:alnum:]]+$/.XXX/" >> build.log' Loading @@ -165,6 +168,7 @@ PATCH assert_success unstub uname unstub brew unstub make unstub patch Loading @@ -185,8 +189,8 @@ OUT brew_libdir="$TMP/homebrew-yaml" mkdir -p "$brew_libdir" stub uname '-s : echo Linux' stub brew false "--prefix libyaml : echo '$brew_libdir'" false stub_repeated uname '-s : echo Linux' stub_repeated brew "--prefix libyaml : echo '$brew_libdir'" stub_make_install run_inline_definition <<DEF Loading @@ -211,7 +215,7 @@ OUT gmp_libdir="$TMP/homebrew-gmp" mkdir -p "$gmp_libdir" stub brew false "--prefix gmp : echo '$gmp_libdir'" stub_repeated brew "--prefix gmp : echo '$gmp_libdir'" stub_make_install run_inline_definition <<DEF Loading @@ -235,7 +239,7 @@ OUT readline_libdir="$TMP/homebrew-readline" mkdir -p "$readline_libdir" stub brew "--prefix readline : echo '$readline_libdir'" false stub_repeated brew "--prefix readline : echo '$readline_libdir'" stub_make_install run_inline_definition <<DEF Loading @@ -256,7 +260,7 @@ OUT @test "readline is not linked from Homebrew when explicitly defined" { cached_tarball "ruby-2.0.0" stub brew false stub_repeated brew false stub_make_install export RUBY_CONFIGURE_OPTS='--with-readline-dir=/custom' Loading @@ -278,7 +282,7 @@ OUT @test "number of CPU cores defaults to 2" { cached_tarball "ruby-2.0.0" stub uname '-s : echo Darwin' false stub_repeated uname '-s : echo Darwin' stub sysctl false stub_make_install Loading @@ -301,7 +305,7 @@ OUT @test "number of CPU cores is detected on Mac" { cached_tarball "ruby-2.0.0" stub uname '-s : echo Darwin' false stub_repeated uname '-s : echo Darwin' stub sysctl '-n hw.ncpu : echo 4' stub_make_install Loading @@ -325,7 +329,7 @@ OUT @test "number of CPU cores is detected on FreeBSD" { cached_tarball "ruby-2.0.0" stub uname '-s : echo FreeBSD' false stub_repeated uname '-s : echo FreeBSD' stub sysctl '-n hw.ncpu : echo 1' stub_make_install Loading @@ -349,7 +353,7 @@ OUT @test "setting RUBY_MAKE_INSTALL_OPTS to a multi-word string" { cached_tarball "ruby-2.0.0" stub uname '-s : echo Linux' stub_repeated uname '-s : echo Linux' stub_make_install export RUBY_MAKE_INSTALL_OPTS="DOGE=\"such wow\"" Loading @@ -371,7 +375,7 @@ OUT @test "setting MAKE_INSTALL_OPTS to a multi-word string" { cached_tarball "ruby-2.0.0" stub uname '-s : echo Linux' stub_repeated uname '-s : echo Linux' stub_make_install export MAKE_INSTALL_OPTS="DOGE=\"such wow\"" Loading Loading @@ -402,7 +406,7 @@ OUT @test "make on FreeBSD defaults to gmake" { cached_tarball "ruby-2.0.0" stub uname "-s : echo FreeBSD" false stub_repeated uname "-s : echo FreeBSD" MAKE=gmake stub_make_install MAKE= install_fixture definitions/vanilla-ruby Loading @@ -421,7 +425,7 @@ apply -p1 -i /my/patch.diff exec ./configure "\$@" CONF stub uname '-s : echo Linux' stub_repeated uname '-s : echo Linux' stub apply 'echo apply "$@" >> build.log' stub_make_install Loading
test/compiler.bats +20 −10 Original line number Diff line number Diff line Loading @@ -8,9 +8,9 @@ export -n CC export -n RUBY_CONFIGURE_OPTS @test "require_gcc on OS X 10.9" { stub uname '-s : echo Darwin' stub_repeated uname '-s : echo Darwin' stub sw_vers '-productVersion : echo 10.9.5' stub gcc '--version : echo 4.2.1' '--version : echo 4.2.1' stub_repeated gcc '--version : echo 4.2.1' run_inline_definition <<DEF require_gcc Loading @@ -22,12 +22,16 @@ DEF CC=${TMP}/bin/gcc MACOSX_DEPLOYMENT_TARGET=no OUT unstub uname unstub sw_vers unstub gcc } @test "require_gcc on OS X 10.10" { stub uname '-s : echo Darwin' stub_repeated uname '-s : echo Darwin' stub sw_vers '-productVersion : echo 10.10' stub gcc '--version : echo 4.2.1' '--version : echo 4.2.1' stub_repeated gcc '--version : echo 4.2.1' run_inline_definition <<DEF require_gcc Loading @@ -39,6 +43,10 @@ DEF CC=${TMP}/bin/gcc MACOSX_DEPLOYMENT_TARGET=10.9 OUT unstub uname unstub sw_vers unstub gcc } @test "require_gcc silences warnings" { Loading @@ -55,13 +63,10 @@ DEF mkdir -p "$INSTALL_ROOT" cd "$INSTALL_ROOT" stub uname '-s : echo Darwin' '-s : echo Darwin' stub_repeated uname '-s : echo Darwin' stub sw_vers '-productVersion : echo 10.10' stub cc 'false' stub brew 'false' stub make \ 'echo make $@' \ 'echo make $@' stub_repeated brew 'false' stub_repeated make 'echo make $@' cat > ./configure <<CON #!${BASH} Loading @@ -83,4 +88,9 @@ CFLAGS=no make -j 2 make install OUT unstub uname unstub sw_vers unstub brew unstub make }
test/rbenv.bats +2 −1 Original line number Diff line number Diff line Loading @@ -77,7 +77,7 @@ OUT } @test "nonexistent version" { stub brew false stub_repeated brew false stub_ruby_build 'echo ERROR >&2 && exit 2' \ "--definitions : echo 1.8.7 1.9.3-p0 1.9.3-p194 2.1.2 | tr ' ' $'\\n'" Loading @@ -97,6 +97,7 @@ If the version you need is missing, try upgrading ruby-build: git -C ${BATS_TEST_DIRNAME}/.. pull OUT unstub brew unstub ruby-build } Loading
test/stubs/stub +6 −4 Original line number Diff line number Diff line #!/usr/bin/env bash set -e status=0 status=127 program="${0##*/}" PROGRAM="$(echo "$program" | tr a-z- A-Z_)" [ -n "$TMPDIR" ] || TMPDIR="/tmp" Loading @@ -9,6 +9,7 @@ PROGRAM="$(echo "$program" | tr a-z- A-Z_)" _STUB_PLAN="${PROGRAM}_STUB_PLAN" _STUB_RUN="${PROGRAM}_STUB_RUN" _STUB_INDEX="${PROGRAM}_STUB_INDEX" _STUB_NOINDEX="${PROGRAM}_STUB_NOINDEX" _STUB_RESULT="${PROGRAM}_STUB_RESULT" _STUB_END="${PROGRAM}_STUB_END" _STUB_DEBUG="${PROGRAM}_STUB_DEBUG" Loading @@ -32,7 +33,7 @@ index=0 while IFS= read -r line; do index=$(($index + 1)) if [ -z "${!_STUB_END}" ] && [ $index -eq "${!_STUB_INDEX}" ]; then if [[ -z "${!_STUB_END}" && -n "${!_STUB_NOINDEX}" || $index -eq "${!_STUB_INDEX}" ]]; then # We found the plan line we're interested in. # Start off by assuming success. result=0 Loading Loading @@ -72,7 +73,8 @@ while IFS= read -r line; do ( eval "$command" ) status="$?" set -e else [ -z "${!_STUB_NOINDEX}" ] || break elif [ -z "${!_STUB_NOINDEX}" ]; then eval "${_STUB_RESULT}"=1 fi fi Loading @@ -95,7 +97,7 @@ if [ -n "${!_STUB_END}" ]; then else # If the requested index is larger than the number # of lines in the plan file, we failed. if [ "${!_STUB_INDEX}" -gt $index ]; then if [[ -z "${!_STUB_NOINDEX}" && "${!_STUB_INDEX}" -gt $index ]]; then eval "${_STUB_RESULT}"=1 fi Loading
test/test_helper.bash +7 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,13 @@ stub() { for arg in "$@"; do printf "%s\n" "$arg" >> "${TMP}/${program}-stub-plan"; done } stub_repeated() { local program="$1" local prefix="$(echo "$program" | tr a-z- A-Z_)" export "${prefix}_STUB_NOINDEX"=1 stub "$@" } unstub() { local program="$1" local prefix="$(echo "$program" | tr a-z- A-Z_)" Loading