Skip to content

Commit 269abbb

Browse files
committed
tests: Clean up assert_diff helper
1 parent 7580a1a commit 269abbb

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/cli.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,16 +1328,15 @@ mod tests {
13281328
use super::*;
13291329

13301330
#[track_caller]
1331-
fn assert_diff(expected_path: impl AsRef<Path>, actual: impl AsRef<str>) {
1331+
fn assert_diff(expected_path: impl AsRef<Path>, actual: impl AsRef<[u8]>) {
13321332
let actual = actual.as_ref();
13331333
let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR"));
1334-
let manifest_dir =
1335-
manifest_dir.strip_prefix(env::current_dir().unwrap()).unwrap_or(manifest_dir);
13361334
let expected_path = &manifest_dir.join(expected_path);
13371335
if !expected_path.is_file() {
1336+
fs::create_dir_all(expected_path.parent().unwrap()).unwrap();
13381337
fs::write(expected_path, "").unwrap();
13391338
}
1340-
let expected = fs::read_to_string(expected_path).unwrap();
1339+
let expected = fs::read(expected_path).unwrap();
13411340
if expected != actual {
13421341
if env::var_os("CI").is_some() {
13431342
let mut child = Command::new("git")
@@ -1347,7 +1346,7 @@ mod tests {
13471346
.stdin(Stdio::piped())
13481347
.spawn()
13491348
.unwrap();
1350-
child.stdin.as_mut().unwrap().write_all(actual.as_bytes()).unwrap();
1349+
child.stdin.as_mut().unwrap().write_all(actual).unwrap();
13511350
assert!(!child.wait().unwrap().success());
13521351
// patch -p1 <<'EOF' ... EOF
13531352
panic!("assertion failed; please run test locally and commit resulting changes, or apply above diff as patch");
@@ -1357,11 +1356,12 @@ mod tests {
13571356
}
13581357
}
13591358

1359+
// TODO: get help message from actual --help output.
13601360
#[test]
1361-
fn update_readme() -> Result<()> {
1361+
fn update_readme() {
13621362
let new = CARGO_LLVM_COV_USAGE;
13631363
let path = &Path::new(env!("CARGO_MANIFEST_DIR")).join("README.md");
1364-
let base = fs::read_to_string(path)?;
1364+
let base = fs::read_to_string(path).unwrap();
13651365
let mut out = String::with_capacity(base.capacity());
13661366
let mut lines = base.lines();
13671367
let mut start = false;
@@ -1392,6 +1392,5 @@ mod tests {
13921392
} else {
13931393
panic!("missing `<!-- readme-long-help:start -->` comment in README.md");
13941394
}
1395-
Ok(())
13961395
}
13971396
}

0 commit comments

Comments
 (0)