Skip to content
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

Isolation of end-to-end tests #2047

Merged
merged 57 commits into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
0852648
removed unused option on node plugin
jdx Jul 9, 2023
574bfd6
chore: release 2024.4.2 (#1872)
mise-en-dev Apr 9, 2024
b5d4e75
chore(deps): update amannn/action-semantic-pull-request action to v5.…
renovate[bot] Apr 24, 2024
48a486c
test: refactor the end-to-end test runner scripts.
Adirelle May 10, 2024
782bf56
test: remove the fixtures files.
Adirelle May 10, 2024
3597843
test: fix/refactor a first batch of e2e tests.
Adirelle May 10, 2024
26ed8dd
test: slightly improve the output of the end-to-end tests.
Adirelle May 10, 2024
3987294
test: enable MISE_EXPERIMENTAL for all test by default.
Adirelle May 10, 2024
0efbb9d
test: simplify assert.sh and add an explicit "skip_slow_test" function
Adirelle May 10, 2024
ffffd44
test: prevent tests from being ran without the run_test wrapper.
Adirelle May 10, 2024
63dc071
test: remove useless cleanup.
Adirelle May 10, 2024
afbc7f0
test: tweak group and notice output messages.
Adirelle May 10, 2024
70515f6
test: fix another batch of tests.
Adirelle May 10, 2024
f7868b5
test: use default configuration filenames in end-to-end tests.
Adirelle May 10, 2024
210690b
test: dispatch e2e tests in subdirectories.
Adirelle May 10, 2024
1943b52
test: run all e2e as sourced bash scripts.
Adirelle May 10, 2024
39c452e
test: tweak python tests.
Adirelle May 10, 2024
1e8a1a4
test: add the path of the test script in GA annotations.
Adirelle May 10, 2024
ddbde0f
test: fix how the test:e2e task finds the tests to execute.
Adirelle May 10, 2024
cfa59b1
test: reorganize the tests to mimic the src/ tree.
Adirelle May 11, 2024
acabb11
test: moved NPM_CONFIG_FUND setting into npm/node tests.
Adirelle May 11, 2024
e5f71b4
test: MISE_ALWAYS_KEEP_DOWNLOAD is useless with one-shot test environ…
Adirelle May 11, 2024
c062e96
test: pass the GITHUB_API_TOKEN variable along.
Adirelle May 11, 2024
776504a
test: fix weird quotes in assert.sh.
Adirelle May 11, 2024
b12ee83
test: renamed MISE_TEST_* variables to TEST_*.
Adirelle May 11, 2024
bb3a92e
test: improve GA annotations (again).
Adirelle May 11, 2024
0f8f01e
test: fix GA annotation parameters.
Adirelle May 11, 2024
12c9fcf
test: skip slow test in run_all_tests.
Adirelle May 11, 2024
9dcc2b5
test: (hopefully) the last change to test annotations;
Adirelle May 11, 2024
236a75f
test: refactor (and fix) most cli E2E tests.
Adirelle May 11, 2024
4253072
test: fix npm, pipx and ubi e2e tests by adding the required tools in…
Adirelle May 11, 2024
b0250e7
test: fixed link and system_node e2e tests.
Adirelle May 11, 2024
8924774
test: remove the old, now unused e2e fixtures.
Adirelle May 11, 2024
4170e7d
test: reworked the direnv e2e test (I guess).
Adirelle May 11, 2024
285c714
test: have the task test:e2e outputs an error when it finds no test.
Adirelle May 11, 2024
b92ffe3
test: display skipped slow tests in the summary.
Adirelle May 11, 2024
abca8ab
test: keep test ordering in e2e tranches.
Adirelle May 11, 2024
7907f83
test: fix handling of required commands.
Adirelle May 11, 2024
e45f520
test: fix require_cmd error message.
Adirelle May 12, 2024
64f0a4f
chore: add and use a docker:run task.
Adirelle May 12, 2024
42619b6
chore: pass any github token as an argument when buliding the dev image.
Adirelle May 12, 2024
d9c818a
test: define CARGO_HOME and RUSTUP_HOME in the test environment.
Adirelle May 12, 2024
5b844ac
test: moved back ubi installation in its e2e test.
Adirelle May 12, 2024
9f94527
test: fixed the slow tests.
Adirelle May 12, 2024
ecd59f2
test: temporarily run all tests.
Adirelle May 12, 2024
de9ab35
test: changed the way tests are spread accros test tranches in run_al…
Adirelle May 12, 2024
a318ba6
test: added an e2e test for poetry using python from the system.
Adirelle May 12, 2024
b8c9e7d
test: fix an error in run_all_tests.
Adirelle May 12, 2024
bd8ee21
test: also prevent bash from reading rc files in tests.
Adirelle May 12, 2024
aa58b1a
test: install all build and test dependencies for the e2e tests.
Adirelle May 12, 2024
af9fc6b
text: fix bash tests.
Adirelle May 12, 2024
a92a8c7
test: hopefully fix neovim build.
Adirelle May 12, 2024
4da7405
test: fix coverage recording from e2e tests.
Adirelle May 12, 2024
db48f54
test: disable slow tests in PRs.
Adirelle May 12, 2024
fa2a585
test: fix code coverage reporting.
Adirelle May 12, 2024
a431226
test: fix an HEREDOC delimiter.
Adirelle May 12, 2024
f043512
test: remove the neovim plugin test since it is already tested in a d…
Adirelle May 12, 2024
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
16 changes: 13 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
components: rustfmt
- uses: taiki-e/install-action@v2
with:
tool: nextest,just,cargo-deny,cargo-msrv,cargo-machete,usage-cli
tool: nextest,cargo-deny,cargo-msrv,cargo-machete,usage-cli
- name: Install direnv
run: sudo apt-get update; sudo apt-get install direnv
- run: cargo nextest run --all-features
Expand Down Expand Up @@ -81,7 +81,17 @@ jobs:
with:
shared-key: coverage
save-if: ${{ github.ref_name == 'main' }}
- run: sudo apt-get update; sudo apt-get install zsh fish direnv
- name: Install build and test dependencies
run: |
sudo apt-get update && sudo apt-get install \
bison \
build-essential \
direnv \
fd-find \
fish \
pipx \
python3-venv \
zsh
- uses: taiki-e/install-action@v2
with:
tool: cargo-llvm-cov,mise,usage-cli
Expand All @@ -104,4 +114,4 @@ jobs:
continue-on-error: true
with:
project-token: cb3da7e860bf4e31a50e733aefa8d347
coverage-reports: lcov.info
coverage-reports: lcov0.info,lcov1.info,lcov2.info,lcov3.info
10 changes: 7 additions & 3 deletions .mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,16 @@ depends = ["build"]

[tasks."docker:image"]
description = "build docker image from Dockerfile"
run = 'docker build $root -f $root/packaging/dev/Dockerfile -t ghcr.io/jdx/mise:dev'
run = 'docker build --build-arg GITHUB_TOKEN=$GITHUB_API_TOKEN $root -f $root/packaging/dev/Dockerfile -t ghcr.io/jdx/mise:dev'

[tasks."docker:run"]
description = "run a command inside of development docker container"
run = 'docker run -ti --rm -e GITHUB_API_TOKEN -e TEST_ALL -v $root:/mise -v /tmp/mise/target:/tmp/mise/target -v /tmp/mise/registry:/tmp/mise/registry -w /mise ghcr.io/jdx/mise:dev'
depends = ["docker:image"]

[tasks."docker:cargo"]
description = "run cargo inside of development docker container"
run = 'docker run -ti --rm -e GITHUB_API_TOKEN -v $root:/mise -v /tmp/mise/target:/tmp/mise/target -v /tmp/mise/registry:/tmp/mise/registry -w /mise ghcr.io/jdx/mise:dev cargo'
depends = ["docker:image"]
run = 'mise tasks run docker:run cargo'

[tasks."docker:mise"]
description = "run mise inside of development docker container"
Expand Down
2 changes: 1 addition & 1 deletion .mise/tasks/test/coverage
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ elif [[ "${TEST_TRANCHE:-}" == 1 ]]; then
mise self-update -fy "$y.$m.0"
fi
echo "::group::Render lcov report"
cargo llvm-cov report --lcov --output-path lcov.info
cargo llvm-cov report --lcov --output-path "lcov${TEST_TRANCHE:-}.info"
6 changes: 5 additions & 1 deletion .mise/tasks/test/e2e
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ export RUST_TEST_THREADS=1
if [[ "${1:-all}" == all ]]; then
./e2e/run_all_tests
else
FILES="$(fd "$1" e2e/)"
FILES="$(find e2e -name "test_*$1*" -type f -printf "%P\n")"
if [[ -z $FILES ]]; then
echo "Not test matches $1" >&2
exit 1
fi
for FILE in $FILES; do
./e2e/run_test "$FILE"
done
Expand Down
11 changes: 9 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ lto = true
[dependencies]
base64 = "0.22.1"
calm_io = "0.1.1"
chrono = { version = "0.4.38", default-features = false, features = ["std", "clock"] }
chrono = { version = "0.4.38", default-features = false, features = [
"std",
"clock",
] }
ci_info = "0.14.14"
clap = { version = "4.5.4", features = ["env", "derive", "string"] }
clap_mangen = { version = "0.2.20", optional = true }
Expand Down Expand Up @@ -77,7 +80,11 @@ petgraph = "0.6.4"
rand = "0.8.5"
rayon = "1.10.0"
regex = "1.10.4"
reqwest = { version = "<0.12", default-features = false, features = ["blocking", "json", "gzip"] }
reqwest = { version = "<0.12", default-features = false, features = [
"blocking",
"json",
"gzip",
] }
rmp-serde = "1.3.0"
# TODO: fix issue with rustls and "No signature verification implemented for Plain(None) files"
self_update = { version = "<0.40.0", default-features = false, features = [
Expand Down
1 change: 0 additions & 1 deletion e2e/.alternate-tool-versions

This file was deleted.

1 change: 0 additions & 1 deletion e2e/.default-npm-packages

This file was deleted.

1 change: 0 additions & 1 deletion e2e/.default-python-packages

This file was deleted.

4 changes: 0 additions & 4 deletions e2e/.e2e-tool-versions

This file was deleted.

4 changes: 0 additions & 4 deletions e2e/.mise/tasks/build

This file was deleted.

1 change: 0 additions & 1 deletion e2e/.node-version

This file was deleted.

1 change: 0 additions & 1 deletion e2e/.test-env

This file was deleted.

1 change: 0 additions & 1 deletion e2e/.test-env2

This file was deleted.

93 changes: 70 additions & 23 deletions e2e/assert.sh
Original file line number Diff line number Diff line change
@@ -1,44 +1,91 @@
#!/usr/bin/env bash
# shellcheck shell=bash

# shellcheck source-path=SCRIPTDIR
source "$TEST_ROOT/style.sh"

fail() {
title="E2E assertion failed" err "$*"
exit 1
}

# Safeguard against running the test directly, which would execute in the actual user home
[[ -n "${TEST_NAME:-}" ]] || fail "tests should be called using run_test"

quiet_assert_succeed() {
local status=0
bash -c "$1" || status=$?
if [[ $status -ne 0 ]]; then
fail "[$1] command failed with status $status"
fi
}

assert_succeed() {
if quiet_assert_succeed "$1"; then
ok "[$1] expected success"
fi
}

assert_fail() {
if ! bash -c "$1" 2>&1; then
ok "[$1] expected failure"
else
fail "[$1] expected failure but succeeded"
fi
}

assert() {
local actual
actual="$(bash -c "$1")"
if [[ "$actual" != "$2" ]]; then
echo "Expected '$2' but got '$actual'"
exit 1
actual="$(quiet_assert_succeed "$1")"
if [[ $actual == "$2" ]]; then
ok "[$1] output is equal to '$2'"
else
fail "[$1] expected '$2' but got '$actual'"
fi
}

assert_contains() {
assert_not() {
local actual
actual="$(bash -c "$1")"
if [[ "$actual" != *"$2"* ]]; then
echo "Expected '$2' to be in '$actual'"
exit 1
actual="$(bash -c "$1" || true)"
if [[ $actual != "$2" ]]; then
ok "[$1] output is different from '$2'"
else
fail "[$1] expected '$2' not to be in '$actual'"
fi
}

assert_not_contains() {
assert_contains() {
local actual
actual="$(bash -c "$1")"
if [[ "$actual" == *"$2"* ]]; then
echo "Expected '$2' to not be in '$actual'"
exit 1
actual="$(quiet_assert_succeed "$1")"
if [[ $actual == *"$2"* ]]; then
ok "[$1] '$2' is in output"
else
fail "[$1] expected '$2' to be in '$actual'"
fi
}

assert_fail() {
if bash -c "$1" 2>&1; then
echo "Expected failure but succeeded"
exit 1
assert_not_contains() {
local actual
actual="$(quiet_assert_succeed "$1")"
if [[ $actual != *"$2"* ]]; then
ok "[$1] '$2' is not in output"
else
fail "[$1] expected '$2' not to be in '$actual'"
fi
}

assert_matches() {
local actual
actual="$(bash -c "$1")"
if [[ ! "$actual" =~ $2 ]]; then
echo "Expected '$2' to match '$actual'"
exit 1
actual="$(quiet_assert_succeed "$1")"
if [[ $actual =~ $2 ]]; then
ok "[$1] '$2' matches output"
else
fail "[$1] expected '$2' to match '$actual'"
fi
}

require_cmd() {
if ! type -p "$1" >/dev/null; then
title="E2E test $TEST_NAME aborted" err "'$1' is required but was not found in PATH"
exit 2
fi
}
1 change: 0 additions & 1 deletion e2e/cd/.e2e-tool-versions

This file was deleted.

1 change: 0 additions & 1 deletion e2e/cd/18/.e2e-tool-versions

This file was deleted.

65 changes: 0 additions & 65 deletions e2e/cd/test_bash

This file was deleted.

17 changes: 0 additions & 17 deletions e2e/cd/test_bash_legacy_activate

This file was deleted.

24 changes: 0 additions & 24 deletions e2e/cd/test_fish

This file was deleted.

5 changes: 5 additions & 0 deletions e2e/cli/test_activate_path_safety
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# shellcheck shell=bash

eval "$(mise activate bash)" && eval "$(mise hook-env)"
install -m 0755 /dev/null "$TMPDIR/MISE_PATH_SAFETY_CHECK"
assert_fail "cd '$TMPDIR' && command -v MISE_PATH_SAFETY_CHECK"
6 changes: 6 additions & 0 deletions e2e/cli/test_doctor
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# shellcheck shell=bash

mise use dummy@latest

eval "$(mise activate bash)" && _mise_hook
mise doctor
12 changes: 12 additions & 0 deletions e2e/cli/test_env_file
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# shellcheck shell=bash

cat <<'EOF' >.mise.toml
[env]
mise.file = ['.test-env']
EOF

echo FOO_FROM_FILE=foo_from_file >.test-env
echo TEST_ENV2=foo >.test-env2

assert "mise x -- env | grep FOO_FROM_FILE" "FOO_FROM_FILE=foo_from_file"
assert "MISE_ENV_FILE=.test-env2 mise x -- env | grep TEST_ENV2" "TEST_ENV2=foo"
7 changes: 2 additions & 5 deletions e2e/test_env_file_glob → e2e/cli/test_env_file_glob
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#!/usr/bin/env bash
set -euo pipefail
# shellcheck source-path=SCRIPTDIR
source "$(dirname "$0")/assert.sh"
# shellcheck shell=bash

cat >.e2e.mise.toml <<EOF
cat <<'EOF' >.mise.toml
[env]
_.file = "env.d/*.env"
EOF
Expand Down
9 changes: 9 additions & 0 deletions e2e/cli/test_env_json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# shellcheck shell=bash
require_cmd jq

cat >.mise.toml <<EOF
[env]
FOO = "bar"
EOF

assert "mise env --json dummy@latest | jq -r .FOO" "bar"
Loading
Loading