Six fast tests failed outside of CI's setup, which runs them as a non-root user with `sudo` and a terminal. `nvm_download_artifact error propagation` expected `mkdir -p` under `/nonexistent` to fail, which root can create; it now uses a path under a regular file, which nobody can create. `nvm_get_arch_unofficial` now only uses `sudo` when it is not already root, and skips the chroot checks when it can do neither. `nvm_write_nvmrc`'s permissions check and the `nvm uninstall` permissions test are skipped as root, since root ignores file permissions. `nvm_stdout_is_terminal`'s `/dev/tty` checks are skipped when there is no controlling terminal, as in `docker run` without `-t`. `nvm_process_nvmrc` now fails with a clear message when the `test/fixtures/nvmrc` submodule is not checked out, instead of on an unexpanded glob. This is not a vulnerability fix.
37 lines
1.3 KiB
Bash
Executable File
37 lines
1.3 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
die () { echo "$@" ; cleanup ; exit 1; }
|
|
|
|
cleanup() {
|
|
echo 'cleaned up'
|
|
}
|
|
|
|
: nvm.sh
|
|
\. ../../../nvm.sh
|
|
|
|
\. ../../common.sh
|
|
|
|
[ -d ../../../test/fixtures/nvmrc/test/fixtures/valid ] || die 'the `test/fixtures/nvmrc` submodule is not checked out; run `git submodule update --init`'
|
|
|
|
for f in ../../../test/fixtures/nvmrc/test/fixtures/valid/*; do
|
|
try nvm_process_nvmrc "${f}/.nvmrc"
|
|
|
|
EXPECTED="$(nvm_json_extract node < "${f}/expected.json" | tr -d '"')"
|
|
|
|
[ "${CAPTURED_EXIT_CODE}" = "0" ] || die "$(basename "${f}"): expected exit code of 0 but got ${CAPTURED_EXIT_CODE}"
|
|
|
|
[ "${CAPTURED_STDOUT}" = "${EXPECTED}" ] || die "$(basename "${f}"): expected STDOUT of \`${EXPECTED}\` but got \`${CAPTURED_STDOUT}\`"
|
|
done
|
|
|
|
for f in ../../../test/fixtures/nvmrc/test/fixtures/invalid/*; do
|
|
try nvm_process_nvmrc "${f}/.nvmrc"
|
|
try_err nvm_process_nvmrc "${f}/.nvmrc"
|
|
STDERR="$(echo "$CAPTURED_STDERR" | awk '{if(NR > 8) print $0}' | strip_colors)"
|
|
|
|
EXPECTED="$(nvm_json_extract < "${f}/expected.json" | tr -d '"')"
|
|
|
|
[ "${CAPTURED_EXIT_CODE}" != "0" ] || die "$(basename "${f}"): expected exit code of 'not 0' but got ${CAPTURED_EXIT_CODE}"
|
|
|
|
[ "${STDERR}" = "${EXPECTED}" ] || die "$(basename "${f}"): expected STDERR of \`${EXPECTED}\` but got \`${STDERR}\`"
|
|
done
|