diff --git a/AGENTS.md b/AGENTS.md index 185d0946cf1c..89819ebe273f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -358,6 +358,7 @@ lldb target/debugging/forest ## Cargo Features - **`default`** - `jemalloc`, `tokio-console`, `tracing-loki`, `tracing-chrome` +- **`test`** - Default feature set for unit tests - **`slim`** - Minimal feature set (uses rustalloc) - **`jemalloc`** - Use jemalloc allocator (production default) - **`rustalloc`** - Use Rust standard allocator @@ -366,6 +367,7 @@ lldb target/debugging/forest - **`tracing-loki`** - Send telemetry to Loki - **`tracing-chrome`** - Chrome tracing support - **`no-f3-sidecar`** - Disable F3 sidecar build +- **`cargo-test`** - Group of tests that is recommended to run with `cargo test` instead of `nextest` - **`doctest-private`** - Enable doctests for private items - **`benchmark-private`** - Enable benchmark suite - **`interop-tests-private`** - Enable interop tests diff --git a/Cargo.toml b/Cargo.toml index 761694c215e5..269653193546 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -310,7 +310,9 @@ lto = "fat" # These should be refactored (probably removed) in #2984 [features] default = ["jemalloc", "tokio-console", "tracing-loki", "tracing-chrome", "sqlite"] +test = [] # default feature set for unit tests slim = ["rustalloc"] +cargo-test = [] # group of tests that is recommended to run with `cargo test` instead of `nextest` doctest-private = [] # see lib.rs::doctest_private benchmark-private = ["dep:criterion"] # see lib.rs::benchmark_private interop-tests-private = [] # see lib.rs::interop_tests_private diff --git a/build.rs b/build.rs index 71adeadcec41..04aa606d1430 100644 --- a/build.rs +++ b/build.rs @@ -81,8 +81,9 @@ fn rpc_regression_tests_gen() { writeln!( w, r#" + #[cfg(feature = "cargo-test")] #[tokio::test(flavor = "multi_thread")] - async fn rpc_snapshot_test_{ident}() {{ + async fn cargo_test_rpc_snapshot_test_{ident}() {{ rpc_regression_test_run("{test}").await }} "#, diff --git a/mise.toml b/mise.toml index 77a456a3438e..bc6330964739 100644 --- a/mise.toml +++ b/mise.toml @@ -157,11 +157,11 @@ arg "" help="Build profile (quick, release, etc.)" default="quick" { } ''' run = ''' -cargo test --doc --profile ${usage_profile?} --features doctest-private --no-fail-fast +cargo test --doc --profile ${usage_profile?} --no-default-features --features "test doctest-private" --no-fail-fast ''' -[tasks."test:rust"] -description = "Run Rust unit and integration tests." +[tasks."test:nextest"] +description = "Run Rust unit and integration tests except `cargo-test` group with nextest." usage = ''' arg "" help="Build profile (quick, release, etc.)" default="quick" { choices "quick" "release" "dev" @@ -169,7 +169,19 @@ arg "" help="Build profile (quick, release, etc.)" default="quick" { ''' run = ''' echo "Running tests with profile: ${usage_profile?}" -cargo nextest run --cargo-profile ${usage_profile?} --workspace --no-fail-fast +cargo nextest run --cargo-profile ${usage_profile?} --workspace --no-default-features --features "test" --no-fail-fast +''' + +[tasks."test:cargo"] +description = "Run Rust unit, integration and doc tests of `cargo-test` group with cargo test." +usage = ''' +arg "" help="Build profile (quick, release, etc.)" default="quick" { + choices "quick" "release" "dev" +} +''' +run = ''' +echo "Running tests with profile: ${usage_profile?}" +cargo test --lib --profile ${usage_profile?} --workspace --no-default-features --features "test cargo-test" --no-fail-fast -- --test "cargo_test_" ''' [tasks.test] @@ -180,14 +192,15 @@ arg "" help="Build profile (quick, release, etc.)" default="quick" { } ''' run = ''' -mise task run test:rust ${usage_profile?} +mise task run test:nextest ${usage_profile?} +mise task run test:cargo ${usage_profile?} mise task run test:docs ${usage_profile?} ''' [tasks.codecov] description = "Generate codecov report" run = ''' -cargo llvm-cov -p forest-filecoin --codecov --output-path lcov.info +cargo llvm-cov -p forest-filecoin --codecov --no-default-features --features "test cargo-test" --output-path lcov.info ''' [tasks."docs:format-spellcheck-dictionary"] diff --git a/src/state_manager/utils.rs b/src/state_manager/utils.rs index 5c02fa27e5bf..1d6ca35f1a28 100644 --- a/src/state_manager/utils.rs +++ b/src/state_manager/utils.rs @@ -355,6 +355,7 @@ pub mod state_compute { //! use super::*; + #[cfg(feature = "cargo-test")] use crate::chain_sync::tipset_syncer::validate_tipset; #[tokio::test(flavor = "multi_thread")] @@ -366,8 +367,9 @@ pub mod state_compute { } // FVM@4 + #[cfg(feature = "cargo-test")] #[tokio::test(flavor = "multi_thread")] - async fn state_compute_mainnet_5709604() { + async fn cargo_test_state_compute_mainnet_5709604() { let chain = NetworkChain::Mainnet; let snapshot = get_state_compute_snapshot(&chain, 5709604).await.unwrap(); let (sm, ts, ts_next) = prepare_state_compute(&chain, &snapshot).await.unwrap(); @@ -375,8 +377,9 @@ pub mod state_compute { } // FVM@4 + #[cfg(feature = "cargo-test")] #[tokio::test(flavor = "multi_thread")] - async fn state_compute_calibnet_3408952() { + async fn cargo_test_state_compute_calibnet_3408952() { let chain = NetworkChain::Calibnet; let snapshot = get_state_compute_snapshot(&chain, 3408952).await.unwrap(); let (sm, ts, ts_next) = prepare_state_compute(&chain, &snapshot).await.unwrap(); @@ -384,8 +387,9 @@ pub mod state_compute { } // Shark state migration with FVM@2 + #[cfg(feature = "cargo-test")] #[tokio::test(flavor = "multi_thread")] - async fn state_compute_calibnet_16801() { + async fn cargo_test_state_compute_calibnet_16801() { let chain = NetworkChain::Calibnet; let snapshot = get_state_compute_snapshot(&chain, 16801).await.unwrap(); let (sm, ts, ts_next) = prepare_state_compute(&chain, &snapshot).await.unwrap(); @@ -393,8 +397,9 @@ pub mod state_compute { } // Hygge state migration with FVM@2 + #[cfg(feature = "cargo-test")] #[tokio::test(flavor = "multi_thread")] - async fn state_compute_calibnet_322355() { + async fn cargo_test_state_compute_calibnet_322355() { let chain = NetworkChain::Calibnet; let snapshot = get_state_compute_snapshot(&chain, 322355).await.unwrap(); let (sm, ts, ts_next) = prepare_state_compute(&chain, &snapshot).await.unwrap(); @@ -402,8 +407,9 @@ pub mod state_compute { } // Lightning state migration with FVM@3 + #[cfg(feature = "cargo-test")] #[tokio::test(flavor = "multi_thread")] - async fn state_compute_calibnet_489095() { + async fn cargo_test_state_compute_calibnet_489095() { let chain = NetworkChain::Calibnet; let snapshot = get_state_compute_snapshot(&chain, 489095).await.unwrap(); let (sm, ts, ts_next) = prepare_state_compute(&chain, &snapshot).await.unwrap(); @@ -411,8 +417,9 @@ pub mod state_compute { } // Watermelon state migration with FVM@3 + #[cfg(feature = "cargo-test")] #[tokio::test(flavor = "multi_thread")] - async fn state_compute_calibnet_1013135() { + async fn cargo_test_state_compute_calibnet_1013135() { let chain = NetworkChain::Calibnet; let snapshot = get_state_compute_snapshot(&chain, 1013135).await.unwrap(); let (sm, ts, ts_next) = prepare_state_compute(&chain, &snapshot).await.unwrap(); @@ -420,8 +427,9 @@ pub mod state_compute { } // Dragon state migration with FVM@4 + #[cfg(feature = "cargo-test")] #[tokio::test(flavor = "multi_thread")] - async fn state_compute_calibnet_1427975() { + async fn cargo_test_state_compute_calibnet_1427975() { let chain = NetworkChain::Calibnet; let snapshot = get_state_compute_snapshot(&chain, 1427975).await.unwrap(); let (sm, ts, ts_next) = prepare_state_compute(&chain, &snapshot).await.unwrap(); @@ -429,8 +437,9 @@ pub mod state_compute { } // Waffle state migration with FVM@4 + #[cfg(feature = "cargo-test")] #[tokio::test(flavor = "multi_thread")] - async fn state_compute_calibnet_1779095() { + async fn cargo_test_state_compute_calibnet_1779095() { let chain = NetworkChain::Calibnet; let snapshot = get_state_compute_snapshot(&chain, 1779095).await.unwrap(); let (sm, ts, ts_next) = prepare_state_compute(&chain, &snapshot).await.unwrap(); @@ -438,8 +447,9 @@ pub mod state_compute { } // TukTuk state migration with FVM@4 + #[cfg(feature = "cargo-test")] #[tokio::test(flavor = "multi_thread")] - async fn state_compute_calibnet_2078795() { + async fn cargo_test_state_compute_calibnet_2078795() { let chain = NetworkChain::Calibnet; let snapshot = get_state_compute_snapshot(&chain, 2078795).await.unwrap(); let (sm, ts, ts_next) = prepare_state_compute(&chain, &snapshot).await.unwrap(); @@ -447,8 +457,9 @@ pub mod state_compute { } // Teep state migration with FVM@4 + #[cfg(feature = "cargo-test")] #[tokio::test(flavor = "multi_thread")] - async fn state_compute_calibnet_2523455() { + async fn cargo_test_state_compute_calibnet_2523455() { let chain = NetworkChain::Calibnet; let snapshot = get_state_compute_snapshot(&chain, 2523455).await.unwrap(); let (sm, ts, ts_next) = prepare_state_compute(&chain, &snapshot).await.unwrap(); @@ -456,16 +467,18 @@ pub mod state_compute { } // GoldenWeek state migration with FVM@4 + #[cfg(feature = "cargo-test")] #[tokio::test(flavor = "multi_thread")] - async fn state_compute_calibnet_3007295() { + async fn cargo_test_state_compute_calibnet_3007295() { let chain = NetworkChain::Calibnet; let snapshot = get_state_compute_snapshot(&chain, 3007295).await.unwrap(); let (sm, ts, ts_next) = prepare_state_compute(&chain, &snapshot).await.unwrap(); state_compute(&sm, ts, &ts_next).await.unwrap(); } + #[cfg(feature = "cargo-test")] #[tokio::test(flavor = "multi_thread")] - async fn state_validate_mainnet_5688000() { + async fn cargo_test_state_validate_mainnet_5688000() { let chain = NetworkChain::Mainnet; let snapshot = get_state_validate_snapshot(&chain, 5688000).await.unwrap(); let (sm, fts) = prepare_state_validate(&chain, &snapshot).await.unwrap(); @@ -473,8 +486,9 @@ pub mod state_compute { } // Shark state migration + #[cfg(feature = "cargo-test")] #[tokio::test(flavor = "multi_thread")] - async fn state_validate_calibnet_16802() { + async fn cargo_test_state_validate_calibnet_16802() { let chain = NetworkChain::Calibnet; let snapshot = get_state_validate_snapshot(&chain, 16802).await.unwrap(); let (sm, fts) = prepare_state_validate(&chain, &snapshot).await.unwrap(); @@ -482,8 +496,9 @@ pub mod state_compute { } // Hygge state migration + #[cfg(feature = "cargo-test")] #[tokio::test(flavor = "multi_thread")] - async fn state_validate_calibnet_322356() { + async fn cargo_test_state_validate_calibnet_322356() { let chain = NetworkChain::Calibnet; let snapshot = get_state_validate_snapshot(&chain, 322356).await.unwrap(); let (sm, fts) = prepare_state_validate(&chain, &snapshot).await.unwrap(); diff --git a/src/tool/subcommands/api_cmd/test_snapshot.rs b/src/tool/subcommands/api_cmd/test_snapshot.rs index 80265660b6d8..fee3b3620ca1 100644 --- a/src/tool/subcommands/api_cmd/test_snapshot.rs +++ b/src/tool/subcommands/api_cmd/test_snapshot.rs @@ -179,6 +179,7 @@ mod tests { // To run a single test: cargo test --lib filecoin_multisig_statedecodeparams_1754230255631789 -- --nocapture include!(concat!(env!("OUT_DIR"), "/__rpc_regression_tests_gen.rs")); + #[allow(dead_code)] async fn rpc_regression_test_run(name: &str) { // Set proof parameter data dir and make sure the proofs are available {