Skip to content

Commit

Permalink
Merge pull request #916 from nodenv/pull-ruby-build
Browse files Browse the repository at this point in the history
pull ruby build
  • Loading branch information
jasonkarns authored Jun 3, 2024
2 parents 78662a5 + 63000bd commit c7e0e9e
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 123 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ brew install node-build

Upgrade with:
```sh
brew update && brew upgrade node-build
brew upgrade node-build
```

### Clone as nodenv plugin using git
Expand Down
2 changes: 1 addition & 1 deletion bin/nodenv-install
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ if [ "$STATUS" == "2" ]; then
echo -n "If the version you need is missing, try upgrading node-build"
if [ "$here" != "${here#$(brew --prefix 2>/dev/null)}" ]; then
printf ":\\n\\n"
echo " brew update && brew upgrade node-build"
echo " brew upgrade node-build"
elif [ -d "${here}/.git" ]; then
printf ":\\n\\n"
echo " git -C ${here} pull"
Expand Down
14 changes: 7 additions & 7 deletions test/build.bats
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ assert_build_log() {
@test "apply node patch before building" {
cached_tarball "node-v4.0.0"

stub brew false
stub_make_install
stub patch ' : echo patch "$@" | sed -E "s/\.[[:alnum:]]+$/.XXX/" >> build.log'

Expand All @@ -85,7 +84,6 @@ OUT
@test "striplevel node patch before building" {
cached_tarball "node-v4.0.0"

stub brew false
stub_make_install
stub patch ' : echo patch "$@" | sed -E "s/\.[[:alnum:]]+$/.XXX/" >> build.log'

Expand All @@ -110,7 +108,6 @@ OUT
@test "apply node patch from git diff before building" {
cached_tarball "node-v4.0.0"

stub brew false
stub_make_install
stub patch ' : echo patch "$@" | sed -E "s/\.[[:alnum:]]+$/.XXX/" >> build.log'

Expand All @@ -136,7 +133,7 @@ OUT
@test "number of CPU cores defaults to 2" {
cached_tarball "node-v4.0.0"

stub uname '-s : echo Darwin'
stub_repeated uname '-s : echo Darwin'
stub sysctl false
stub_make_install

Expand All @@ -159,7 +156,7 @@ OUT
@test "number of CPU cores is detected on Mac" {
cached_tarball "node-v4.0.0"

stub uname '-s : echo Darwin'
stub_repeated uname '-s : echo Darwin'
stub sysctl '-n hw.ncpu : echo 4'
stub_make_install

Expand All @@ -183,7 +180,7 @@ OUT
@test "number of CPU cores is detected on FreeBSD" {
cached_tarball "node-v4.0.0"

stub uname '-s : echo FreeBSD'
stub_repeated uname '-s : echo FreeBSD'
stub sysctl '-n hw.ncpu : echo 1'
stub_make_install

Expand All @@ -207,6 +204,7 @@ OUT
@test "setting NODE_MAKE_INSTALL_OPTS to a multi-word string" {
cached_tarball "node-v4.0.0"

stub_repeated uname '-s : echo Linux'
stub_make_install

export NODE_MAKE_INSTALL_OPTS="DOGE=\"such wow\""
Expand All @@ -227,6 +225,7 @@ OUT
@test "setting MAKE_INSTALL_OPTS to a multi-word string" {
cached_tarball "node-v4.0.0"

stub_repeated uname '-s : echo Linux'
stub_make_install

export MAKE_INSTALL_OPTS="DOGE=\"such wow\""
Expand Down Expand Up @@ -256,7 +255,7 @@ OUT
@test "make on FreeBSD defaults to gmake" {
cached_tarball "node-v4.0.0"

stub uname "-s : echo FreeBSD"
stub_repeated uname "-s : echo FreeBSD"
MAKE=gmake stub_make_install

MAKE= install_fixture definitions/vanilla-node
Expand All @@ -275,6 +274,7 @@ apply -p1 -i /my/patch.diff
exec ./configure "\$@"
CONF

stub_repeated uname '-s : echo Linux'
stub apply 'echo apply "$@" >> build.log'
stub_make_install

Expand Down
8 changes: 5 additions & 3 deletions test/compiler.bats
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ export -n NODE_CONFIGURE_OPTS
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 $@'
Expand All @@ -40,4 +38,8 @@ CFLAGS=no
make -j 2
make install
OUT

unstub uname
unstub sw_vers
unstub make
}
5 changes: 3 additions & 2 deletions test/nodenv.bats
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ OUT
}

@test "nonexistent version" {
stub brew false
stub_repeated brew false
stub_node_build 'echo ERROR >&2 && exit 2' \
"--definitions : echo 0.8.7 0.10.4 0.10.6 1.0.0 4.1.2 | tr ' ' $'\\n'"

Expand All @@ -102,6 +102,7 @@ If the version you need is missing, try upgrading node-build:
git -C ${BATS_TEST_DIRNAME}/.. pull
OUT

unstub brew
unstub node-build
}

Expand All @@ -119,7 +120,7 @@ See all available versions with \`nodenv install --list'.
If the version you need is missing, try upgrading node-build:
brew update && brew upgrade node-build
brew upgrade node-build
OUT

unstub brew
Expand Down
109 changes: 0 additions & 109 deletions test/stubs/stub

This file was deleted.

8 changes: 8 additions & 0 deletions test/test_helper.bash
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ teardown() {
rm -fr "${BATS_TMPDIR:?}"/*
}

stub_repeated() {
local program="$1"
# shellcheck disable=SC2155
local prefix="$(echo "$program" | tr a-z- A-Z_)"
export "${prefix}_STUB_NOINDEX"=1
stub "$@"
}

run_inline_definition() {
local definition="${BATS_TMPDIR}/build-definition"
cat > "$definition"
Expand Down

0 comments on commit c7e0e9e

Please sign in to comment.