From 2f93ebd42c84cd4f17f07a31cfe45b416acd16b3 Mon Sep 17 00:00:00 2001 From: Jun Wu Date: Wed, 10 Mar 2021 22:35:16 -0800 Subject: [PATCH] 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. --- src/commands.rs | 6 +++++- tests/test_init_command.rs | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/commands.rs b/src/commands.rs index f81d19c50..6c2dc8c15 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -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(()) } diff --git a/tests/test_init_command.rs b/tests/test_init_command.rs index b21d23e0a..ec77cd251 100644 --- a/tests/test_init_command.rs +++ b/tests/test_init_command.rs @@ -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()) ); }