summaryrefslogtreecommitdiffstats
path: root/src/test.h
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2013-04-08 21:05:27 (GMT)
committerEvan Martin <martine@danga.com>2013-04-08 21:18:50 (GMT)
commit29e76bc16dc5e1b50e6afc8fe1614259bb53cbd1 (patch)
tree33f1824c843f654fede56292974ba1c33f60b42b /src/test.h
parent28411da9014bc780784e63ce2411fe9070c8caf1 (diff)
downloadNinja-29e76bc16dc5e1b50e6afc8fe1614259bb53cbd1.zip
Ninja-29e76bc16dc5e1b50e6afc8fe1614259bb53cbd1.tar.gz
Ninja-29e76bc16dc5e1b50e6afc8fe1614259bb53cbd1.tar.bz2
move test virtual time "now_" into VirtualFileSystem
It's the only piece that cares about the current time.
Diffstat (limited to 'src/test.h')
-rw-r--r--src/test.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/test.h b/src/test.h
index 37ca1f9..bff0e5a 100644
--- a/src/test.h
+++ b/src/test.h
@@ -41,8 +41,16 @@ void AssertHash(const char* expected, uint64_t actual);
/// of disk state. It also logs file accesses and directory creations
/// so it can be used by tests to verify disk access patterns.
struct VirtualFileSystem : public DiskInterface {
- /// "Create" a file with a given mtime and contents.
- void Create(const string& path, int time, const string& contents);
+ VirtualFileSystem() : now_(1) {}
+
+ /// "Create" a file with contents.
+ void Create(const string& path, const string& contents);
+
+ /// Tick "time" forwards; subsequent file operations will be newer than
+ /// previous ones.
+ int Tick() {
+ return ++now_;
+ }
// DiskInterface
virtual TimeStamp Stat(const string& path);
@@ -63,6 +71,9 @@ struct VirtualFileSystem : public DiskInterface {
FileMap files_;
set<string> files_removed_;
set<string> files_created_;
+
+ /// A simple fake timestamp for file operations.
+ int now_;
};
struct ScopedTempDir {