Browse files

remove tempnam

  • Loading branch information...
1 parent 13977a2 commit 667f48b5ef5cdda883488cf5e07d75744d76c919 @evmar evmar committed Jan 9, 2011
Showing with 7 additions and 8 deletions.
  1. +7 −8 src/build_log_test.cc
View
15 src/build_log_test.cc
@@ -2,15 +2,14 @@
#include "test.h"
+static const char kTestFilename[] = "BuildLogTest-tempfile";
+
struct BuildLogTest : public StateTestWithBuiltinRules {
virtual void SetUp() {
- log_filename_ = tempnam(NULL, "ninja");
}
virtual void TearDown() {
- unlink(log_filename_.c_str());
+ unlink(kTestFilename);
}
-
- string log_filename_;
};
TEST_F(BuildLogTest, WriteRead) {
@@ -20,14 +19,14 @@ TEST_F(BuildLogTest, WriteRead) {
BuildLog log1;
string err;
- EXPECT_TRUE(log1.OpenForWrite(log_filename_, &err));
+ EXPECT_TRUE(log1.OpenForWrite(kTestFilename, &err));
ASSERT_EQ("", err);
log1.RecordCommand(state_.edges_[0], 15);
log1.RecordCommand(state_.edges_[1], 20);
log1.Close();
BuildLog log2;
- EXPECT_TRUE(log2.Load(log_filename_, &err));
+ EXPECT_TRUE(log2.Load(kTestFilename, &err));
ASSERT_EQ("", err);
ASSERT_EQ(2, log1.log_.size());
@@ -42,14 +41,14 @@ TEST_F(BuildLogTest, WriteRead) {
}
TEST_F(BuildLogTest, DoubleEntry) {
- FILE* f = fopen(log_filename_.c_str(), "wb");
+ FILE* f = fopen(kTestFilename, "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));
+ EXPECT_TRUE(log.Load(kTestFilename, &err));
ASSERT_EQ("", err);
BuildLog::LogEntry* e = log.LookupByOutput("out");

0 comments on commit 667f48b

Please sign in to comment.