Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/benchmarks-mv/blob/main/tests/sync_docs.rs # benchmarks-mv Measurement harnesses and evidence bundles for AIEN on the NVIDIA DGX Spark GB10. Speed is reported against the machine's physical limit and my own previous run. Attachment of AienOS. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `benchmarks-mv / tests / sync_docs.rs` 126 lines ยท 4475 bytes Raw Blame History 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2026 Drake Stapleton (AIEN / aien-dev) 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 16 //! `sync-docs` must fail, not report "already in sync", for a target with no benchmark markers. 17 18 use std::fs; 19 use std::path::PathBuf; 20 use std::process::Command; 21 22 fn temp_doc(name: &str, body: &str) -> PathBuf { 23 let dir = std::env::temp_dir().join(format!("aien-sync-docs-{}-{}", std::process::id(), name)); 24 fs::create_dir_all(&dir).expect("create temp dir"); 25 let p = dir.join("doc.md"); 26 fs::write(&p, body).expect("write temp doc"); 27 p 28 } 29 30 fn run_sync(target: &PathBuf, check: bool) -> std::process::Output { 31 let mut cmd = Command::new(env!("CARGO_BIN_EXE_aien-benchmarks")); 32 cmd.current_dir(env!("CARGO_MANIFEST_DIR")) 33 .arg("sync-docs") 34 .arg("--target") 35 .arg(target); 36 if check { 37 cmd.arg("--check"); 38 } 39 cmd.output().expect("run aien-benchmarks") 40 } 41 42 #[test] 43 fn markerless_target_fails_in_check_and_write_mode() { 44 let body = "# A document with no benchmark table\n"; 45 for check in [true, false] { 46 let p = temp_doc(if check { "check" } else { "write" }, body); 47 let out = run_sync(&p, check); 48 let stdout = String::from_utf8_lossy(&out.stdout); 49 let stderr = String::from_utf8_lossy(&out.stderr); 50 assert!( 51 !out.status.success(), 52 "check={check}: must exit non-zero; stdout={stdout} stderr={stderr}" 53 ); 54 assert!( 55 !stdout.contains("already in sync"), 56 "check={check}: stdout={stdout}" 57 ); 58 assert!( 59 stderr.contains("no benchmark markers"), 60 "check={check}: stderr={stderr}" 61 ); 62 assert!( 63 stderr.contains(&p.display().to_string()), 64 "check={check}: stderr must name the file: {stderr}" 65 ); 66 assert_eq!( 67 fs::read_to_string(&p).unwrap(), 68 body, 69 "check={check}: file must be untouched" 70 ); 71 fs::remove_dir_all(p.parent().unwrap()).ok(); 72 } 73 } 74 75 #[test] 76 fn target_with_only_start_marker_fails() { 77 let p = temp_doc("start-only", "# Doc\n\nold\n"); 78 let out = run_sync(&p, true); 79 assert!(!out.status.success()); 80 assert!(String::from_utf8_lossy(&out.stderr).contains("no benchmark markers")); 81 fs::remove_dir_all(p.parent().unwrap()).ok(); 82 } 83 84 #[test] 85 fn markers_out_of_order_fail_and_say_so() { 86 let body = "# Doc\n\nold\n\n"; 87 let p = temp_doc("out-of-order", body); 88 let out = run_sync(&p, false); 89 assert!(!out.status.success()); 90 assert!(String::from_utf8_lossy(&out.stderr).contains("out of order")); 91 assert_eq!( 92 fs::read_to_string(&p).unwrap(), 93 body, 94 "file must be untouched" 95 ); 96 fs::remove_dir_all(p.parent().unwrap()).ok(); 97 } 98 99 #[test] 100 fn named_target_that_does_not_exist_fails() { 101 let p = std::env::temp_dir().join(format!( 102 "aien-sync-docs-{}-absent/doc.md", 103 std::process::id() 104 )); 105 let out = run_sync(&p, true); 106 let stderr = String::from_utf8_lossy(&out.stderr); 107 assert!(!out.status.success(), "stderr={stderr}"); 108 assert!(stderr.contains("Target file not found"), "stderr={stderr}"); 109 assert!(stderr.contains(&p.display().to_string()), "stderr={stderr}"); 110 } 111 112 #[test] 113 fn marked_target_syncs_then_checks_clean() { 114 let p = temp_doc( 115 "marked", 116 "# Doc\n\nold\n\n", 117 ); 118 let out = run_sync(&p, true); 119 assert!(!out.status.success(), "stale table must fail --check"); 120 let out = run_sync(&p, false); 121 assert!(out.status.success()); 122 let out = run_sync(&p, true); 123 assert!(out.status.success()); 124 assert!(String::from_utf8_lossy(&out.stdout).contains("already in sync")); 125 fs::remove_dir_all(p.parent().unwrap()).ok(); 126 }