| ci-bench: cross-platform CI race scaffold (rickub CI vs GitHub Actions) 0baf736 Olivier Girardot yesterday | 1 | //! Integration tests: real work over the warm build, so `cargo test` is a |
| 2 | //! meaningful, separately-timed step (not a no-op). |
| 3 | |
| 4 | use bench_rust_build::{drive, interesting, make_item, run_round, Config}; |
| 5 | |
| 6 | fn small() -> Config { |
| 7 | Config { |
| 8 | items: 200, |
| 9 | rounds: 2, |
| 10 | } |
| 11 | } |
| 12 | |
| 13 | #[test] |
| 14 | fn labels_match_the_documented_pattern() { |
| 15 | assert!(interesting("cold-cache-0001")); |
| 16 | assert!(interesting("warm-boot-9999")); |
| 17 | assert!(!interesting("hot-cache-0001")); |
| 18 | assert!(!interesting("cold-cache-1")); |
| 19 | assert!(!interesting("")); |
| 20 | } |
| 21 | |
| 22 | #[test] |
| 23 | fn items_round_trip_through_json() { |
| 24 | let item = make_item(3, 42); |
| 25 | let json = serde_json::to_string(&item).unwrap(); |
| 26 | let back: bench_rust_build::Item = serde_json::from_str(&json).unwrap(); |
| 27 | assert_eq!(item, back); |
| 28 | } |
| 29 | |
| 30 | #[test] |
| 31 | fn a_round_selects_exactly_the_cold_items() { |
| 32 | // items are alternating cold-cache/warm-boot, all matching the pattern; |
| 33 | // "selected" counts matches, so every item is selected. |
| 34 | let cfg = small(); |
| 35 | let selected = run_round(&cfg, 0).unwrap(); |
| 36 | assert_eq!(selected, cfg.items as usize); |
| 37 | } |
| 38 | |
| 39 | #[tokio::test] |
| 40 | async fn the_tokio_runtime_drives_all_rounds() { |
| 41 | let cfg = small(); |
| 42 | let selected = drive(cfg.clone()).await.unwrap(); |
| 43 | assert_eq!(selected, cfg.items as usize * cfg.rounds as usize); |
| 44 | } |
| 45 | |
| 46 | #[test] |
| 47 | fn config_defaults_are_sane() { |
| 48 | let cfg = Config::default(); |
| 49 | assert!(cfg.items > 0); |
| 50 | assert!(cfg.rounds > 0); |
| 51 | } |