Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Unified Diff: grit/tool/build_unittest.py

Issue 757213003: Give build a --write-only-new option. (Closed) Base URL: http://grit-i18n.googlecode.com/svn/trunk/
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« grit/tool/build.py ('K') | « grit/tool/build.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()
« grit/tool/build.py ('K') | « grit/tool/build.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698