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 output_dir = tempfile.mkdtemp() | |
250 builder = build.RcBuilder() | |
251 class DummyOpts(object): | |
252 def __init__(self): | |
253 self.input = util.PathFromRoot('grit/testdata/substitute.grd') | |
254 self.verbose = False | |
255 self.extra_verbose = False | |
256 UNCHANGED = 10 | |
257 header = os.path.join(output_dir, 'resource.h') | |
258 | |
259 builder.Run(DummyOpts(), ['-o', output_dir]) | |
260 self.failUnless(os.path.exists(header)) | |
261 first_mtime = os.stat(header).st_mtime | |
262 | |
263 os.utime(header, (UNCHANGED, UNCHANGED)) | |
264 builder.Run(DummyOpts(), ['-o', output_dir, '--write-only-new', '0']) | |
265 self.failUnless(os.path.exists(header)) | |
266 second_mtime = os.stat(header).st_mtime | |
267 | |
268 os.utime(header, (UNCHANGED, UNCHANGED)) | |
269 builder.Run(DummyOpts(), ['-o', output_dir, '--write-only-new', '1']) | |
270 self.failUnless(os.path.exists(header)) | |
271 third_mtime = os.stat(header).st_mtime | |
272 | |
273 self.assertTrue(abs(second_mtime - UNCHANGED) > 5) | |
274 self.assertTrue(abs(second_mtime - first_mtime) < 5) | |
newt (away)
2014/12/04 22:45:22
What's the purpose of this line? It seems only to
Nico
2014/12/04 22:47:49
Yeah, I guess it's not very different from the lin
| |
275 self.assertTrue(abs(third_mtime - UNCHANGED) < 5) | |
276 | |
248 | 277 |
249 if __name__ == '__main__': | 278 if __name__ == '__main__': |
250 unittest.main() | 279 unittest.main() |
OLD | NEW |