//! The CLI's own judgements, and the one test that reads the real tree.usesuper::*;#[test]fn the_repo_root_is_found_by_walking_up_to_the_workspace_manifest() {let root = repo_root().expect("the repo root"); assert!(root.join(files::ANDROID_CORE_DIR).is_dir()); assert!(root.join(files::ANDROID_DIR).is_dir()); assert!(root.join("pnpm-workspace.yaml").is_file()); assert!(root.join("apps/cotton").is_dir());}#[test]fn a_flag_with_no_value_after_it_is_refused_rather_than_ignored() {let argv = vec!["--root".to_string()];let refused = flag_value(&argv, "--root").expect_err("refused"); assert!(refused.contains("needs a directory"), "{refused}"); assert_eq!( flag_value(&["--check".to_string()], "--root").expect("absent"),None ); assert_eq!( flag_value(&["--root".to_string(), "x".to_string()], "--root").expect("given"),Some("x".to_string()) );}#[test]fn what_is_checked_in_is_what_the_generator_writes_today() {// The same comparison `--check` makes, run here too so a red one names the// differing files rather than a count of 23. This is the ONE test that// reads the repo, and the paths it reads belong to two Swift packages:// `apps/loom/Sources/CottonPaper/Generated` is the look both halves draw// with and `apps/cotton/Sources/CottonUI/Generated` the phone's, so a// move of either has to come back here.let root = repo_root().expect("the repo root");for dir in [files::IOS_DIR, files::IOS_PAPER_DIR] { assert!( root.join(dir).is_dir(),"{} is not a directory — did the generated tree move? \ Grep that path repo-wide before changing this guard.", root.join(dir).display() ); } assert_eq!( files::drift(&root).expect("checked"),Vec::<String>::new(),"run `pnpm gen:design` and commit the result" );}#[test]fn check_writes_nothing_at_all() {let root = repo_root().expect("the repo root");let before = std::fs::read_to_string(root.join(files::IOS_PAPER_DIR).join("CottonMark.swift")).expect("read"); assert_eq!(run(&["--check".to_string()]).expect("checked"), 0); assert_eq!( std::fs::read_to_string(root.join(files::IOS_PAPER_DIR).join("CottonMark.swift")).expect("read"), before );}