Skip to content

Commit

Permalink
fix: run tests in the main thread
Browse files Browse the repository at this point in the history
  • Loading branch information
mdevils committed Dec 11, 2024
1 parent 15abae4 commit 2041f07
Show file tree
Hide file tree
Showing 6 changed files with 271 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ jobs:
run: cargo clippy -- -Dwarnings

- name: Run tests
run: cargo test --all-features --verbose
run: cargo test --all-features --verbose -- --test-threads=1
245 changes: 244 additions & 1 deletion Cargo.lock

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

13 changes: 12 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "osakit"
version = "0.2.4"
version = "0.3.0"
edition = "2021"
authors = ["Marat Dulin <[email protected]>"]
description = "OSAKit macOS Framework adapted for Rust"
Expand All @@ -24,6 +24,12 @@ serde = { version = "1", features = ["derive"] }
serde_json = "1"
thiserror = "1"

[dev-dependencies]
libtest-mimic-collect = "0.3.1"

[lib]
test = false

[features]
stable = []
unstable = ["declare-script"]
Expand All @@ -39,3 +45,8 @@ cargo-watch = { version = "8.5.2" }
[package.metadata.docs.rs]
default-target = "x86_64-apple-darwin"
features = ["full"]

[[test]]
name = "test"
harness = false
path = "src/test.rs"
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ cargo-run-bin:
fi

test:
cargo test --all-features
cargo test --all-features -- --test-threads=1

lint:
cargo fmt --check
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ See [Full Documentation](https://docs.rs/osakit/).
are limited to `i32` type.
* `OSAKit` calls must be made from the main thread, so, for example, the default `cargo test`s can fail,
after stalling for 2 min, use a custom test harness like [libtest-mimic](https://github.com/LukasKalbertodt/libtest-mimic) with `--test-threads=1`.
For convenience, there is a [libtest-mimic-collect](https://crates.io/crates/libtest-mimic-collect)
crate that provides a procedural macro for collecting tests for `libtest-mimic` crate.

## Supported platforms

Expand Down
11 changes: 11 additions & 0 deletions src/test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
mod export;

#[allow(unused_imports)]
pub use export::*;

#[macro_use]
extern crate libtest_mimic_collect;

pub fn main() {
libtest_mimic_collect::TestCollection::run();
}

0 comments on commit 2041f07

Please sign in to comment.