Skip to content

Commit

Permalink
[adapt tests]
Browse files Browse the repository at this point in the history
  • Loading branch information
kinke committed Jun 1, 2023
1 parent 82fab67 commit 2a286bb
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/build_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1637,6 +1637,8 @@ TEST_F(BuildWithLogTest, ImplicitGeneratedOutOfDate2) {
EXPECT_FALSE(GetNode("out.imp")->dirty());
}

#define SYMMETRY 1

TEST_F(BuildWithLogTest, NotInLogButOnDisk) {
ASSERT_NO_FATAL_FAILURE(AssertParse(&state_,
"rule cc\n"
Expand All @@ -1652,6 +1654,9 @@ TEST_F(BuildWithLogTest, NotInLogButOnDisk) {
// Because it's not in the log, it should not be up-to-date until
// we build again.
EXPECT_TRUE(builder_.AddTarget("out1", &err));
#ifdef SYMMETRY
EXPECT_TRUE(builder_.AlreadyUpToDate());
#else
EXPECT_FALSE(builder_.AlreadyUpToDate());

command_runner_.commands_ran_.clear();
Expand All @@ -1660,6 +1665,7 @@ TEST_F(BuildWithLogTest, NotInLogButOnDisk) {
EXPECT_TRUE(builder_.AddTarget("out1", &err));
EXPECT_TRUE(builder_.Build(&err));
EXPECT_TRUE(builder_.AlreadyUpToDate());
#endif
}

TEST_F(BuildWithLogTest, RebuildAfterFailure) {
Expand Down Expand Up @@ -1701,10 +1707,14 @@ TEST_F(BuildWithLogTest, RebuildAfterFailure) {

// Run again, should rerun even though the output file is up to date on disk
EXPECT_TRUE(builder_.AddTarget("out1", &err));
#ifdef SYMMETRY
EXPECT_TRUE(builder_.AlreadyUpToDate());
#else
EXPECT_FALSE(builder_.AlreadyUpToDate());
EXPECT_TRUE(builder_.Build(&err));
EXPECT_EQ(1u, command_runner_.commands_ran_.size());
EXPECT_EQ("", err);
#endif
}

TEST_F(BuildWithLogTest, RebuildWithNoInputs) {
Expand Down Expand Up @@ -1758,6 +1768,9 @@ TEST_F(BuildWithLogTest, RestatTest) {

fs_.Create("in", "");

#ifdef SYMMETRY
string err;
#else
// Do a pre-build so that there's commands in the log for the outputs,
// otherwise, the lack of an entry in the build log will cause out3 to rebuild
// regardless of restat.
Expand All @@ -1774,6 +1787,8 @@ TEST_F(BuildWithLogTest, RestatTest) {
fs_.Tick();

fs_.Create("in", "");
#endif

// "cc" touches out1, so we should build out2. But because "true" does not
// touch out2, we should cancel the build of out3.
EXPECT_TRUE(builder_.AddTarget("out3", &err));
Expand Down Expand Up @@ -3001,7 +3016,11 @@ TEST_F(BuildWithDepsLogTest, RestatMissingDepfileDepslog) {
fs_.Create("header.h", "");

RebuildTarget("out", manifest, "build_log", "ninja_deps");
#ifdef SYMMETRY
ASSERT_EQ(1u, command_runner_.commands_ran_.size());
#else
ASSERT_EQ(2u, command_runner_.commands_ran_.size());
#endif

// Sanity: this rebuild should be NOOP
RebuildTarget("out", manifest, "build_log", "ninja_deps");
Expand Down Expand Up @@ -3639,10 +3658,16 @@ TEST_F(BuildWithLogTest, DyndepBuildDiscoverRestat) {
ASSERT_EQ("", err);
EXPECT_TRUE(builder_.Build(&err));
ASSERT_EQ("", err);
#ifdef SYMMETRY
ASSERT_EQ(2u, command_runner_.commands_ran_.size());
#else
ASSERT_EQ(3u, command_runner_.commands_ran_.size());
#endif
EXPECT_EQ("cp dd-in dd", command_runner_.commands_ran_[0]);
EXPECT_EQ("true", command_runner_.commands_ran_[1]);
#ifndef SYMMETRY
EXPECT_EQ("cat out1 > out2", command_runner_.commands_ran_[2]);
#endif

command_runner_.commands_ran_.clear();
state_.Reset();
Expand Down

0 comments on commit 2a286bb

Please sign in to comment.