Loading bin/ruby-build +12 −1 Original line number Diff line number Diff line Loading @@ -96,6 +96,17 @@ file_is_not_empty() { fi } num_cpu_cores() { local num="" if [ "Darwin" = "$(uname -s)" ]; then num="$(sysctl -n hw.ncpu 2>/dev/null || true)" elif [ -r /proc/cpuinfo ]; then num="$(grep -c ^processor /proc/cpuinfo)" [ "$num" -gt 0 ] || num="" fi echo "${num:-2}" } install_package() { install_package_using "tarball" 1 "$@" } Loading Loading @@ -374,7 +385,7 @@ build_package_standard() { if [ "${MAKEOPTS+defined}" ]; then MAKE_OPTS="$MAKEOPTS" elif [ -z "${MAKE_OPTS+defined}" ]; then MAKE_OPTS="-j 2" MAKE_OPTS="-j $(num_cpu_cores)" fi # Support YAML_CONFIGURE_OPTS, RUBY_CONFIGURE_OPTS, etc. Loading test/build.bats +46 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ load test_helper export RUBY_BUILD_CACHE_PATH="$TMP/cache" export MAKE=make export MAKE_OPTS="-j 2" setup() { mkdir -p "$INSTALL_ROOT" Loading Loading @@ -91,6 +92,51 @@ make -j 2 OUT } @test "number of CPU cores defaults to 2" { cached_tarball "ruby-2.0.0" stub uname '-s : echo Darwin' stub sysctl false stub_make_install export -n MAKE_OPTS run_inline_definition <<DEF install_package "ruby-2.0.0" "http://ruby-lang.org/ruby/2.0/ruby-2.0.0.tar.gz" DEF assert_success unstub uname unstub make assert_build_log <<OUT ruby-2.0.0: --prefix=$INSTALL_ROOT make -j 2 OUT } @test "number of CPU cores is detected on Mac" { cached_tarball "ruby-2.0.0" stub uname '-s : echo Darwin' stub sysctl '-n hw.ncpu : echo 4' stub_make_install export -n MAKE_OPTS run_inline_definition <<DEF install_package "ruby-2.0.0" "http://ruby-lang.org/ruby/2.0/ruby-2.0.0.tar.gz" DEF assert_success unstub uname unstub sysctl unstub make assert_build_log <<OUT ruby-2.0.0: --prefix=$INSTALL_ROOT make -j 4 OUT } @test "custom relative install destination" { export RUBY_BUILD_CACHE_PATH="$FIXTURE_ROOT" Loading Loading
bin/ruby-build +12 −1 Original line number Diff line number Diff line Loading @@ -96,6 +96,17 @@ file_is_not_empty() { fi } num_cpu_cores() { local num="" if [ "Darwin" = "$(uname -s)" ]; then num="$(sysctl -n hw.ncpu 2>/dev/null || true)" elif [ -r /proc/cpuinfo ]; then num="$(grep -c ^processor /proc/cpuinfo)" [ "$num" -gt 0 ] || num="" fi echo "${num:-2}" } install_package() { install_package_using "tarball" 1 "$@" } Loading Loading @@ -374,7 +385,7 @@ build_package_standard() { if [ "${MAKEOPTS+defined}" ]; then MAKE_OPTS="$MAKEOPTS" elif [ -z "${MAKE_OPTS+defined}" ]; then MAKE_OPTS="-j 2" MAKE_OPTS="-j $(num_cpu_cores)" fi # Support YAML_CONFIGURE_OPTS, RUBY_CONFIGURE_OPTS, etc. Loading
test/build.bats +46 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ load test_helper export RUBY_BUILD_CACHE_PATH="$TMP/cache" export MAKE=make export MAKE_OPTS="-j 2" setup() { mkdir -p "$INSTALL_ROOT" Loading Loading @@ -91,6 +92,51 @@ make -j 2 OUT } @test "number of CPU cores defaults to 2" { cached_tarball "ruby-2.0.0" stub uname '-s : echo Darwin' stub sysctl false stub_make_install export -n MAKE_OPTS run_inline_definition <<DEF install_package "ruby-2.0.0" "http://ruby-lang.org/ruby/2.0/ruby-2.0.0.tar.gz" DEF assert_success unstub uname unstub make assert_build_log <<OUT ruby-2.0.0: --prefix=$INSTALL_ROOT make -j 2 OUT } @test "number of CPU cores is detected on Mac" { cached_tarball "ruby-2.0.0" stub uname '-s : echo Darwin' stub sysctl '-n hw.ncpu : echo 4' stub_make_install export -n MAKE_OPTS run_inline_definition <<DEF install_package "ruby-2.0.0" "http://ruby-lang.org/ruby/2.0/ruby-2.0.0.tar.gz" DEF assert_success unstub uname unstub sysctl unstub make assert_build_log <<OUT ruby-2.0.0: --prefix=$INSTALL_ROOT make -j 4 OUT } @test "custom relative install destination" { export RUBY_BUILD_CACHE_PATH="$FIXTURE_ROOT" Loading