mod common;
use common::mds_bin;
use std::fs;
use std::path::Path;
fn create_plain_mds(dir: &Path, name: &str) {
fs::write(dir.join(name), "Hello, world!\n").unwrap();
}
fn create_messages_mds(dir: &Path, name: &str) {
fs::write(
dir.join(name),
"@message system:\nYou are a helpful assistant.\n@end\n@message user:\nHello!\n@end\n",
)
.unwrap();
}
fn create_bad_mds(dir: &Path, name: &str) {
fs::write(dir.join(name), "{{undefined_var_xyz}}\n").unwrap();
}
fn build_dir(dir: &Path, extra_args: &[&str]) -> std::process::Output {
mds_bin()
.arg("build")
.arg(dir)
.args(extra_args)
.stdout(std::process::Stdio::piped())
.stderr(std::process::Stdio::piped())
.output()
.unwrap()
}
fn check_dir(dir: &Path, extra_args: &[&str]) -> std::process::Output {
mds_bin()
.arg("check")
.arg(dir)
.args(extra_args)
.stdout(std::process::Stdio::piped())
.stderr(std::process::Stdio::piped())
.output()
.unwrap()
}
#[test]
fn dir_build_subtree_mirror_intrinsic_ext() {
let src = tempfile::tempdir().unwrap();
let out = tempfile::tempdir().unwrap();
fs::create_dir(src.path().join("sub")).unwrap();
create_plain_mds(src.path(), "plain.mds");
create_messages_mds(&src.path().join("sub"), "messages.mds");
let output = build_dir(src.path(), &["--out-dir", out.path().to_str().unwrap()]);
assert!(
output.status.success(),
"dir build should succeed; stderr: {}",
String::from_utf8_lossy(&output.stderr)
);
let plain_out = out.path().join("plain.md");
assert!(
plain_out.exists(),
"expected out/plain.md to be created; out dir: {:?}",
fs::read_dir(out.path()).map(|rd| rd
.filter_map(|e| e.ok().map(|e| e.path()))
.collect::<Vec<_>>())
);
let plain_content = fs::read_to_string(&plain_out).unwrap();
assert!(
plain_content.contains("Hello"),
"plain.md should contain rendered content; got: {plain_content:?}"
);
let msg_out = out.path().join("sub").join("messages.json");
assert!(
msg_out.exists(),
"expected out/sub/messages.json to be created"
);
let msg_content = fs::read_to_string(&msg_out).unwrap();
let parsed: serde_json::Value =
serde_json::from_str(&msg_content).expect("messages.json should be valid JSON");
assert!(parsed.is_array(), "messages.json should be a JSON array");
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
stderr.contains("built"),
"stderr should contain build summary; got: {stderr}"
);
}
#[test]
fn dir_build_partials_produce_no_output() {
let src = tempfile::tempdir().unwrap();
let out = tempfile::tempdir().unwrap();
create_plain_mds(src.path(), "_partial.mds");
create_plain_mds(src.path(), "main.mds");
let output = build_dir(src.path(), &["--out-dir", out.path().to_str().unwrap()]);
assert!(
output.status.success(),
"dir build should succeed; stderr: {}",
String::from_utf8_lossy(&output.stderr)
);
let partial_out = out.path().join("_partial.md");
assert!(
!partial_out.exists(),
"_partial.md must not be created (partials are skipped)"
);
let main_out = out.path().join("main.md");
assert!(main_out.exists(), "main.md should be created");
}
#[test]
fn dir_build_continue_on_error_summary_nonzero() {
let src = tempfile::tempdir().unwrap();
let out = tempfile::tempdir().unwrap();
create_plain_mds(src.path(), "good.mds");
create_bad_mds(src.path(), "bad.mds");
let output = build_dir(src.path(), &["--out-dir", out.path().to_str().unwrap()]);
assert!(
!output.status.success(),
"dir build with a failing file must exit non-zero"
);
let good_out = out.path().join("good.md");
assert!(
good_out.exists(),
"good.md should still be created despite bad.mds failing"
);
let bad_out = out.path().join("bad.md");
assert!(
!bad_out.exists(),
"bad.md must not be created when compilation fails"
);
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
stderr.contains("built") && stderr.contains("failed"),
"stderr must contain a build summary with 'built' and 'failed'; got: {stderr}"
);
assert!(
stderr.contains("1 built") && stderr.contains("1 failed"),
"stderr must show '1 built, 1 failed'; got: {stderr}"
);
}
#[test]
fn dir_build_bare_writes_next_to_source() {
let src = tempfile::tempdir().unwrap();
create_plain_mds(src.path(), "page.mds");
create_messages_mds(src.path(), "chat.mds");
let output = build_dir(src.path(), &[]);
assert!(
output.status.success(),
"bare dir build should succeed; stderr: {}",
String::from_utf8_lossy(&output.stderr)
);
let page_out = src.path().join("page.md");
assert!(page_out.exists(), "page.md should appear next to page.mds");
let chat_out = src.path().join("chat.json");
assert!(
chat_out.exists(),
"chat.json should appear next to chat.mds"
);
let _ = fs::remove_file(&page_out);
let _ = fs::remove_file(&chat_out);
}
#[cfg(unix)]
#[test]
fn dir_build_symlinked_file_skipped() {
let src = tempfile::tempdir().unwrap();
let out = tempfile::tempdir().unwrap();
let real_file = src.path().join("real.mds");
fs::write(&real_file, "Real content.\n").unwrap();
let link_file = src.path().join("link.mds");
std::os::unix::fs::symlink(&real_file, &link_file).unwrap();
let output = build_dir(src.path(), &["--out-dir", out.path().to_str().unwrap()]);
assert!(
output.status.success(),
"build should succeed; stderr: {}",
String::from_utf8_lossy(&output.stderr)
);
let link_out = out.path().join("link.md");
assert!(
!link_out.exists(),
"symlinked .mds file must not produce output"
);
let real_out = out.path().join("real.md");
assert!(real_out.exists(), "real.md should be created from real.mds");
}
#[cfg(unix)]
#[test]
fn dir_build_symlinked_subdir_skipped() {
let real_dir = tempfile::tempdir().unwrap();
let src = tempfile::tempdir().unwrap();
let out = tempfile::tempdir().unwrap();
fs::write(real_dir.path().join("child.mds"), "Child.\n").unwrap();
let link_dir = src.path().join("linked_sub");
std::os::unix::fs::symlink(real_dir.path(), &link_dir).unwrap();
create_plain_mds(src.path(), "root.mds");
let output = build_dir(src.path(), &["--out-dir", out.path().to_str().unwrap()]);
assert!(
output.status.success(),
"build should succeed; stderr: {}",
String::from_utf8_lossy(&output.stderr)
);
let child_out = out.path().join("linked_sub").join("child.md");
assert!(
!child_out.exists(),
"symlinked subdirectory must not be traversed"
);
}
#[cfg(unix)]
#[test]
fn dir_build_symlinked_entry_root_rejected() {
let real_dir = tempfile::tempdir().unwrap();
create_plain_mds(real_dir.path(), "page.mds");
let link_dir = tempfile::tempdir().unwrap();
let link_path = link_dir.path().join("linked");
std::os::unix::fs::symlink(real_dir.path(), &link_path).unwrap();
let output = build_dir(&link_path, &[]);
assert!(
!output.status.success(),
"build on a symlinked entry root must fail"
);
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
stderr.contains("symlink") || stderr.contains("directory"),
"error must mention symlink; got: {stderr}"
);
}
#[test]
fn dir_build_oversized_file_fails_others_succeed() {
let src = tempfile::tempdir().unwrap();
let out = tempfile::tempdir().unwrap();
create_plain_mds(src.path(), "good.mds");
let big_content = "x".repeat(10 * 1024 * 1024 + 1);
fs::write(src.path().join("big.mds"), &big_content).unwrap();
let output = build_dir(src.path(), &["--out-dir", out.path().to_str().unwrap()]);
assert!(
!output.status.success(),
"dir build with an oversized file must exit non-zero"
);
let good_out = out.path().join("good.md");
assert!(
good_out.exists(),
"good.md should still be created despite the oversized file"
);
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
stderr.contains("failed"),
"stderr must mention failure in summary; got: {stderr}"
);
}
#[test]
fn dir_check_validates_tree_exits_zero_on_all_ok() {
let src = tempfile::tempdir().unwrap();
create_plain_mds(src.path(), "page.mds");
create_messages_mds(src.path(), "chat.mds");
let output = check_dir(src.path(), &[]);
assert!(
output.status.success(),
"check on a valid tree should succeed; stderr: {}",
String::from_utf8_lossy(&output.stderr)
);
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
stderr.contains("passed"),
"stderr should contain check summary; got: {stderr}"
);
}
#[test]
fn dir_check_continues_on_error_nonzero_exit() {
let src = tempfile::tempdir().unwrap();
create_plain_mds(src.path(), "good.mds");
create_bad_mds(src.path(), "bad.mds");
let output = check_dir(src.path(), &[]);
assert!(
!output.status.success(),
"check with a failing file must exit non-zero"
);
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
stderr.contains("passed") || stderr.contains("failed"),
"stderr must contain check summary; got: {stderr}"
);
}
#[test]
fn dir_check_empty_dir_exits_zero() {
let src = tempfile::tempdir().unwrap();
let output = check_dir(src.path(), &[]);
assert!(
output.status.success(),
"check on empty dir should succeed; stderr: {}",
String::from_utf8_lossy(&output.stderr)
);
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
stderr.contains("No .mds files") || stderr.contains("no .mds"),
"stderr should mention no files found; got: {stderr}"
);
}
#[test]
fn dir_check_mixed_content_file_nonzero() {
let src = tempfile::tempdir().unwrap();
fs::write(
src.path().join("mixed.mds"),
"Some text before.\n@message user:\nHello!\n@end\n",
)
.unwrap();
let output = check_dir(src.path(), &[]);
assert!(
!output.status.success(),
"check on a mixed-content file must exit non-zero"
);
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
stderr.contains("mixed") || stderr.contains("failed"),
"error must mention mixed content or failure; got: {stderr}"
);
}
#[test]
fn dir_build_stale_output_cleaned_on_format_flip() {
let src = tempfile::tempdir().unwrap();
let out = tempfile::tempdir().unwrap();
let mds_path = src.path().join("page.mds");
fs::write(&mds_path, "Hello, world!\n").unwrap();
let output1 = build_dir(src.path(), &["--out-dir", out.path().to_str().unwrap()]);
assert!(
output1.status.success(),
"first build should succeed; stderr: {}",
String::from_utf8_lossy(&output1.stderr)
);
let md_out = out.path().join("page.md");
assert!(md_out.exists(), "page.md should be created on first build");
fs::write(&mds_path, "@message user:\nHello!\n@end\n").unwrap();
let output2 = build_dir(src.path(), &["--out-dir", out.path().to_str().unwrap()]);
assert!(
output2.status.success(),
"second build should succeed; stderr: {}",
String::from_utf8_lossy(&output2.stderr)
);
let json_out = out.path().join("page.json");
assert!(
json_out.exists(),
"page.json should be created on second build"
);
assert!(
!md_out.exists(),
"stale page.md should be removed after format flip to messages"
);
}
#[test]
fn dir_build_empty_dir_exits_zero() {
let src = tempfile::tempdir().unwrap();
let output = build_dir(src.path(), &[]);
assert!(
output.status.success(),
"build on empty dir should succeed; stderr: {}",
String::from_utf8_lossy(&output.stderr)
);
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
stderr.contains("No .mds files") || stderr.contains("no .mds"),
"stderr should mention no .mds files; got: {stderr}"
);
}
fn lint_dir(dir: &Path, extra_args: &[&str]) -> std::process::Output {
mds_bin()
.arg("lint")
.arg(dir)
.args(extra_args)
.stdout(std::process::Stdio::piped())
.stderr(std::process::Stdio::piped())
.output()
.unwrap()
}
fn fmt_dir(dir: &Path, extra_args: &[&str]) -> std::process::Output {
mds_bin()
.arg("fmt")
.arg(dir)
.args(extra_args)
.stdout(std::process::Stdio::piped())
.stderr(std::process::Stdio::piped())
.output()
.unwrap()
}
#[test]
fn dir_build_all_excluded_exits_nonzero() {
let src = tempfile::tempdir().unwrap();
let hidden = src.path().join(".github");
fs::create_dir_all(hidden.join("prompts")).unwrap();
fs::write(hidden.join("prompts").join("system.mds"), "Hello!\n").unwrap();
let output = build_dir(src.path(), &[]);
assert!(
!output.status.success(),
"build with all candidates in excluded dirs must exit non-zero; exit: {:?}; stderr: {}",
output.status.code(),
String::from_utf8_lossy(&output.stderr)
);
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
stderr.contains("excluded") || stderr.contains("default-excluded"),
"stderr must mention excluded directories; got: {stderr}"
);
assert!(
stderr.contains('1'),
"stderr must carry the skip count (1 file excluded); got: {stderr}"
);
}
#[test]
fn dir_build_all_excluded_quiet_still_emits_diagnostic() {
let src = tempfile::tempdir().unwrap();
let nm = src.path().join("node_modules");
fs::create_dir(&nm).unwrap();
fs::write(nm.join("lib.mds"), "Hello!\n").unwrap();
fs::write(nm.join("other.mds"), "World!\n").unwrap();
let output = build_dir(src.path(), &["--quiet"]);
assert!(
!output.status.success(),
"build with all candidates excluded must exit non-zero even under --quiet"
);
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
!stderr.is_empty(),
"stderr must not be empty under --quiet when all candidates are excluded"
);
assert!(
stderr.contains("excluded") || stderr.contains("default-excluded"),
"all-excluded diagnostic must appear under --quiet; got: {stderr}"
);
assert!(
stderr.contains('2'),
"stderr must report 2 skipped files; got: {stderr}"
);
}
#[test]
fn dir_build_genuinely_empty_still_exits_zero() {
let src = tempfile::tempdir().unwrap();
let output = build_dir(src.path(), &[]);
assert!(
output.status.success(),
"genuinely empty dir must still exit 0; stderr: {}",
String::from_utf8_lossy(&output.stderr)
);
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
stderr.contains("No .mds files") || stderr.contains("no .mds"),
"empty-dir message should mention no .mds files; got: {stderr}"
);
assert!(
!stderr.contains("excluded"),
"empty-dir must NOT show the excluded diagnostic; got: {stderr}"
);
}
#[test]
fn dir_build_mixed_excluded_and_normal_processes_normal() {
let src = tempfile::tempdir().unwrap();
let out = tempfile::tempdir().unwrap();
create_plain_mds(src.path(), "normal.mds");
let hidden = src.path().join(".prompts");
fs::create_dir(&hidden).unwrap();
fs::write(hidden.join("excluded.mds"), "Hello!\n").unwrap();
let output = build_dir(src.path(), &["--out-dir", out.path().to_str().unwrap()]);
assert!(
output.status.success(),
"build with mixed excluded+normal files must succeed; stderr: {}",
String::from_utf8_lossy(&output.stderr)
);
assert!(
out.path().join("normal.md").exists(),
"normal.md must be built"
);
assert!(
!out.path().join(".prompts").join("excluded.md").exists(),
"excluded.md must not be built"
);
}
#[test]
fn dir_check_all_excluded_exits_nonzero() {
let src = tempfile::tempdir().unwrap();
let hidden = src.path().join(".claude");
fs::create_dir(&hidden).unwrap();
fs::write(hidden.join("prompt.mds"), "Hello!\n").unwrap();
let output = check_dir(src.path(), &[]);
assert!(
!output.status.success(),
"check with all candidates in excluded dirs must exit non-zero; stderr: {}",
String::from_utf8_lossy(&output.stderr)
);
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
stderr.contains("excluded") || stderr.contains("default-excluded"),
"stderr must mention excluded directories; got: {stderr}"
);
assert!(
stderr.contains('1'),
"stderr must carry the skip count; got: {stderr}"
);
}
#[test]
fn dir_check_all_excluded_quiet_still_emits_diagnostic() {
let src = tempfile::tempdir().unwrap();
let hidden = src.path().join(".cursor");
fs::create_dir_all(hidden.join("rules")).unwrap();
fs::write(hidden.join("rules").join("rule.mds"), "Hello!\n").unwrap();
let output = check_dir(src.path(), &["--quiet"]);
assert!(
!output.status.success(),
"check with all candidates excluded must exit non-zero even under --quiet"
);
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
!stderr.is_empty() && (stderr.contains("excluded") || stderr.contains("default-excluded")),
"all-excluded diagnostic must appear under --quiet; got: {stderr:?}"
);
}
#[test]
fn dir_lint_all_excluded_exits_nonzero() {
let src = tempfile::tempdir().unwrap();
let nm = src.path().join("node_modules");
fs::create_dir(&nm).unwrap();
fs::write(nm.join("template.mds"), "Hello!\n").unwrap();
let output = lint_dir(src.path(), &[]);
assert!(
!output.status.success(),
"lint with all candidates in excluded dirs must exit non-zero; stderr: {}",
String::from_utf8_lossy(&output.stderr)
);
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
stderr.contains("excluded") || stderr.contains("default-excluded"),
"stderr must mention excluded directories; got: {stderr}"
);
}
#[test]
fn dir_lint_all_excluded_quiet_still_emits_diagnostic() {
let src = tempfile::tempdir().unwrap();
let hidden = src.path().join(".github");
fs::create_dir(&hidden).unwrap();
fs::write(hidden.join("workflow.mds"), "Hello!\n").unwrap();
let output = lint_dir(src.path(), &["--quiet"]);
assert!(
!output.status.success(),
"lint with all candidates excluded must exit non-zero even under --quiet"
);
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
!stderr.is_empty() && (stderr.contains("excluded") || stderr.contains("default-excluded")),
"all-excluded diagnostic must appear under --quiet; got: {stderr:?}"
);
}
#[test]
fn dir_fmt_all_excluded_exits_nonzero() {
let src = tempfile::tempdir().unwrap();
let hidden = src.path().join(".prompts");
fs::create_dir(&hidden).unwrap();
fs::write(hidden.join("system.mds"), "Hello!\n").unwrap();
let output = fmt_dir(src.path(), &[]);
assert!(
!output.status.success(),
"fmt with all candidates in excluded dirs must exit non-zero; stderr: {}",
String::from_utf8_lossy(&output.stderr)
);
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
stderr.contains("excluded") || stderr.contains("default-excluded"),
"stderr must mention excluded directories; got: {stderr}"
);
}
#[test]
fn dir_fmt_all_excluded_quiet_still_emits_diagnostic() {
let src = tempfile::tempdir().unwrap();
let nm = src.path().join("node_modules");
fs::create_dir(&nm).unwrap();
fs::write(nm.join("component.mds"), "Hello!\n").unwrap();
let output = fmt_dir(src.path(), &["--quiet"]);
assert!(
!output.status.success(),
"fmt with all candidates excluded must exit non-zero even under --quiet"
);
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
!stderr.is_empty() && (stderr.contains("excluded") || stderr.contains("default-excluded")),
"all-excluded diagnostic must appear under --quiet; got: {stderr:?}"
);
}
#[test]
fn dir_build_quiet_suppresses_summary_on_success() {
let src1 = tempfile::tempdir().unwrap();
create_plain_mds(src1.path(), "a.mds");
create_plain_mds(src1.path(), "b.mds");
let quiet_out = build_dir(src1.path(), &["--quiet"]);
assert_eq!(
quiet_out.status.code(),
Some(0),
"quiet build over an all-success tree must exit 0; stderr: {}",
String::from_utf8_lossy(&quiet_out.stderr)
);
let quiet_stderr = String::from_utf8_lossy(&quiet_out.stderr);
assert!(
quiet_stderr.is_empty(),
"AC-Q01: --quiet build with no failures must produce empty stderr; got: {quiet_stderr:?}"
);
let src2 = tempfile::tempdir().unwrap();
create_plain_mds(src2.path(), "a.mds");
create_plain_mds(src2.path(), "b.mds");
let control_out = build_dir(src2.path(), &[]);
let control_stderr = String::from_utf8_lossy(&control_out.stderr);
assert!(
control_stderr.contains("2 built"),
"positive control: non-quiet run must print '2 built' so the quiet absence assertion \
is non-vacuous; got: {control_stderr:?}"
);
}
#[test]
fn dir_build_quiet_still_prints_summary_on_failure() {
let src = tempfile::tempdir().unwrap();
create_plain_mds(src.path(), "good.mds");
create_bad_mds(src.path(), "bad.mds");
let output = build_dir(src.path(), &["--quiet"]);
assert_eq!(
output.status.code(),
Some(1),
"quiet build with a failing file must exit 1; stderr: {}",
String::from_utf8_lossy(&output.stderr)
);
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
stderr.contains("1 built"),
"AC-Q02: --quiet build with failures must print summary so non-zero exit is explained; \
got: {stderr:?}"
);
assert!(
stderr.contains("1 failed"),
"AC-Q02: summary must include '1 failed'; got: {stderr:?}"
);
}
#[test]
fn dir_build_quiet_works_in_pre_subcommand_position() {
let src = tempfile::tempdir().unwrap();
create_plain_mds(src.path(), "a.mds");
create_plain_mds(src.path(), "b.mds");
let post = build_dir(src.path(), &["--quiet"]);
let pre = mds_bin()
.arg("--quiet")
.arg("build")
.arg(src.path())
.stdout(std::process::Stdio::piped())
.stderr(std::process::Stdio::piped())
.output()
.unwrap();
assert_eq!(
pre.status.code(),
post.status.code(),
"pre-subcommand --quiet must produce the same exit code as post-subcommand --quiet"
);
assert_eq!(
pre.stderr, post.stderr,
"pre-subcommand --quiet must produce the same stderr as post-subcommand --quiet"
);
assert!(
post.stderr.is_empty(),
"AC-Q30 anchor: an all-success tree under --quiet must produce empty stderr in \
BOTH orderings, not merely equal stderr; got: {}",
String::from_utf8_lossy(&post.stderr)
);
let control_src = tempfile::tempdir().unwrap();
create_plain_mds(control_src.path(), "a.mds");
create_plain_mds(control_src.path(), "b.mds");
let control = build_dir(control_src.path(), &[]);
assert!(
String::from_utf8_lossy(&control.stderr).contains("2 built, 0 failed"),
"positive control: the same tree without --quiet must print '2 built, 0 failed'; got: {}",
String::from_utf8_lossy(&control.stderr)
);
}
fn create_defs_only_mds(dir: &Path, name: &str) {
fs::write(
dir.join(name),
"@define greet(name):\n Hi {{name}}\n@end\n\n@export greet\n",
)
.unwrap();
}
#[test]
fn d5_dir_build_summary_reports_empty_outputs() {
let src = tempfile::tempdir().unwrap();
create_plain_mds(src.path(), "a.mds");
create_defs_only_mds(src.path(), "lib.mds");
let output = build_dir(src.path(), &[]);
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
output.status.success(),
"both files compile successfully; stderr: {stderr}"
);
let lib_out = src.path().join("lib.md");
assert_eq!(
fs::metadata(&lib_out).map(|m| m.len()).ok(),
Some(0),
"fixture invariant: lib.md must be a zero-byte output"
);
assert!(
stderr.contains("2 built (1 empty), 0 failed"),
"R5: summary must count zero-byte outputs; got: {stderr}"
);
}
#[test]
fn d5_dir_build_summary_omits_empty_clause_when_none() {
let src = tempfile::tempdir().unwrap();
create_plain_mds(src.path(), "a.mds");
let output = build_dir(src.path(), &[]);
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
stderr.contains("1 built, 0 failed"),
"summary keeps its historical form when no output is empty; got: {stderr}"
);
assert!(
!stderr.contains("empty"),
"R5: the empty clause must be ABSENT when every output has content \
(no golden churn); got: {stderr}"
);
}
#[test]
fn d5_dir_build_quiet_gate_unchanged_with_empty_outputs() {
let src = tempfile::tempdir().unwrap();
create_plain_mds(src.path(), "a.mds");
create_defs_only_mds(src.path(), "lib.mds");
let output = build_dir(src.path(), &["--quiet"]);
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(output.status.success(), "all-success run; stderr: {stderr}");
assert!(
!stderr.contains("built"),
"R5: --quiet must still suppress the summary on an all-success run even \
when empty outputs exist (gate unchanged); got: {stderr}"
);
}