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
878d144b77
221 changed files with 5316 additions and 0 deletions
81
tools/limits/tests/scan.rs
Normal file
81
tools/limits/tests/scan.rs
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
mod tree;
|
||||
|
||||
use fabrilis_limits::{MAX_FILES_PER_DIR, MAX_LINES, WARN_LINES, scan};
|
||||
use tree::TempTree;
|
||||
|
||||
fn lines(count: usize) -> String {
|
||||
"let _x = 1;\n".repeat(count)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn clean_tree_has_no_findings() {
|
||||
let tree = TempTree::new("clean");
|
||||
tree.write("a.rs", &lines(10));
|
||||
let report = scan(tree.path());
|
||||
assert!(report.errors.is_empty() && report.warnings.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn soft_limit_warns_but_does_not_fail() {
|
||||
let tree = TempTree::new("soft");
|
||||
tree.write("a.rs", &lines(WARN_LINES + 1));
|
||||
let report = scan(tree.path());
|
||||
assert!(report.errors.is_empty());
|
||||
assert_eq!(report.warnings.len(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn exactly_at_limits_is_fine() {
|
||||
let tree = TempTree::new("edge");
|
||||
tree.write("a.rs", &lines(MAX_LINES));
|
||||
let report = scan(tree.path());
|
||||
assert!(report.errors.is_empty());
|
||||
assert_eq!(report.warnings.len(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hard_limit_is_an_error() {
|
||||
let tree = TempTree::new("hard");
|
||||
tree.write("a.rs", &lines(MAX_LINES + 1));
|
||||
let report = scan(tree.path());
|
||||
assert_eq!(report.errors.len(), 1);
|
||||
assert!(report.warnings.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn too_many_files_in_one_directory_is_an_error() {
|
||||
let tree = TempTree::new("files");
|
||||
for i in 0..=MAX_FILES_PER_DIR {
|
||||
tree.write(&format!("d/f{i}.rs"), "");
|
||||
}
|
||||
tree.write("other/a.rs", "");
|
||||
let report = scan(tree.path());
|
||||
assert_eq!(report.errors.len(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn subdirectories_do_not_count_towards_the_file_limit() {
|
||||
let tree = TempTree::new("subdirs");
|
||||
for i in 0..MAX_FILES_PER_DIR {
|
||||
tree.write(&format!("d/f{i}.rs"), "");
|
||||
tree.write(&format!("d/sub{i}/mod.rs"), "");
|
||||
}
|
||||
assert!(scan(tree.path()).errors.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn non_english_comment_is_an_error_with_a_location() {
|
||||
let tree = TempTree::new("lang");
|
||||
tree.write("a.rs", "fn a() {}\n// комментарий\n");
|
||||
let report = scan(tree.path());
|
||||
assert_eq!(report.errors.len(), 1);
|
||||
assert!(report.errors[0].contains("a.rs:2"), "{:?}", report.errors);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn docs_and_target_are_ignored() {
|
||||
let tree = TempTree::new("skip");
|
||||
tree.write("docs/x.rs", &lines(MAX_LINES + 10));
|
||||
tree.write("target/y.rs", &lines(MAX_LINES + 10));
|
||||
assert!(scan(tree.path()).errors.is_empty());
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue