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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#![feature(await_macro)]
pub mod webserver;
use std::env;
pub fn init_test(module: &str) {
::std::env::set_var("RUST_BACKTRACE", "1");
if ::std::env::var("RUST_LOG").is_err() {
::std::env::set_var("RUST_LOG", format!("info,{}=debug", module));
}
let _ = env_logger::try_init();
}
pub fn init_test_no_thread(module: &str) -> Result<(), ()> {
let is_single_threaded =
env::args().any(|a| a == "--test-threads=1") || env::var("RUST_TEST_THREADS").unwrap_or_else(|_| "0".to_string()) == "1";
if is_single_threaded {
init_test(module);
Ok(())
} else {
Err(())
}
}
pub fn init_quickcheck_test(module: &str, test_count: usize) {
::std::env::set_var("RUST_BACKTRACE", "0");
if ::std::env::var("RUST_LOG").is_err() {
::std::env::set_var("RUST_LOG", format!("info,{}=debug,quickcheck=debug", module));
}
::std::env::set_var("QUICKCHECK_TESTS", format!("{}", test_count));
let _ = env_logger::try_init();
}
pub fn init_webcontroll_test(module: &str) -> webserver::Service {
init_test(module);
webserver::Service::start(None).expect("Could not start webservice")
}