1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//!
//! * **This module is included iif the *testbed* feature is enabled.**
use std::sync::Arc;

use crate::newton::Newton;

#[cfg(not(feature = "ci"))]
mod renderer;
#[cfg(not(feature = "ci"))]
mod runner;

pub trait Testbed {
    fn newton() -> Newton {
        Newton::create()
    }

    fn reset(newton: &Newton) -> Self;
}

pub fn run<T: Testbed + Send + Sync>(title: Option<&str>) {
    #[cfg(not(feature = "ci"))]
    match self::runner::Runner::<T>::run(title) {
        Ok(_) => {}
        Err(e) => {
            eprintln!("ERROR: {}\n{:#?}", e, e);
            std::process::exit(1)
        }
    }
    #[cfg(feature = "ci")]
    panic!("Newton Testbed can't run on a CI environment");
}