Chromium Code Reviews| 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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 294 second_mtime = os.stat(header).st_mtime | 294 second_mtime = os.stat(header).st_mtime |
| 295 | 295 |
| 296 os.utime(header, (UNCHANGED, UNCHANGED)) | 296 os.utime(header, (UNCHANGED, UNCHANGED)) |
| 297 builder.Run(DummyOpts(), ['-o', output_dir, '--write-only-new', '1']) | 297 builder.Run(DummyOpts(), ['-o', output_dir, '--write-only-new', '1']) |
| 298 self.failUnless(os.path.exists(header)) | 298 self.failUnless(os.path.exists(header)) |
| 299 third_mtime = os.stat(header).st_mtime | 299 third_mtime = os.stat(header).st_mtime |
| 300 | 300 |
| 301 self.assertTrue(abs(second_mtime - UNCHANGED) > 5) | 301 self.assertTrue(abs(second_mtime - UNCHANGED) > 5) |
| 302 self.assertTrue(abs(third_mtime - UNCHANGED) < 5) | 302 self.assertTrue(abs(third_mtime - UNCHANGED) < 5) |
| 303 | 303 |
| 304 def testGenerateDepFileWithDependOnStamp(self): | |
| 305 output_dir = tempfile.mkdtemp() | |
| 306 builder = build.RcBuilder() | |
| 307 class DummyOpts(object): | |
| 308 def __init__(self): | |
| 309 self.input = util.PathFromRoot('grit/testdata/substitute.grd') | |
| 310 self.verbose = False | |
| 311 self.extra_verbose = False | |
| 312 expected_dep_file_name = 'substitute.grd.d' | |
| 313 expected_stamp_file_name = expected_dep_file_name + '.stamp' | |
| 314 expected_dep_file = os.path.join(output_dir, expected_dep_file_name) | |
| 315 expected_stamp_file = os.path.join(output_dir, expected_stamp_file_name) | |
| 316 if os.path.isfile(expected_stamp_file): | |
| 317 os.remove(expected_stamp_file) | |
| 318 builder.Run(DummyOpts(), ['-o', output_dir, | |
| 319 '--depdir', output_dir, | |
| 320 '--depfile', expected_dep_file, | |
| 321 '--depend-on-stamp']) | |
| 322 self.failUnless(os.path.isfile(expected_stamp_file)) | |
| 323 first_mtime = os.stat(expected_stamp_file).st_mtime | |
| 324 builder.Run(DummyOpts(), ['-o', output_dir, | |
| 325 '--depdir', output_dir, | |
| 326 '--depfile', expected_dep_file, | |
| 327 '--depend-on-stamp']) | |
| 328 self.failUnless(os.path.isfile(expected_stamp_file)) | |
| 329 second_mtime = os.stat(expected_stamp_file).st_mtime | |
| 330 self.assertTrue(second_mtime > first_mtime) | |
|
Nico
2015/03/23 18:59:35
this fails for me:
==============================
knn
2015/03/23 19:28:14
Oh I see :(
Thanks!
| |
| 331 | |
| 332 self.failUnless(os.path.isfile(expected_dep_file)) | |
| 333 with open(expected_dep_file) as f: | |
| 334 line = f.readline() | |
| 335 (dep_output_file, deps_string) = line.split(': ') | |
| 336 deps = deps_string.split(' ') | |
| 337 | |
| 338 self.failUnlessEqual(expected_stamp_file_name, dep_output_file) | |
| 339 self.failUnlessEqual(1, len(deps)) | |
| 340 self.failUnlessEqual(deps[0], | |
| 341 util.PathFromRoot('grit/testdata/substitute.xmb')) | |
| 342 | |
| 304 | 343 |
| 305 if __name__ == '__main__': | 344 if __name__ == '__main__': |
| 306 unittest.main() | 345 unittest.main() |
| OLD | NEW |