rickub/ci-benchpublic Fork 0
c936d6f2dbc65f365b8bab9c6e0c032a7582d0dd
Commits
Clone
git clone https://git.rickub.com/rickub/ci-bench.git
git clone ssh://git@rickub.com/rickub/ci-bench.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

workload.rs · 51 lines · 1.4 KBRust Blame HistoryRaw
ci-bench: cross-platform CI race scaffold (rickub CI vs GitHub Actions) 0baf736 Olivier Girardot yesterday1//! Integration tests: real work over the warm build, so `cargo test` is a
2//! meaningful, separately-timed step (not a no-op).
3
4use bench_rust_build::{drive, interesting, make_item, run_round, Config};
5
6fn small() -> Config {
7 Config {
8 items: 200,
9 rounds: 2,
10 }
11}
12
13#[test]
14fn 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]
23fn 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]
31fn 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]
40async 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]
47fn config_defaults_are_sane() {
48 let cfg = Config::default();
49 assert!(cfg.items > 0);
50 assert!(cfg.rounds > 0);
51}