Skip to content
Myr

[Tests] make the fast suite pass on Alpine

Before adoption: this commit came in with the history the project adopted, so no landing records it.

`nvm_get_arch`: skip the smartos arm64/armv8l cases, which have no uname mock and fall through to the real host (adding a musl suffix on Alpine). `nvm_get_arch_unofficial`: skip the glibc chroot (fixed /lib64 loader, sudo); the musl mapping is already covered by the `nvm_get_arch alpine` test. `nvm_install_no_progress_bar`: skip below the musl floor, since v0.12.18 has no musl binary and hardcodes the glibc tarball URL.

authored by Jordan Harband · committed by Jordan Harband · parent f1e7a84 · Browse files · 3 files+30 added−9 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+30 added−9 removed

  • tests:+30 added−9 removed

3 files+30 added−9 removed

modified:test/fast/Unit tests/nvm_get_arch+7 added-2 removed
88 unmodified lines
8990run_test x86 osx x8691run_test amd64 osx x649293# These smartos cases have no arch-specific uname mock, so nvm_get_os falls94# through to the real host; on Alpine that host is linux and picks up the musl95# suffix, which these non-musl assertions do not expect. Skip them there.96if [ ! -f "/etc/alpine-release" ]; then93run_test arm64 smartos x6494run_test armv8l smartos x6497 run_test arm64 smartos x6498 run_test armv8l smartos x6499fi100101run_test loongarch64 linux loong64102103cleanup
modified:test/fast/Unit tests/nvm_get_arch_unofficial+15 added-7 removed
55 unmodified lines
56 # /dev/null57 sudo mknod "${chroot_dir}/dev/null" c 1 358}5960# The chroot fixtures assume a glibc layout (fixed dynamic-linker path under61# /lib64, coreutils binaries). On musl Alpine that setup does not apply, and62# nvm_get_arch's musl mapping is already covered by the "nvm_get_arch alpine"63# test, so skip the chroot checks there and still run the ls-remote checks.64if [ -f "/etc/alpine-release" ]; then65 echo "on Alpine; skipping chroot arch checks (covered by 'nvm_get_arch alpine')"66else60setup_chroot "${CHROOT_WITH_ALPINE}"61setup_chroot "${CHROOT_WITHOUT_ALPINE}"67 setup_chroot "${CHROOT_WITH_ALPINE}"68 setup_chroot "${CHROOT_WITHOUT_ALPINE}"6963# Run tests in chroot environments64ARCH_WITH_ALPINE=$(sudo chroot "${CHROOT_WITH_ALPINE}" /bin/sh -c ". ./nvm.sh && nvm_get_arch")65[ "${ARCH_WITH_ALPINE}" = "x64-musl" ] || die "Expected x64-musl for alpine environment but got ${ARCH_WITH_ALPINE}"70 # Run tests in chroot environments71 ARCH_WITH_ALPINE=$(sudo chroot "${CHROOT_WITH_ALPINE}" /bin/sh -c ". ./nvm.sh && nvm_get_arch")72 [ "${ARCH_WITH_ALPINE}" = "x64-musl" ] || die "Expected x64-musl for alpine environment but got ${ARCH_WITH_ALPINE}"7367ARCH_WITHOUT_ALPINE=$(sudo chroot "${CHROOT_WITHOUT_ALPINE}" /bin/sh -c ". ./nvm.sh && nvm_get_arch")68[ "${ARCH_WITHOUT_ALPINE}" != "x64-musl" ] || die "Did not expect x64-musl for non-alpine environment"74 ARCH_WITHOUT_ALPINE=$(sudo chroot "${CHROOT_WITHOUT_ALPINE}" /bin/sh -c ". ./nvm.sh && nvm_get_arch")75 [ "${ARCH_WITHOUT_ALPINE}" != "x64-musl" ] || die "Did not expect x64-musl for non-alpine environment"76fi7778# Run tests for nvm ls-remote79test_default_ls_remote() {80 mock_response='N/A'
24 unmodified lines
modified:test/fast/Unit tests/nvm_install_no_progress_bar+8 added
12 unmodified lines
1314: nvm.sh15\. ../../../nvm.sh1617# v0.12.18 predates musl binaries and the expected output hardcodes the glibc18# x64 tarball URL, so on Alpine nvm would request a nonexistent -musl build.19# The progress-bar behavior is not OS-specific, so skip below the musl floor.20if [ -f "/etc/alpine-release" ]; then21 echo 'on Alpine; skipping (v0.12.18 has no musl binary)'22 exit 023fi2425cleanup2627OUTPUT="$(TERM=dumb 2>&1 nvm install --no-progress v0.12.18)"28EXPECTED_OUTPUT="Downloading and installing node v0.12.18...
66 unmodified lines