Index: grit/tool/build_unittest.py |
=================================================================== |
--- grit/tool/build_unittest.py (revision 183) |
+++ grit/tool/build_unittest.py (working copy) |
@@ -245,6 +245,34 @@ |
non_whitelisted_ids, |
) |
+ def testWriteOnlyNew(self): |
+ 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 |
+ UNCHANGED = 10 |
+ header = os.path.join(output_dir, 'resource.h') |
+ builder.Run(DummyOpts(), ['-o', output_dir]) |
+ self.failUnless(os.path.exists(header)) |
+ first_mtime = os.stat(header).st_mtime |
+ |
+ os.utime(header, (UNCHANGED, UNCHANGED)) |
+ builder.Run(DummyOpts(), ['-o', output_dir, '--write-only-new', '0']) |
+ self.failUnless(os.path.exists(header)) |
+ second_mtime = os.stat(header).st_mtime |
+ |
+ os.utime(header, (UNCHANGED, UNCHANGED)) |
+ builder.Run(DummyOpts(), ['-o', output_dir, '--write-only-new', '1']) |
+ self.failUnless(os.path.exists(header)) |
+ third_mtime = os.stat(header).st_mtime |
+ |
+ self.assertTrue(abs(second_mtime - UNCHANGED) > 5) |
+ self.assertTrue(abs(third_mtime - UNCHANGED) < 5) |
+ |
+ |
if __name__ == '__main__': |
unittest.main() |