Permalink
Browse files

later entry in build log should overwrite earlier one

  • Loading branch information...
1 parent e5ae916 commit 681de18033236071e822ca709d912d32cd4b2f83 @evmar evmar committed Jan 7, 2011
Showing with 17 additions and 1 deletion.
  1. +1 −1 src/build_log.cc
  2. +16 −0 src/build_log_test.cc
View
2 src/build_log.cc
@@ -76,7 +76,7 @@ bool BuildLog::Load(const string& path, string* err) {
start = end + 1;
end = strchr(start, '\n');
entry->command = string(start, end - start);
- log_.insert(make_pair(entry->output, entry));
+ log_[entry->output] = entry;
}
return true;
View
16 src/build_log_test.cc
@@ -41,3 +41,19 @@ TEST_F(BuildLogTest, WriteRead) {
ASSERT_EQ(15, e1->time_ms);
ASSERT_EQ("out", e1->output);
}
+
+TEST_F(BuildLogTest, DoubleEntry) {
+ FILE* f = fopen(log_filename_.c_str(), "wb");
+ fprintf(f, "0 out command abc\n");
+ fprintf(f, "0 out command def\n");
+ fclose(f);
+
+ string err;
+ BuildLog log;
+ EXPECT_TRUE(log.Load(log_filename_, &err));
+ ASSERT_EQ("", err);
+
+ BuildLog::LogEntry* e = log.LookupByOutput("out");
+ ASSERT_TRUE(e);
+ ASSERT_EQ("command def", e->command);
+}

0 comments on commit 681de18

Please sign in to comment.