Skip to content

Commit 815a03f

Browse files
authored
fix(ci): move snapshot tests to using cargo test (#6540)
1 parent 63620e9 commit 815a03f

File tree

6 files changed

+55
-21
lines changed

6 files changed

+55
-21
lines changed

AGENTS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ lldb target/debugging/forest
358358
## Cargo Features
359359

360360
- **`default`** - `jemalloc`, `tokio-console`, `tracing-loki`, `tracing-chrome`
361+
- **`test`** - Default feature set for unit tests
361362
- **`slim`** - Minimal feature set (uses rustalloc)
362363
- **`jemalloc`** - Use jemalloc allocator (production default)
363364
- **`rustalloc`** - Use Rust standard allocator
@@ -366,6 +367,7 @@ lldb target/debugging/forest
366367
- **`tracing-loki`** - Send telemetry to Loki
367368
- **`tracing-chrome`** - Chrome tracing support
368369
- **`no-f3-sidecar`** - Disable F3 sidecar build
370+
- **`cargo-test`** - Group of tests that is recommended to run with `cargo test` instead of `nextest`
369371
- **`doctest-private`** - Enable doctests for private items
370372
- **`benchmark-private`** - Enable benchmark suite
371373
- **`interop-tests-private`** - Enable interop tests

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,9 @@ lto = "fat"
310310
# These should be refactored (probably removed) in #2984
311311
[features]
312312
default = ["jemalloc", "tokio-console", "tracing-loki", "tracing-chrome", "sqlite"]
313+
test = [] # default feature set for unit tests
313314
slim = ["rustalloc"]
315+
cargo-test = [] # group of tests that is recommended to run with `cargo test` instead of `nextest`
314316
doctest-private = [] # see lib.rs::doctest_private
315317
benchmark-private = ["dep:criterion"] # see lib.rs::benchmark_private
316318
interop-tests-private = [] # see lib.rs::interop_tests_private

build.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ fn rpc_regression_tests_gen() {
8181
writeln!(
8282
w,
8383
r#"
84+
#[cfg(feature = "cargo-test")]
8485
#[tokio::test(flavor = "multi_thread")]
85-
async fn rpc_snapshot_test_{ident}() {{
86+
async fn cargo_test_rpc_snapshot_test_{ident}() {{
8687
rpc_regression_test_run("{test}").await
8788
}}
8889
"#,

mise.toml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,19 +157,31 @@ arg "<profile>" help="Build profile (quick, release, etc.)" default="quick" {
157157
}
158158
'''
159159
run = '''
160-
cargo test --doc --profile ${usage_profile?} --features doctest-private --no-fail-fast
160+
cargo test --doc --profile ${usage_profile?} --no-default-features --features "test doctest-private" --no-fail-fast
161161
'''
162162

163-
[tasks."test:rust"]
164-
description = "Run Rust unit and integration tests."
163+
[tasks."test:nextest"]
164+
description = "Run Rust unit and integration tests except `cargo-test` group with nextest."
165165
usage = '''
166166
arg "<profile>" help="Build profile (quick, release, etc.)" default="quick" {
167167
choices "quick" "release" "dev"
168168
}
169169
'''
170170
run = '''
171171
echo "Running tests with profile: ${usage_profile?}"
172-
cargo nextest run --cargo-profile ${usage_profile?} --workspace --no-fail-fast
172+
cargo nextest run --cargo-profile ${usage_profile?} --workspace --no-default-features --features "test" --no-fail-fast
173+
'''
174+
175+
[tasks."test:cargo"]
176+
description = "Run Rust unit, integration and doc tests of `cargo-test` group with cargo test."
177+
usage = '''
178+
arg "<profile>" help="Build profile (quick, release, etc.)" default="quick" {
179+
choices "quick" "release" "dev"
180+
}
181+
'''
182+
run = '''
183+
echo "Running tests with profile: ${usage_profile?}"
184+
cargo test --lib --profile ${usage_profile?} --workspace --no-default-features --features "test cargo-test" --no-fail-fast -- --test "cargo_test_"
173185
'''
174186

175187
[tasks.test]
@@ -180,14 +192,15 @@ arg "<profile>" help="Build profile (quick, release, etc.)" default="quick" {
180192
}
181193
'''
182194
run = '''
183-
mise task run test:rust ${usage_profile?}
195+
mise task run test:nextest ${usage_profile?}
196+
mise task run test:cargo ${usage_profile?}
184197
mise task run test:docs ${usage_profile?}
185198
'''
186199

187200
[tasks.codecov]
188201
description = "Generate codecov report"
189202
run = '''
190-
cargo llvm-cov -p forest-filecoin --codecov --output-path lcov.info
203+
cargo llvm-cov -p forest-filecoin --codecov --no-default-features --features "test cargo-test" --output-path lcov.info
191204
'''
192205

193206
[tasks."docs:format-spellcheck-dictionary"]

src/state_manager/utils.rs

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ pub mod state_compute {
355355
//!
356356
357357
use super::*;
358+
#[cfg(feature = "cargo-test")]
358359
use crate::chain_sync::tipset_syncer::validate_tipset;
359360

360361
#[tokio::test(flavor = "multi_thread")]
@@ -366,124 +367,138 @@ pub mod state_compute {
366367
}
367368

368369
// FVM@4
370+
#[cfg(feature = "cargo-test")]
369371
#[tokio::test(flavor = "multi_thread")]
370-
async fn state_compute_mainnet_5709604() {
372+
async fn cargo_test_state_compute_mainnet_5709604() {
371373
let chain = NetworkChain::Mainnet;
372374
let snapshot = get_state_compute_snapshot(&chain, 5709604).await.unwrap();
373375
let (sm, ts, ts_next) = prepare_state_compute(&chain, &snapshot).await.unwrap();
374376
state_compute(&sm, ts, &ts_next).await.unwrap();
375377
}
376378

377379
// FVM@4
380+
#[cfg(feature = "cargo-test")]
378381
#[tokio::test(flavor = "multi_thread")]
379-
async fn state_compute_calibnet_3408952() {
382+
async fn cargo_test_state_compute_calibnet_3408952() {
380383
let chain = NetworkChain::Calibnet;
381384
let snapshot = get_state_compute_snapshot(&chain, 3408952).await.unwrap();
382385
let (sm, ts, ts_next) = prepare_state_compute(&chain, &snapshot).await.unwrap();
383386
state_compute(&sm, ts, &ts_next).await.unwrap();
384387
}
385388

386389
// Shark state migration with FVM@2
390+
#[cfg(feature = "cargo-test")]
387391
#[tokio::test(flavor = "multi_thread")]
388-
async fn state_compute_calibnet_16801() {
392+
async fn cargo_test_state_compute_calibnet_16801() {
389393
let chain = NetworkChain::Calibnet;
390394
let snapshot = get_state_compute_snapshot(&chain, 16801).await.unwrap();
391395
let (sm, ts, ts_next) = prepare_state_compute(&chain, &snapshot).await.unwrap();
392396
state_compute(&sm, ts, &ts_next).await.unwrap();
393397
}
394398

395399
// Hygge state migration with FVM@2
400+
#[cfg(feature = "cargo-test")]
396401
#[tokio::test(flavor = "multi_thread")]
397-
async fn state_compute_calibnet_322355() {
402+
async fn cargo_test_state_compute_calibnet_322355() {
398403
let chain = NetworkChain::Calibnet;
399404
let snapshot = get_state_compute_snapshot(&chain, 322355).await.unwrap();
400405
let (sm, ts, ts_next) = prepare_state_compute(&chain, &snapshot).await.unwrap();
401406
state_compute(&sm, ts, &ts_next).await.unwrap();
402407
}
403408

404409
// Lightning state migration with FVM@3
410+
#[cfg(feature = "cargo-test")]
405411
#[tokio::test(flavor = "multi_thread")]
406-
async fn state_compute_calibnet_489095() {
412+
async fn cargo_test_state_compute_calibnet_489095() {
407413
let chain = NetworkChain::Calibnet;
408414
let snapshot = get_state_compute_snapshot(&chain, 489095).await.unwrap();
409415
let (sm, ts, ts_next) = prepare_state_compute(&chain, &snapshot).await.unwrap();
410416
state_compute(&sm, ts, &ts_next).await.unwrap();
411417
}
412418

413419
// Watermelon state migration with FVM@3
420+
#[cfg(feature = "cargo-test")]
414421
#[tokio::test(flavor = "multi_thread")]
415-
async fn state_compute_calibnet_1013135() {
422+
async fn cargo_test_state_compute_calibnet_1013135() {
416423
let chain = NetworkChain::Calibnet;
417424
let snapshot = get_state_compute_snapshot(&chain, 1013135).await.unwrap();
418425
let (sm, ts, ts_next) = prepare_state_compute(&chain, &snapshot).await.unwrap();
419426
state_compute(&sm, ts, &ts_next).await.unwrap();
420427
}
421428

422429
// Dragon state migration with FVM@4
430+
#[cfg(feature = "cargo-test")]
423431
#[tokio::test(flavor = "multi_thread")]
424-
async fn state_compute_calibnet_1427975() {
432+
async fn cargo_test_state_compute_calibnet_1427975() {
425433
let chain = NetworkChain::Calibnet;
426434
let snapshot = get_state_compute_snapshot(&chain, 1427975).await.unwrap();
427435
let (sm, ts, ts_next) = prepare_state_compute(&chain, &snapshot).await.unwrap();
428436
state_compute(&sm, ts, &ts_next).await.unwrap();
429437
}
430438

431439
// Waffle state migration with FVM@4
440+
#[cfg(feature = "cargo-test")]
432441
#[tokio::test(flavor = "multi_thread")]
433-
async fn state_compute_calibnet_1779095() {
442+
async fn cargo_test_state_compute_calibnet_1779095() {
434443
let chain = NetworkChain::Calibnet;
435444
let snapshot = get_state_compute_snapshot(&chain, 1779095).await.unwrap();
436445
let (sm, ts, ts_next) = prepare_state_compute(&chain, &snapshot).await.unwrap();
437446
state_compute(&sm, ts, &ts_next).await.unwrap();
438447
}
439448

440449
// TukTuk state migration with FVM@4
450+
#[cfg(feature = "cargo-test")]
441451
#[tokio::test(flavor = "multi_thread")]
442-
async fn state_compute_calibnet_2078795() {
452+
async fn cargo_test_state_compute_calibnet_2078795() {
443453
let chain = NetworkChain::Calibnet;
444454
let snapshot = get_state_compute_snapshot(&chain, 2078795).await.unwrap();
445455
let (sm, ts, ts_next) = prepare_state_compute(&chain, &snapshot).await.unwrap();
446456
state_compute(&sm, ts, &ts_next).await.unwrap();
447457
}
448458

449459
// Teep state migration with FVM@4
460+
#[cfg(feature = "cargo-test")]
450461
#[tokio::test(flavor = "multi_thread")]
451-
async fn state_compute_calibnet_2523455() {
462+
async fn cargo_test_state_compute_calibnet_2523455() {
452463
let chain = NetworkChain::Calibnet;
453464
let snapshot = get_state_compute_snapshot(&chain, 2523455).await.unwrap();
454465
let (sm, ts, ts_next) = prepare_state_compute(&chain, &snapshot).await.unwrap();
455466
state_compute(&sm, ts, &ts_next).await.unwrap();
456467
}
457468

458469
// GoldenWeek state migration with FVM@4
470+
#[cfg(feature = "cargo-test")]
459471
#[tokio::test(flavor = "multi_thread")]
460-
async fn state_compute_calibnet_3007295() {
472+
async fn cargo_test_state_compute_calibnet_3007295() {
461473
let chain = NetworkChain::Calibnet;
462474
let snapshot = get_state_compute_snapshot(&chain, 3007295).await.unwrap();
463475
let (sm, ts, ts_next) = prepare_state_compute(&chain, &snapshot).await.unwrap();
464476
state_compute(&sm, ts, &ts_next).await.unwrap();
465477
}
466478

479+
#[cfg(feature = "cargo-test")]
467480
#[tokio::test(flavor = "multi_thread")]
468-
async fn state_validate_mainnet_5688000() {
481+
async fn cargo_test_state_validate_mainnet_5688000() {
469482
let chain = NetworkChain::Mainnet;
470483
let snapshot = get_state_validate_snapshot(&chain, 5688000).await.unwrap();
471484
let (sm, fts) = prepare_state_validate(&chain, &snapshot).await.unwrap();
472485
validate_tipset(&sm, fts, None).await.unwrap();
473486
}
474487

475488
// Shark state migration
489+
#[cfg(feature = "cargo-test")]
476490
#[tokio::test(flavor = "multi_thread")]
477-
async fn state_validate_calibnet_16802() {
491+
async fn cargo_test_state_validate_calibnet_16802() {
478492
let chain = NetworkChain::Calibnet;
479493
let snapshot = get_state_validate_snapshot(&chain, 16802).await.unwrap();
480494
let (sm, fts) = prepare_state_validate(&chain, &snapshot).await.unwrap();
481495
validate_tipset(&sm, fts, None).await.unwrap();
482496
}
483497

484498
// Hygge state migration
499+
#[cfg(feature = "cargo-test")]
485500
#[tokio::test(flavor = "multi_thread")]
486-
async fn state_validate_calibnet_322356() {
501+
async fn cargo_test_state_validate_calibnet_322356() {
487502
let chain = NetworkChain::Calibnet;
488503
let snapshot = get_state_validate_snapshot(&chain, 322356).await.unwrap();
489504
let (sm, fts) = prepare_state_validate(&chain, &snapshot).await.unwrap();

src/tool/subcommands/api_cmd/test_snapshot.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ mod tests {
179179
// To run a single test: cargo test --lib filecoin_multisig_statedecodeparams_1754230255631789 -- --nocapture
180180
include!(concat!(env!("OUT_DIR"), "/__rpc_regression_tests_gen.rs"));
181181

182+
#[allow(dead_code)]
182183
async fn rpc_regression_test_run(name: &str) {
183184
// Set proof parameter data dir and make sure the proofs are available
184185
{

0 commit comments

Comments
 (0)