OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 '''Unit tests for the 'grit build' tool. | 6 '''Unit tests for the 'grit build' tool. |
7 ''' | 7 ''' |
8 | 8 |
9 import codecs | 9 import codecs |
10 import os | 10 import os |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
238 'IDR_STRUCTURE_IN_FALSE_IF_NOT_WHITELISTED', | 238 'IDR_STRUCTURE_IN_FALSE_IF_NOT_WHITELISTED', |
239 'IDR_INCLUDE_NOT_WHITELISTED', | 239 'IDR_INCLUDE_NOT_WHITELISTED', |
240 ] | 240 ] |
241 for output_file in (header, map_cc): | 241 for output_file in (header, map_cc): |
242 self._verifyWhitelistedOutput( | 242 self._verifyWhitelistedOutput( |
243 output_file, | 243 output_file, |
244 whitelisted_ids, | 244 whitelisted_ids, |
245 non_whitelisted_ids, | 245 non_whitelisted_ids, |
246 ) | 246 ) |
247 | 247 |
248 def testWriteOnlyNew(self): | |
249 import time | |
250 output_dir = tempfile.mkdtemp() | |
251 builder = build.RcBuilder() | |
252 class DummyOpts(object): | |
253 def __init__(self): | |
254 self.input = util.PathFromRoot('grit/testdata/substitute.grd') | |
255 self.verbose = False | |
256 self.extra_verbose = False | |
257 builder.Run(DummyOpts(), ['-o', output_dir]) | |
258 header = os.path.join(output_dir, 'resource.h') | |
259 self.failUnless(os.path.exists(header)) | |
260 first_mtime = os.stat(header).st_mtime | |
261 | |
262 mtime_resolution = 2 if sys.platform == 'win32' else 1 | |
263 | |
264 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 :-/
| |
265 builder.Run(DummyOpts(), ['-o', output_dir]) | |
266 self.failUnless(os.path.exists(header)) | |
267 second_mtime = os.stat(header).st_mtime | |
268 | |
269 time.sleep(mtime_resolution) | |
270 builder.Run(DummyOpts(), ['-o', output_dir, '--write-only-new']) | |
271 self.failUnless(os.path.exists(header)) | |
272 third_mtime = os.stat(header).st_mtime | |
273 | |
274 self.assertNotEqual(first_mtime, second_mtime) | |
275 self.assertEqual(second_mtime, third_mtime) | |
276 | |
248 | 277 |
249 if __name__ == '__main__': | 278 if __name__ == '__main__': |
250 unittest.main() | 279 unittest.main() |
OLD | NEW |