From 2a11c26af2c3903d99092d4a1a6d33f38a28ef97 Mon Sep 17 00:00:00 2001 From: Ross Sullivan Date: Thu, 10 Apr 2025 21:34:35 +0900 Subject: [PATCH] test(build-dir): Added test for unmatched brackets in build-dir path --- tests/testsuite/build_dir.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/testsuite/build_dir.rs b/tests/testsuite/build_dir.rs index 7854bdebb..f4681a0dc 100644 --- a/tests/testsuite/build_dir.rs +++ b/tests/testsuite/build_dir.rs @@ -684,6 +684,39 @@ fn template_workspace_path_hash_should_handle_symlink() { } } +#[cargo_test] +fn template_should_handle_ignore_unmatched_brackets() { + let p = project() + .file("src/lib.rs", "") + .file( + ".cargo/config.toml", + r#" + [build] + build-dir = "foo/{bar" + "#, + ) + .build(); + + p.cargo("build -Z build-dir") + .masquerade_as_nightly_cargo(&["build-dir"]) + .run(); + + let p = project() + .file("src/lib.rs", "") + .file( + ".cargo/config.toml", + r#" + [build] + build-dir = "foo/}bar" + "#, + ) + .build(); + + p.cargo("build -Z build-dir") + .masquerade_as_nightly_cargo(&["build-dir"]) + .run(); +} + fn parse_workspace_manifest_path_hash(hash_dir: &PathBuf) -> PathBuf { // Since the hash will change between test runs simply find the first directories and assume // that is the hash dir. The format is a 2 char directory followed by the remaining hash in the