commands: do not use debug print for path

"{:?}" escapes `\` to `\\` for Windows paths. That breaks tests checking
paths without using "{:?}". Use PathBuf::display() in both commands and
tests to get consistent output.

This fixes test_init_local, test_init_git_internal, and
test_init_git_external on Windows.
This commit is contained in:
Jun Wu 2021-03-10 22:35:16 -08:00
parent eacab648b0
commit 2f93ebd42c
2 changed files with 9 additions and 3 deletions

View file

@ -615,7 +615,11 @@ fn cmd_init(
} else {
repo = ReadonlyRepo::init_local(ui.settings(), wc_path);
}
writeln!(ui, "Initialized repo in {:?}", repo.working_copy_path());
writeln!(
ui,
"Initialized repo in \"{}\"",
repo.working_copy_path().display()
);
Ok(())
}

View file

@ -51,10 +51,12 @@ fn test_init_git_external() {
assert!(repo_path.join(".jj").is_dir());
let store_file_contents = std::fs::read_to_string(repo_path.join(".jj").join("store")).unwrap();
assert!(store_file_contents.starts_with("git: "));
assert!(store_file_contents.ends_with("/git-repo"));
assert!(store_file_contents
.replace('\\', "/")
.ends_with("/git-repo"));
assert_eq!(
output.stdout_string(),
format!("Initialized repo in \"{}\"\n", repo_path.to_str().unwrap())
format!("Initialized repo in \"{}\"\n", repo_path.display())
);
}