+
Skip to content

Fast track exact auto #813

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions bin/n
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,16 @@ function get_auto_version() {
function get_latest_resolved_version() {
g_target_node=
local version=${1}

# Transform some labels before processing further to allow fast-track for exact numeric versions.
if [[ "${version}" = "auto" ]]; then
get_auto_version || return 2
version="${g_target_node}"
elif [[ "${version}" = "engine" ]]; then
get_engine_version || return 2
version="${g_target_node}"
fi

simple_version=${version#node/} # Only place supporting node/ [sic]
if is_exact_numeric_version "${simple_version}"; then
# Just numbers, already resolved, no need to lookup first.
Expand Down Expand Up @@ -1259,11 +1269,9 @@ function display_local_versions() {
version="$(display_latest_node_support_alias "${version}")"
match_count=1
elif [[ "${version}" = "auto" ]]; then
# suppress stdout logging so lsr layout same as usual for scripting
get_auto_version || return 2
version="${g_target_node}"
elif [[ "${version}" = "engine" ]]; then
# suppress stdout logging so lsr layout same as usual for scripting
get_engine_version || return 2
version="${g_target_node}"
fi
Expand Down Expand Up @@ -1310,11 +1318,9 @@ function display_remote_versions() {
version="$(display_latest_node_support_alias "${version}")"
match_count=1
elif [[ "${version}" = "auto" ]]; then
# suppress stdout logging so lsr layout same as usual for scripting
get_auto_version || return 2
version="${g_target_node}"
elif [[ "${version}" = "engine" ]]; then
# suppress stdout logging so lsr layout same as usual for scripting
get_engine_version || return 2
version="${g_target_node}"
fi
Expand Down
2 changes: 1 addition & 1 deletion test/bin/run-all-tests
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services=( fedora-curl ubuntu-wget )
cd "$(dirname "${BIN_DIRECTORY}")" || exit 2
for service in "${services[@]}" ; do
echo "${service}"
docker-compose run --rm "${service}" "bats" "/mnt/test/tests"
docker compose run --rm "${service}" "bats" "/mnt/test/tests"
echo ""
done

Expand Down
1 change: 0 additions & 1 deletion test/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '2'
services:
ubuntu-curl:
extends:
Expand Down
10 changes: 5 additions & 5 deletions test/tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,25 @@ Run all the tests on a single system:

cd test
npx bats tests
docker-compose run ubuntu-curl bats /mnt/test/tests
docker compose run ubuntu-curl bats /mnt/test/tests

Run single test on a single system::

cd test
npx bats tests/install-contents.bats
docker-compose run ubuntu-curl bats /mnt/test/tests/install-contents.bats
docker compose run ubuntu-curl bats /mnt/test/tests/install-contents.bats

## Docker Tips

Using `docker-compose` in addition to `docker` for convenient mounting of `n` script and the tests into the container. Changes to the tests or to `n` itself are reflected immediately without needing to rebuild the containers.
Using `docker compose` in addition to `docker` for convenient mounting of `n` script and the tests into the container. Changes to the tests or to `n` itself are reflected immediately without needing to rebuild the containers.

`bats` is being mounted directly out of `node_modules` into the container as a manual install based on its own install script. This is a bit of a hack, but avoids needing to install `git` or `npm` for a full remote install of `bats`, and means everything on the same version of `bats`.

The containers each have:

* either curl or wget (or both) installed

Using `docker-compose` to run the container adds:
Using `docker compose` to run the container adds:

* specified `n` script mounted to `/usr/local/bin/n`
* `test/tests` mounted to `/mnt/test/tests`
Expand All @@ -48,7 +48,7 @@ Using `docker-compose` to run the container adds:
So for example:

cd test
docker-compose run ubuntu-curl
docker compose run ubuntu-curl
# in container
n --version
bats /mnt/test/tests
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载