Skip to content

Commit

Permalink
test: migrate tests from unit to e2e (#3231)
Browse files Browse the repository at this point in the history
* test: migrate tests from unit to e2e

* test: migrate tests from unit to e2e
  • Loading branch information
jdx authored Nov 27, 2024
1 parent f246584 commit a530e44
Show file tree
Hide file tree
Showing 164 changed files with 154 additions and 4,022 deletions.
67 changes: 32 additions & 35 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -245,41 +245,38 @@ jobs:
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: coverage.lcov
# windows-unit:
# runs-on: windows-latest
# timeout-minutes: 30
# needs: [build-windows]
# env:
# MISE_DATA_DIR: ~/.local/share/mise
# MISE_CACHE_DIR: ~/.cache/mise
# steps:
# - uses: actions/checkout@v4
# - uses: Swatinem/rust-cache@v2
# with:
# shared-key: unit
# - uses: actions/download-artifact@v4
# with:
# name: mise-windows-latest
# path: target/debug
# - run: Add-Content "$env:GITHUB_PATH" "$env:GITHUB_WORKSPACE/target/debug"
# - run: mise -v
# # TODO: enable when we can remove continue-on-error:
# # - name: cargo test
# # uses: nick-fields/retry@v3
# # with:
# # timeout_minutes: 30
# # retry_wait_seconds: 30
# # max_attempts: 2
# # command: cargo test
# - uses: actions/cache@v4
# with:
# key: ${{ runner.os }}-mise-tools-${{ hashFiles('mise.lock') }}
# path: |
# ~/.local/share/mise
# ~/.cache/mise
# - run: mise install
# - run: cargo test
# continue-on-error: true
windows-unit:
runs-on: windows-latest
timeout-minutes: 30
needs: [build-windows]
env:
MISE_DATA_DIR: ~/.local/share/mise
MISE_CACHE_DIR: ~/.cache/mise
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
shared-key: unit
# - uses: actions/download-artifact@v4
# with:
# name: mise-windows-latest
# path: target/debug
# - run: Add-Content "$env:GITHUB_PATH" "$env:GITHUB_WORKSPACE/target/debug"
# - uses: actions/cache@v4
# with:
# key: ${{ runner.os }}-mise-tools-${{ hashFiles('mise.lock') }}
# path: |
# ~/.local/share/mise
# ~/.cache/mise
# - run: mise -v
# - run: mise install
- name: cargo test
uses: nick-fields/retry@v3
with:
timeout_minutes: 30
retry_wait_seconds: 30
max_attempts: 2
command: cargo test
windows-e2e:
runs-on: windows-latest
timeout-minutes: 30
Expand Down
125 changes: 0 additions & 125 deletions Cargo.lock

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

3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,9 @@ toml = "0.8"
indexmap = "2"

[dev-dependencies]
assert_cmd = "2"
ctor = "0.2"
insta = { version = "1", features = ["filters", "json"] }
predicates = "3"
pretty_assertions = "1"
test-case = "3"
test-log = "0.2"

[features]
Expand Down
2 changes: 1 addition & 1 deletion docs/cli/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Answer yes to all confirmation prompts
- [`mise sync <SUBCOMMAND>`](/cli/sync.md)
- [`mise sync node [FLAGS]`](/cli/sync/node.md)
- [`mise sync python <--pyenv>`](/cli/sync/python.md)
- [`mise tasks [FLAGS] <SUBCOMMAND>`](/cli/tasks.md)
- [`mise tasks [FLAGS] [TASK] <SUBCOMMAND>`](/cli/tasks.md)
- [`mise tasks deps [--hidden] [--dot] [TASKS]...`](/cli/tasks/deps.md)
- [`mise tasks edit [-p --path] <TASK>`](/cli/tasks/edit.md)
- [`mise tasks info [-J --json] <TASK>`](/cli/tasks/info.md)
Expand Down
8 changes: 7 additions & 1 deletion docs/cli/tasks.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# `mise tasks`

- **Usage**: `mise tasks [FLAGS] <SUBCOMMAND>`
- **Usage**: `mise tasks [FLAGS] [TASK] <SUBCOMMAND>`
- **Aliases**: `t`
- **Source code**: [`src/cli/tasks.rs`](https://github.com/jdx/mise/blob/main/src/cli/tasks.rs)

Manage tasks

## Arguments

### `[TASK]`

Task name to get info of

## Flags

### `--no-header`
Expand Down
3 changes: 3 additions & 0 deletions e2e/cli/test_backends
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

assert_contains "mise backends" "cargo"
13 changes: 13 additions & 0 deletions e2e/tasks/test_task_deps
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,16 @@ depends = ["hello:*"]
EOF
assert_contains "mise run hello:all" "[hello:1] Hello from 1"
assert_contains "mise run hello:all" "[hello:2] Hello from 2"
assert "mise task deps" "hello:1
hello:2
hello:all
├── hello:2
└── hello:1"
assert "mise task hello:all" 'Task: hello:all
Description: Hello from all
Source: ~/workdir/mise.toml
Depends on: hello:*
Usage Spec:
name "hello:all"
bin "hello:all"'
1 change: 1 addition & 0 deletions mise.usage.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,7 @@ cmd "tasks" help="Manage tasks" {
}
flag "-J --json" help="Output in JSON format"
flag "--usage" hide=true
arg "[TASK]" help="Task name to get info of"
cmd "deps" help="Display a tree visualization of a dependency graph" {
after_long_help r#"Examples:

Expand Down
3 changes: 0 additions & 3 deletions src/backend/asdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,13 +387,10 @@ impl Debug for AsdfBackend {
mod tests {
use test_log::test;

use crate::test::reset;

use super::*;

#[test]
fn test_debug() {
reset();
let plugin = AsdfBackend::from_arg("dummy".into());
assert!(format!("{:?}", plugin).starts_with("AsdfPlugin { name: \"dummy\""));
}
Expand Down
4 changes: 0 additions & 4 deletions src/backend/spm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,11 @@ impl SwiftPackageRepo {
#[cfg(test)]
mod tests {
use super::*;
use crate::config::config_file::reset;
use pretty_assertions::assert_str_eq;
use test_log::test;

#[test]
fn test_spm_repo_init_by_shorthand() {
reset();
let package_name = "nicklockwood/SwiftFormat";
let package_repo = SwiftPackageRepo::new(package_name).unwrap();
assert_str_eq!(
Expand All @@ -257,7 +255,6 @@ mod tests {

#[test]
fn test_spm_repo_init_name() {
reset();
assert!(
SwiftPackageRepo::new("owner/name.swift").is_ok(),
"name part can contain ."
Expand All @@ -278,7 +275,6 @@ mod tests {

#[test]
fn test_spm_repo_init_by_url() {
reset();
let package_name = "https://github.com/nicklockwood/SwiftFormat.git";
let package_repo = SwiftPackageRepo::new(package_name).unwrap();
assert_str_eq!(
Expand Down
Loading

0 comments on commit a530e44

Please sign in to comment.