Initial commit: Fabrilis docs, rules and deterministic core
Docs (architecture, decisions, coupling, determinism, UI, references), code rules enforced by tools/limits, deterministic core with units, time, math, sched, snapshot, vec and rng, plus smoke tests. ref/ stays out of git.
This commit is contained in:
commit
79928b645b
222 changed files with 5335 additions and 0 deletions
37
tools/limits/tests/tree/mod.rs
Normal file
37
tools/limits/tests/tree/mod.rs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
//! A temporary directory tree for rule tests.
|
||||
|
||||
#![allow(
|
||||
clippy::unwrap_used,
|
||||
reason = "test helper: a failure should abort the test"
|
||||
)]
|
||||
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
pub struct TempTree(PathBuf);
|
||||
|
||||
impl TempTree {
|
||||
pub fn new(name: &str) -> Self {
|
||||
let root =
|
||||
std::env::temp_dir().join(format!("fabrilis-limits-{}-{name}", std::process::id()));
|
||||
let _ = fs::remove_dir_all(&root);
|
||||
fs::create_dir_all(&root).unwrap();
|
||||
Self(root)
|
||||
}
|
||||
|
||||
pub fn path(&self) -> &Path {
|
||||
&self.0
|
||||
}
|
||||
|
||||
pub fn write(&self, relative: &str, content: &str) {
|
||||
let path = self.0.join(relative);
|
||||
fs::create_dir_all(path.parent().unwrap()).unwrap();
|
||||
fs::write(path, content).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for TempTree {
|
||||
fn drop(&mut self) {
|
||||
let _ = fs::remove_dir_all(&self.0);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue