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

Side by Side Diff: grit/tool/build_unittest.py

Issue 407693002: Fix .d file outputs, add support for asserting outputs. (Closed) Base URL: https://chromium.googlesource.com/external/grit-i18n.git@master
Patch Set: now with tests Created 6 years, 5 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 unified diff | Download patch
« grit/tool/build.py ('K') | « grit/tool/build.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 os 9 import os
10 import sys 10 import sys
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 self.verbose = False 42 self.verbose = False
43 self.extra_verbose = False 43 self.extra_verbose = False
44 expected_dep_file = os.path.join(output_dir, 'substitute.grd.d') 44 expected_dep_file = os.path.join(output_dir, 'substitute.grd.d')
45 builder.Run(DummyOpts(), ['-o', output_dir, 45 builder.Run(DummyOpts(), ['-o', output_dir,
46 '--depdir', output_dir, 46 '--depdir', output_dir,
47 '--depfile', expected_dep_file]) 47 '--depfile', expected_dep_file])
48 48
49 self.failUnless(os.path.isfile(expected_dep_file)) 49 self.failUnless(os.path.isfile(expected_dep_file))
50 with open(expected_dep_file) as f: 50 with open(expected_dep_file) as f:
51 line = f.readline() 51 line = f.readline()
52 (dep_file_name, deps_string) = line.split(': ') 52 (dep_output_file, deps_string) = line.split(': ')
53 deps = deps_string.split(' ') 53 deps = deps_string.split(' ')
54 self.failUnlessEqual(os.path.abspath(expected_dep_file), 54
55 os.path.abspath(os.path.join(output_dir, dep_file_name)), 55 self.failUnlessEqual("resource.h", dep_output_file)
56 "depfile should refer to itself as the depended upon file")
57 self.failUnlessEqual(1, len(deps)) 56 self.failUnlessEqual(1, len(deps))
58 self.failUnlessEqual(deps[0], 57 self.failUnlessEqual(deps[0],
59 util.PathFromRoot('grit/testdata/substitute.xmb')) 58 util.PathFromRoot('grit/testdata/substitute.xmb'))
60 59
60 def testAssertOutputs(self):
61 output_dir = tempfile.mkdtemp()
62 class DummyOpts(object):
63 def __init__(self):
64 self.input = util.PathFromRoot('grit/testdata/substitute.grd')
65 self.verbose = False
66 self.extra_verbose = False
67
68 # Incomplete output file list should fail.
69 builder_fail = build.RcBuilder()
70 self.failUnlessEqual(2,
71 builder_fail.Run(DummyOpts(), [
72 '-o', output_dir,
73 '-a', os.path.abspath(
74 os.path.join(output_dir, 'en_generated_resources.rc'))]))
75
76 # Complete output file list should succeed.
77 builder_ok = build.RcBuilder()
78 self.failUnlessEqual(0,
79 builder_ok.Run(DummyOpts(), [
80 '-o', output_dir,
81 '-a', os.path.abspath(
82 os.path.join(output_dir, 'en_generated_resources.rc')),
83 '-a', os.path.abspath(
84 os.path.join(output_dir, 'sv_generated_resources.rc')),
85 '-a', os.path.abspath(
86 os.path.join(output_dir, 'resource.h'))]))
61 87
62 if __name__ == '__main__': 88 if __name__ == '__main__':
63 unittest.main() 89 unittest.main()
OLDNEW
« 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