Skip to content

Commit

Permalink
test: make unit tests work shuffled
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed May 18, 2024
1 parent 2b130cb commit 462db17
Show file tree
Hide file tree
Showing 66 changed files with 2,209 additions and 118 deletions.
19 changes: 11 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
MISE_TRUSTED_CONFIG_PATHS: ${{ github.workspace }}
MISE_EXPERIMENTAL: 1
RUST_BACKTRACE: 1

permissions:
pull-requests: write
Expand All @@ -39,34 +41,35 @@ jobs:
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 build --all-features
echo "$PWD/target/debug" >> "$GITHUB_PATH"
- run: cargo nextest run --all-features
env:
RUST_BACKTRACE: "1"
- run: mise run test:shuffle
- run: cargo deny check
- run: cargo msrv verify
- run: cargo machete --with-metadata
- run: ./scripts/test-standalone.sh
- run: cargo build --all-features
- run: ./target/debug/mise settings set experimental true
- run: mise settings set experimental true
- uses: actions/cache@v4
with:
path: |
~/.local/share/mise/installs
~/.local/share/mise/plugins
key: mise-tools-${{ hashFiles('.mise.toml') }}
restore-keys: mise-tools
- run: ./target/debug/mise install
- run: ./target/debug/mise run render
- run: mise install
- run: mise run render
- if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'jdx/mise'
run: ./target/debug/mise run lint-fix && git diff HEAD
run: mise run lint-fix && git diff HEAD
- if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'jdx/mise'
uses: EndBug/add-and-commit@v9
with:
push: true
author_name: mise[bot]
author_email: 123107610+mise-en-dev@users.noreply.github.com
- uses: actions-rust-lang/rustfmt@v1
- run: ./target/debug/mise run lint
- run: mise run lint

coverage:
name: coverage-${{matrix.tranche}}
Expand Down
3 changes: 3 additions & 0 deletions .mise.local.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ tasks.c1 = { run = "echo c1 && sleep 0.5 && echo", depends = ["b1"], hide = true

[env]
FOO=".mise.local.toml"

[tasks."test:shuffle"]
run = "cargo +nightly test --all-features -- -Z unstable-options --shuffle"
115 changes: 108 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 18 additions & 17 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ license = "MIT"
keywords = ["mise"]
categories = ["command-line-utilities"]
include = [
"src/**/*.rs",
"src/plugins/core/assets/**",
"src/assets/**",
"/completions/*",
"/Cargo.lock",
"/LICENSE",
"/README.md",
"/build.rs",
"/zipsign.pub",
"src/**/*.rs",
"src/plugins/core/assets/**",
"src/assets/**",
"/completions/*",
"/Cargo.lock",
"/LICENSE",
"/README.md",
"/build.rs",
"/zipsign.pub",
]
rust-version = "1.76.0"
build = "build.rs"
Expand All @@ -43,8 +43,8 @@ lto = true
base64 = "0.22.1"
calm_io = "0.1.1"
chrono = { version = "0.4.38", default-features = false, features = [
"std",
"clock",
"std",
"clock",
] }
ci_info = "0.14.14"
clap = { version = "4.5.4", features = ["env", "derive", "string"] }
Expand Down Expand Up @@ -87,16 +87,16 @@ regex = "1.10.4"
# mise error sending request for url (https://api.github.com/repos/jdx/mise/releases): error trying to connect: invalid URL, scheme is not http
# mise error trying to connect: invalid URL, scheme is not http
reqwest = { version = "<0.12", default-features = false, features = [
"blocking",
"json",
"gzip",
"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 = [
"archive-tar",
"compression-flate2",
"signatures",
"archive-tar",
"compression-flate2",
"signatures",
] }
serde = "1.0.199"
serde_derive = "1.0.199"
Expand Down Expand Up @@ -137,6 +137,7 @@ insta = { version = "1.38.0", features = ["filters", "json"] }
predicates = "3.1.0"
pretty_assertions = "1.4.0"
test-case = "3.3.1"
test-log = "0.2"

[features]
default = ["native-tls"]
Expand Down
6 changes: 4 additions & 2 deletions src/cli/alias/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ static AFTER_LONG_HELP: &str = color_print::cstr!(

#[cfg(test)]
mod tests {
use crate::test::reset_config;
use crate::test::reset;

#[test]
fn test_alias_get() {
reset_config();
reset();
let stdout = assert_cli!("alias", "get", "tiny", "my/alias");
assert_snapshot!(stdout, @r###"
3.0
Expand All @@ -54,12 +54,14 @@ mod tests {

#[test]
fn test_alias_get_plugin_unknown() {
reset();
let err = assert_cli_err!("alias", "get", "unknown", "unknown");
assert_snapshot!(err, @"Unknown plugin: unknown");
}

#[test]
fn test_alias_get_alias_unknown() {
reset();
let err = assert_cli_err!("alias", "get", "tiny", "unknown");
assert_snapshot!(err, @"Unknown alias: unknown");
}
Expand Down
5 changes: 5 additions & 0 deletions src/cli/alias/ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,12 @@ static AFTER_LONG_HELP: &str = color_print::cstr!(

#[cfg(test)]
mod tests {
use crate::test::reset;
use test_log::test;

#[test]
fn test_alias_ls() {
reset();
assert_cli_snapshot!("aliases", @r###"
java lts 21
node lts 20
Expand All @@ -92,6 +96,7 @@ mod tests {

#[test]
fn test_alias_ls_filter() {
reset();
assert_cli_snapshot!("aliases", "ls", "tiny", @r###"
tiny lts 3.1.0
tiny lts-prev 2.0.0
Expand Down
Loading

0 comments on commit 462db17

Please sign in to comment.