Oregami
Repositories/oxedyne/fe2o3

oxedyne/fe2o3/fe2o3_core/tests/time_clock_install.rs

908 bytes, 1 run

created by r1870400018:74279, which is this file's identity for as long as the history lasts, whatever it is later renamed to

download · who wrote it · its history

1//! The process clock is installed once. A binary of its own, because the
2//! global it sets would otherwise leak into every other test in the process.
3
4#![cfg(not(target_arch = "wasm32"))]
5
6use oxedyne_fe2o3_core::{
7 prelude::*,
8 time::{
9 self,
10 ClockSource,
11 },
12};
13
14#[test]
15fn test_second_install_errors_07() -> Outcome<()> {
16 assert!(!time::clock().is_driven());
17 let path = std::env::temp_dir().join(fmt!("fe2o3_time_clock_install_{}", std::process::id()));
18 res!(std::fs::write(&path, 42u64.to_le_bytes()));
19 let spec = fmt!("driven:{}", path.display());
20 res!(time::install(res!(ClockSource::from_spec(Some(&spec)))));
21 assert!(time::clock().is_driven());
22 assert_eq!(res!(time::clock().now_millis()), 42);
23 assert!(time::install(ClockSource::System).is_err());
24 assert!(time::clock().is_driven());
25 res!(std::fs::remove_file(&path));
26 Ok(())
27}