mirror of
https://github.com/nvm-sh/nvm.git
synced 2026-10-23 23:03:46 +08:00
urchin only executes test files that have the executable bit, silently skipping the rest, and `npm run test:check-exec` would catch non-executable ones, but no workflow ran it - so several test files have never actually run. Make all of them executable, and fix the ones that were broken: - the io.js source-install tests, skipped since 2016: io.js requires python 2 and gcc <= 5, so they now skip on toolchains that can not compile it, and a new gcc:4.9-container CI job runs them unmodified - resolving, downloading, checksumming, and compiling io.js for real. New `fake source` variants exercise nvm's source pipeline everywhere - cache lookup, offline resolution, extraction, configure, make, make install, activation - via a tiny fake source tree seeded into the download cache and installed with `--offline`. Also strengthen the `nvm run | grep` assertions with `--silent`, since the version banner used to satisfy the grep even when the built binary could not run, and give the final assertions the `die` they always meant to call. - `nvm uninstall ... incorrect file permissions fails nicely`, parked in 2025 as failing: `sudo npm` resets PATH, so node 5's npm crashed under the system node. The permissions check only trips on files that are neither writable nor self-owned, and that precondition only needs `sudo touch` - not npm, jspm, or the network - so use that, against a fake installed version, and skip only where passwordless sudo does not exist. - `nvm install --offline`: `nvm ls | tail -1` always grabbed an alias line, never a version; use `nvm_ls` and skip its trailing `system <version>` line. - `nvm exec ... help should not parse`: in a BRE, `[options]` is a bracket expression, so the grep could never match node's literal `Usage: node [options]` output. - `nvm use ... nvmrc containing not installed version`: current output once again matches its expectations verbatim; no changes needed. Rewrite `test:check-exec` in POSIX sh - npm runs scripts with /bin/sh, which is dash on Ubuntu, where the previous `[[`/`$'\n'` bashisms would break; match by extension, so that filenames containing dots can not dodge the check; and disable git's `core.quotePath` mangling of the non-ASCII test filenames. Then wire it into the lint workflow.
45 lines
1.7 KiB
Bash
Executable File
45 lines
1.7 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
\. ../common.sh
|
|
|
|
die () { echo "$@" ; exit 1; }
|
|
|
|
\. ../../nvm.sh
|
|
|
|
set -ex
|
|
|
|
NVM_TEST_VERSION='v3.99.9'
|
|
NVM_PREFIXED_TEST_VERSION="iojs-${NVM_TEST_VERSION}"
|
|
|
|
# Remove the stuff we're clobbering.
|
|
nvm uninstall "${NVM_TEST_VERSION}" || echo 'not installed'
|
|
|
|
# Exercise nvm's entire source-install pipeline - cache, extract, configure,
|
|
# make, make install, activation - against a tiny fake source tree, seeded
|
|
# into the download cache and installed with --offline. This runs everywhere,
|
|
# including on toolchains where real io.js can not compile; `install from
|
|
# source` covers the real compile, in CI's gcc:4.9 container job.
|
|
SLUG="$(nvm_get_download_slug iojs source "${NVM_TEST_VERSION}")"
|
|
COMPRESSION="$(nvm_get_artifact_compression "${NVM_TEST_VERSION}")"
|
|
CACHE_DIR="$(nvm_cache_dir)/src/${SLUG}"
|
|
STAGING="$(mktemp -d)"
|
|
mkdir -p "${STAGING}/${SLUG}" "${CACHE_DIR}"
|
|
cp ../fixtures/fake-source-tarball/configure ../fixtures/fake-source-tarball/Makefile "${STAGING}/${SLUG}/"
|
|
chmod +x "${STAGING}/${SLUG}/configure"
|
|
echo "${NVM_TEST_VERSION}" > "${STAGING}/${SLUG}/VERSION"
|
|
if [ "${COMPRESSION}" = 'tar.xz' ]; then
|
|
(cd "${STAGING}" && tar -cJf "${CACHE_DIR}/${SLUG}.${COMPRESSION}" "${SLUG}")
|
|
else
|
|
(cd "${STAGING}" && tar -czf "${CACHE_DIR}/${SLUG}.${COMPRESSION}" "${SLUG}")
|
|
fi
|
|
rm -rf "${STAGING}"
|
|
|
|
# Install from source
|
|
nvm install -s --offline "${NVM_PREFIXED_TEST_VERSION}" || die "'nvm install -s --offline ${NVM_PREFIXED_TEST_VERSION}' failed"
|
|
|
|
# Check
|
|
nvm_is_version_installed "${NVM_PREFIXED_TEST_VERSION}" || die 'version not installed'
|
|
nvm run --silent "${NVM_PREFIXED_TEST_VERSION}" --version | grep "${NVM_TEST_VERSION}" || die "'nvm run ${NVM_PREFIXED_TEST_VERSION} --version | grep ${NVM_TEST_VERSION}' failed"
|
|
|
|
rm -rf "${CACHE_DIR}"
|