Index: grit/tool/build_unittest.py |
=================================================================== |
--- grit/tool/build_unittest.py (revision 182) |
+++ grit/tool/build_unittest.py (working copy) |
@@ -245,6 +245,35 @@ |
non_whitelisted_ids, |
) |
+ def testWriteOnlyNew(self): |
+ import time |
+ output_dir = tempfile.mkdtemp() |
+ builder = build.RcBuilder() |
+ class DummyOpts(object): |
+ def __init__(self): |
+ self.input = util.PathFromRoot('grit/testdata/substitute.grd') |
+ self.verbose = False |
+ self.extra_verbose = False |
+ builder.Run(DummyOpts(), ['-o', output_dir]) |
+ header = os.path.join(output_dir, 'resource.h') |
+ self.failUnless(os.path.exists(header)) |
+ first_mtime = os.stat(header).st_mtime |
+ mtime_resolution = 2 if sys.platform == 'win32' else 1 |
+ |
+ time.sleep(mtime_resolution) |
newt (away)
2014/12/04 22:09:42
Is there a way do this without sleeping for 1 or 2
Nico
2014/12/04 22:33:07
Yeah, I was pretty unhappy with this too :-/
|
+ builder.Run(DummyOpts(), ['-o', output_dir]) |
+ self.failUnless(os.path.exists(header)) |
+ second_mtime = os.stat(header).st_mtime |
+ |
+ time.sleep(mtime_resolution) |
+ builder.Run(DummyOpts(), ['-o', output_dir, '--write-only-new']) |
+ self.failUnless(os.path.exists(header)) |
+ third_mtime = os.stat(header).st_mtime |
+ |
+ self.assertNotEqual(first_mtime, second_mtime) |
+ self.assertEqual(second_mtime, third_mtime) |
+ |
+ |
if __name__ == '__main__': |
unittest.main() |