18 #include <gtest/gtest.h>
55 void Create(
const std::string& path,
const std::string& contents);
64 TimeStamp Stat(
const std::string& path, std::string* err)
const override;
65 bool WriteFile(
const std::string& path,
const std::string& contents,
67 bool MakeDir(
const std::string& path)
override;
69 std::string* err)
override;
70 int RemoveFile(
const std::string& path)
override;
81 typedef std::map<std::string, Entry>
FileMap;
Interface for accessing the disk.
Information about a node in the dependency graph: the file, whether it's dirty, mtime,...
A class that records a file path and ensures that it is removed on destruction.
ScopedFilePath(const char *path)
void Release()
Release the file, the destructor will not remove the file.
const std::string & path() const
const char * c_str() const
ScopedFilePath(const std::string &path)
Constructor just records the file path.
void CreateAndEnter(const std::string &name)
Create a temporary directory and chdir into it.
std::string start_dir_
The temp directory containing our dir.
std::string temp_dir_name_
The subdirectory name for our dir, or empty if it hasn't been set up.
void Cleanup()
Clean up the temporary directory.
A base test fixture that includes a State object with a builtin "cat" rule.
void AddCatRule(State *state)
Add a "cat" rule to state.
StateTestWithBuiltinRules()
Node * GetNode(const std::string &path)
Short way to get a Node by its path from state_.
Global state (file status) for a single run.
Abstract interface to object that tracks the status of a build: completion fraction,...
An entry for a single in-memory file.
An implementation of DiskInterface that uses an in-memory representation of disk state.
bool WriteFile(const std::string &path, const std::string &contents, bool) override
Create a file, with the specified name and contents If crlf_on_windows is true, will be converted t...
std::map< std::string, Entry > FileMap
bool MakeDir(const std::string &path) override
Create a directory, returning false on failure.
int RemoveFile(const std::string &path) override
Remove the file named path.
Status ReadFile(const std::string &path, std::string *contents, std::string *err) override
Read and store in given string.
TimeStamp Stat(const std::string &path, std::string *err) const override
stat() a file, returning the mtime, or 0 if missing and -1 on other errors.
std::set< std::string > files_removed_
int Tick()
Tick "time" forwards; subsequent file operations will be newer than previous ones.
int now_
A simple fake timestamp for file operations.
std::set< std::string > files_created_
std::vector< std::string > files_read_
void Create(const std::string &path, const std::string &contents)
"Create" a file with contents.
std::vector< std::string > directories_made_
void AssertHash(const char *expected, uint64_t actual)
void AssertParse(State *state, const char *input, ManifestParserOptions=ManifestParserOptions())
void VerifyGraph(const State &state)
unsigned long long uint64_t