|
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 std::map< std::string, Entry > | FileMap |
| enum | Status { Okay , NotFound , OtherError } |
| Result of ReadFile. More... | |
Public Member Functions | |
| void | Create (const std::string &path, const std::string &contents) |
| "Create" a file with contents. | |
| bool | MakeDir (const std::string &path) override |
| Create a directory, returning false on failure. | |
| bool | MakeDirs (const std::string &path) |
Create all the parent directories for path; like mkdir -p basename path. | |
| Status | ReadFile (const std::string &path, std::string *contents, std::string *err) override |
| Read and store in given string. | |
| int | RemoveFile (const std::string &path) override |
| Remove the file named path. | |
| 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. | |
| int | Tick () |
| Tick "time" forwards; subsequent file operations will be newer than previous ones. | |
| VirtualFileSystem () | |
| 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 to \r (only on Windows builds of Ninja). | |
Public Attributes | |
| std::vector< std::string > | directories_made_ |
| FileMap | files_ |
| std::set< std::string > | files_created_ |
| std::vector< std::string > | files_read_ |
| std::set< std::string > | files_removed_ |
| int | now_ |
| A simple fake timestamp for file operations. | |
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 std::map<std::string, Entry> VirtualFileSystem::FileMap |
|
inherited |
Result of ReadFile.
| Enumerator | |
|---|---|
| Okay | |
| NotFound | |
| OtherError | |
Definition at line 29 of file disk_interface.h.
|
inline |
| void VirtualFileSystem::Create | ( | const std::string & | path, |
| const std::string & | contents ) |
"Create" a file with contents.
Definition at line 145 of file test.cc.
References files_, files_created_, and now_.
Referenced by TestPhonyUseCase(), and WriteFile().
|
overridevirtual |
Create a directory, returning false on failure.
Implements DiskInterface.
Definition at line 167 of file test.cc.
References directories_made_.
|
inherited |
Create all the parent directories for path; like mkdir -p basename path.
Definition at line 140 of file disk_interface.cc.
References Error(), MakeDir(), MakeDirs(), and Stat().
Referenced by MakeDirs().
|
overridevirtual |
Read and store in given string.
On success, return Okay. On error, return another Status and fill |err|.
Implements FileReader.
Definition at line 172 of file test.cc.
References files_, files_read_, FileReader::NotFound, and FileReader::Okay.
|
overridevirtual |
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 185 of file test.cc.
References directories_made_, files_, and files_removed_.
|
overridevirtual |
stat() a file, returning the mtime, or 0 if missing and -1 on other errors.
Implements DiskInterface.
Definition at line 152 of file test.cc.
References files_.
|
inline |
Tick "time" forwards; subsequent file operations will be newer than previous ones.
Definition at line 59 of file test.h.
References now_.
Referenced by TestPhonyUseCase().
|
overridevirtual |
Create a file, with the specified name and contents If crlf_on_windows is true,
will be converted to \r
(only on Windows builds of Ninja).
Returns true on success, false on failure
Implements DiskInterface.
Definition at line 161 of file test.cc.
References Create().
| std::vector<std::string> VirtualFileSystem::directories_made_ |
Definition at line 79 of file test.h.
Referenced by MakeDir(), and RemoveFile().
| FileMap VirtualFileSystem::files_ |
Definition at line 82 of file test.h.
Referenced by Create(), ReadFile(), RemoveFile(), and Stat().
| std::set<std::string> VirtualFileSystem::files_created_ |
| std::vector<std::string> VirtualFileSystem::files_read_ |
Definition at line 80 of file test.h.
Referenced by ReadFile().
| std::set<std::string> VirtualFileSystem::files_removed_ |
Definition at line 83 of file test.h.
Referenced by RemoveFile().
| int VirtualFileSystem::now_ |
A simple fake timestamp for file operations.
Definition at line 87 of file test.h.
Referenced by Create(), TestPhonyUseCase(), Tick(), and VirtualFileSystem().