|
Ninja
|
An implementation of DiskInterface that uses an in-memory representation of disk state. More...
#include <test.h>

Classes | |
| struct | Entry |
| An entry for a single in-memory file. More... | |
Public Types | |
| typedef map< string, Entry > | FileMap |
| enum | Status { Okay, NotFound, OtherError } |
| Result of ReadFile. More... | |
Public Member Functions | |
| void | Create (const string &path, const string &contents) |
| "Create" a file with contents. More... | |
| virtual bool | MakeDir (const string &path) |
| Create a directory, returning false on failure. More... | |
| bool | MakeDirs (const string &path) |
Create all the parent directories for path; like mkdir -p basename path. More... | |
| virtual Status | ReadFile (const string &path, string *contents, string *err) |
| Read and store in given string. More... | |
| virtual int | RemoveFile (const string &path) |
| Remove the file named path. More... | |
| virtual TimeStamp | Stat (const string &path, string *err) const |
| stat() a file, returning the mtime, or 0 if missing and -1 on other errors. More... | |
| int | Tick () |
| Tick "time" forwards; subsequent file operations will be newer than previous ones. More... | |
| VirtualFileSystem () | |
| virtual bool | WriteFile (const string &path, const string &contents) |
| Create a file, with the specified name and contents Returns true on success, false on failure. More... | |
Public Attributes | |
| vector< string > | directories_made_ |
| FileMap | files_ |
| set< string > | files_created_ |
| vector< string > | files_read_ |
| set< string > | files_removed_ |
| int | now_ |
| A simple fake timestamp for file operations. More... | |
An implementation of DiskInterface that uses an in-memory representation of disk state.
It also logs file accesses and directory creations so it can be used by tests to verify disk access patterns.
| typedef map<string, Entry> VirtualFileSystem::FileMap |
|
inherited |
Result of ReadFile.
| Enumerator | |
|---|---|
| Okay | |
| NotFound | |
| OtherError | |
Definition at line 30 of file disk_interface.h.
| void VirtualFileSystem::Create | ( | const string & | path, |
| const string & | contents | ||
| ) |
"Create" a file with contents.
Definition at line 143 of file test.cc.
References files_, files_created_, and now_.
Referenced by BuildTest::SetUp(), FakeCommandRunner::StartCommand(), and WriteFile().
|
virtual |
Create a directory, returning false on failure.
Implements DiskInterface.
Definition at line 164 of file test.cc.
References directories_made_.
|
inherited |
Create all the parent directories for path; like mkdir -p basename path.
Definition at line 134 of file disk_interface.cc.
References Error(), DiskInterface::MakeDir(), and DiskInterface::Stat().
Referenced by Builder::StartEdge().
|
virtual |
Read and store in given string.
On success, return Okay. On error, return another Status and fill |err|.
Implements FileReader.
Definition at line 169 of file test.cc.
References files_, files_read_, FileReader::NotFound, and FileReader::Okay.
|
virtual |
Remove the file named path.
It behaves like 'rm -f path' so no errors are reported if it does not exists.
Implements DiskInterface.
Definition at line 182 of file test.cc.
References directories_made_, files_, and files_removed_.
|
virtual |
stat() a file, returning the mtime, or 0 if missing and -1 on other errors.
Implements DiskInterface.
Definition at line 150 of file test.cc.
References files_.
|
inline |
|
virtual |
Create a file, with the specified name and contents Returns true on success, false on failure.
Implements DiskInterface.
Definition at line 159 of file test.cc.
References Create().
| vector<string> VirtualFileSystem::directories_made_ |
Definition at line 160 of file test.h.
Referenced by MakeDir(), and RemoveFile().
| FileMap VirtualFileSystem::files_ |
Definition at line 163 of file test.h.
Referenced by Create(), ReadFile(), RemoveFile(), and Stat().
| set<string> VirtualFileSystem::files_created_ |
| vector<string> VirtualFileSystem::files_read_ |
Definition at line 161 of file test.h.
Referenced by ReadFile().
| set<string> VirtualFileSystem::files_removed_ |
Definition at line 164 of file test.h.
Referenced by RemoveFile().
| int VirtualFileSystem::now_ |
A simple fake timestamp for file operations.
Definition at line 168 of file test.h.
Referenced by Create(), Tick(), and FakeCommandRunner::WaitForCommand().
1.8.14