summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuilhem Charles <guilhem.charles@gmail.com>2019-01-12 13:35:44 +0100
committerGuilhem Charles <guilhem.charles@gmail.com>2019-01-13 11:34:26 +0100
commitcfd0bd3007b291df505f8c45083453310142d681 (patch)
treec13438e446ccd23d2f212dda8f5cb586e0a3172d
parent6e02ebc4b5947095fa64b5bf814f14dd6f6f6a9a (diff)
downloadninja-cfd0bd3007b291df505f8c45083453310142d681.tar.gz
1492 add column headers to .ninja_log
-rw-r--r--src/build_log.cc4
-rw-r--r--src/build_log_test.cc9
2 files changed, 8 insertions, 5 deletions
diff --git a/src/build_log.cc b/src/build_log.cc
index c4a08a0..774f72f 100644
--- a/src/build_log.cc
+++ b/src/build_log.cc
@@ -49,6 +49,7 @@
namespace {
const char kFileSignature[] = "# ninja log v%d\n";
+const char kFileColumnLabels[] = "# start_time end_time mtime command hash\n";
const int kOldestSupportedVersion = 4;
const int kCurrentVersion = 5;
@@ -144,7 +145,8 @@ bool BuildLog::OpenForWrite(const string& path, const BuildLogUser& user,
fseek(log_file_, 0, SEEK_END);
if (ftell(log_file_) == 0) {
- if (fprintf(log_file_, kFileSignature, kCurrentVersion) < 0) {
+ if (fprintf(log_file_, kFileSignature, kCurrentVersion) < 0 ||
+ fprintf(log_file_, kFileColumnLabels) < 0) {
*err = strerror(errno);
return false;
}
diff --git a/src/build_log_test.cc b/src/build_log_test.cc
index ad30380..eea818f 100644
--- a/src/build_log_test.cc
+++ b/src/build_log_test.cc
@@ -70,8 +70,9 @@ TEST_F(BuildLogTest, WriteRead) {
}
TEST_F(BuildLogTest, FirstWriteAddsSignature) {
- const char kExpectedVersion[] = "# ninja log vX\n";
- const size_t kVersionPos = strlen(kExpectedVersion) - 2; // Points at 'X'.
+ const char kExpectedContent[] = "# ninja log vX\n"
+ "# start_time end_time mtime command hash\n";
+ const size_t kVersionPos = 13; // Points at 'X'.
BuildLog log;
string contents, err;
@@ -84,7 +85,7 @@ TEST_F(BuildLogTest, FirstWriteAddsSignature) {
ASSERT_EQ("", err);
if (contents.size() >= kVersionPos)
contents[kVersionPos] = 'X';
- EXPECT_EQ(kExpectedVersion, contents);
+ EXPECT_EQ(kExpectedContent, contents);
// Opening the file anew shouldn't add a second version string.
EXPECT_TRUE(log.OpenForWrite(kTestFilename, *this, &err));
@@ -96,7 +97,7 @@ TEST_F(BuildLogTest, FirstWriteAddsSignature) {
ASSERT_EQ("", err);
if (contents.size() >= kVersionPos)
contents[kVersionPos] = 'X';
- EXPECT_EQ(kExpectedVersion, contents);
+ EXPECT_EQ(kExpectedContent, contents);
}
TEST_F(BuildLogTest, DoubleEntry) {