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

Unified Diff: grit/tool/build_unittest.py

Issue 997813004: Allow depfile to depend on a Stamp file instead of the default first input. (Closed) Base URL: https://chromium.googlesource.com/external/grit-i18n.git@master
Patch Set: +hack Created 5 years, 9 months 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
« no previous file with comments | « 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
diff --git a/grit/tool/build_unittest.py b/grit/tool/build_unittest.py
index d35778334218e3723e9f43c19afc43f1ad5c7249..bf657249871081c0aec477d3a11a5dd44932d06a 100644
--- a/grit/tool/build_unittest.py
+++ b/grit/tool/build_unittest.py
@@ -301,6 +301,53 @@ class BuildUnittest(unittest.TestCase):
self.assertTrue(abs(second_mtime - UNCHANGED) > 5)
self.assertTrue(abs(third_mtime - UNCHANGED) < 5)
+ def testGenerateDepFileWithDependOnStamp(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
+ expected_dep_file_name = 'substitute.grd.d'
+ expected_stamp_file_name = expected_dep_file_name + '.stamp'
+ expected_dep_file = os.path.join(output_dir, expected_dep_file_name)
+ expected_stamp_file = os.path.join(output_dir, expected_stamp_file_name)
+ if os.path.isfile(expected_stamp_file):
+ os.remove(expected_stamp_file)
+ builder.Run(DummyOpts(), ['-o', output_dir,
+ '--depdir', output_dir,
+ '--depfile', expected_dep_file,
+ '--depend-on-stamp'])
+ self.failUnless(os.path.isfile(expected_stamp_file))
+ first_mtime = os.stat(expected_stamp_file).st_mtime
+
+ # Reset mtime to very old.
+ OLDTIME = 10
+ os.utime(expected_stamp_file, (OLDTIME, OLDTIME))
+
+ builder.Run(DummyOpts(), ['-o', output_dir,
+ '--depdir', output_dir,
+ '--depfile', expected_dep_file,
+ '--depend-on-stamp'])
+ self.failUnless(os.path.isfile(expected_stamp_file))
+ second_mtime = os.stat(expected_stamp_file).st_mtime
+
+ # Some OS have a 2s stat resolution window, so can't do a direct comparison.
+ self.assertTrue((second_mtime - OLDTIME) > 5)
+ self.assertTrue(abs(second_mtime - first_mtime) < 5)
+
+ self.failUnless(os.path.isfile(expected_dep_file))
+ with open(expected_dep_file) as f:
+ line = f.readline()
+ (dep_output_file, deps_string) = line.split(': ')
+ deps = deps_string.split(' ')
+
+ self.failUnlessEqual(expected_stamp_file_name, dep_output_file)
+ self.failUnlessEqual(1, len(deps))
+ self.failUnlessEqual(deps[0],
+ util.PathFromRoot('grit/testdata/substitute.xmb'))
+
if __name__ == '__main__':
unittest.main()
« no previous file with comments | « grit/tool/build.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698