From f2de7453420d1286e6953c182a9072444a35d852 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 19 Mar 2022 19:22:08 -0700 Subject: [PATCH] Handle argv[0] change in 1.61 nightly --- Cargo.toml | 3 +++ tests/test.rs | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 9bff8cd..f76eaf6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,5 +10,8 @@ readme = "README.md" edition = "2018" rust-version = "1.33" +[dev-dependencies] +rustversion = "1.0" + [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/tests/test.rs b/tests/test.rs index 57e5d17..c6299bc 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -25,7 +25,16 @@ fn test() { #[cfg(any(target_os = "linux", target_os = "macos"))] let expected = format!("target/{}/debug/examples/print\na\nb\nc\n", TARGET); #[cfg(windows)] - let expected = format!("target\\{}\\debug\\examples\\print.exe\na\nb\nc\n", TARGET); + let expected = { + #[rustversion::since(1.61.0)] + const PREFIX: &str = concat!(r"\\?\", env!("CARGO_MANIFEST_DIR"), r"\target"); + #[rustversion::before(1.61.0)] + const PREFIX: &str = "target"; + format!( + "{}\\{}\\debug\\examples\\print.exe\na\nb\nc\n", + PREFIX, TARGET, + ) + }; let actual = String::from_utf8(output.stdout).unwrap(); assert_eq!(actual, expected);