summaryrefslogtreecommitdiffstats
path: root/src/clean_test.cc
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2014-05-21 22:07:47 (GMT)
committerNico Weber <thakis@chromium.org>2014-05-21 22:18:01 (GMT)
commitbc239cca4f3f0757ba34d0306fbc2a2b75d067a2 (patch)
treee01abd5130c1e0f7ecca0dc0f0a24e8b9113dc0f /src/clean_test.cc
parent7103c32646df958b0287c65b1c660bf528a191d6 (diff)
downloadNinja-bc239cca4f3f0757ba34d0306fbc2a2b75d067a2.zip
Ninja-bc239cca4f3f0757ba34d0306fbc2a2b75d067a2.tar.gz
Ninja-bc239cca4f3f0757ba34d0306fbc2a2b75d067a2.tar.bz2
Make "depfile=$out.d" work if $out contains escaped characters, rspfile too.
Fixes #730. This has always been broken, but due to #690 more paths are now escaped (e.g. paths containing + characters, like file.c++). Also see discussion in #689. The approach is to give EdgeEnv an enum deciding on whether or not to escape file names, and provide functions that evaluate depfile and rspfile with that set that to kNoEscape. (depfile=$out.d doesn't make sense on edges with multiple outputs.) This should be relatively safe, as $in and $out can't be used on edges, only on rules (#687).
Diffstat (limited to 'src/clean_test.cc')
-rw-r--r--src/clean_test.cc28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/clean_test.cc b/src/clean_test.cc
index 4a00fd8..5869bbb 100644
--- a/src/clean_test.cc
+++ b/src/clean_test.cc
@@ -368,3 +368,31 @@ TEST_F(CleanTest, CleanPhony) {
EXPECT_EQ(2, cleaner.cleaned_files_count());
EXPECT_NE(0, fs_.Stat("phony"));
}
+
+TEST_F(CleanTest, CleanDepFileAndRspFileWithSpaces) {
+ ASSERT_NO_FATAL_FAILURE(AssertParse(&state_,
+"rule cc_dep\n"
+" command = cc $in > $out\n"
+" depfile = $out.d\n"
+"rule cc_rsp\n"
+" command = cc $in > $out\n"
+" rspfile = $out.rsp\n"
+" rspfile_content = $in\n"
+"build out$ 1: cc_dep in$ 1\n"
+"build out$ 2: cc_rsp in$ 1\n"
+));
+ fs_.Create("out 1", "");
+ fs_.Create("out 2", "");
+ fs_.Create("out 1.d", "");
+ fs_.Create("out 2.rsp", "");
+
+ Cleaner cleaner(&state_, config_, &fs_);
+ EXPECT_EQ(0, cleaner.CleanAll());
+ EXPECT_EQ(4, cleaner.cleaned_files_count());
+ EXPECT_EQ(4u, fs_.files_removed_.size());
+
+ EXPECT_EQ(0, fs_.Stat("out 1"));
+ EXPECT_EQ(0, fs_.Stat("out 2"));
+ EXPECT_EQ(0, fs_.Stat("out 1.d"));
+ EXPECT_EQ(0, fs_.Stat("out 2.rsp"));
+}