Skip to content
This repository
Browse code

later entry in build log should overwrite earlier one

  • Loading branch information...
commit 681de18033236071e822ca709d912d32cd4b2f83 1 parent e5ae916
Evan Martin authored January 07, 2011
2  src/build_log.cc
@@ -76,7 +76,7 @@ bool BuildLog::Load(const string& path, string* err) {
76 76
     start = end + 1;
77 77
     end = strchr(start, '\n');
78 78
     entry->command = string(start, end - start);
79  
-    log_.insert(make_pair(entry->output, entry));
  79
+    log_[entry->output] = entry;
80 80
   }
81 81
 
82 82
   return true;
16  src/build_log_test.cc
@@ -41,3 +41,19 @@ TEST_F(BuildLogTest, WriteRead) {
41 41
   ASSERT_EQ(15, e1->time_ms);
42 42
   ASSERT_EQ("out", e1->output);
43 43
 }
  44
+
  45
+TEST_F(BuildLogTest, DoubleEntry) {
  46
+  FILE* f = fopen(log_filename_.c_str(), "wb");
  47
+  fprintf(f, "0 out command abc\n");
  48
+  fprintf(f, "0 out command def\n");
  49
+  fclose(f);
  50
+
  51
+  string err;
  52
+  BuildLog log;
  53
+  EXPECT_TRUE(log.Load(log_filename_, &err));
  54
+  ASSERT_EQ("", err);
  55
+
  56
+  BuildLog::LogEntry* e = log.LookupByOutput("out");
  57
+  ASSERT_TRUE(e);
  58
+  ASSERT_EQ("command def", e->command);
  59
+}

0 notes on commit 681de18

Please sign in to comment.
Something went wrong with that request. Please try again.