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

Side by Side Diff: tools/generate_stubs/generate_stubs_unittest.py

Issue 332823003: generate_stubs: Allow // comments as well as the existing #. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Back to PS1 Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « tools/generate_stubs/generate_stubs.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 """Unittest for the generate_stubs.py. 6 """Unittest for the generate_stubs.py.
7 7
8 Since generate_stubs.py is a code generator, it is hard to do a very good 8 Since generate_stubs.py is a code generator, it is hard to do a very good
9 test. Instead of creating a golden-file test, which might be flakey, this 9 test. Instead of creating a golden-file test, which might be flakey, this
10 test elects instead to verify that various components "exist" within the 10 test elects instead to verify that various components "exist" within the
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 self.assertRaises(gs.BadSignatureError, gs.ParseSignatures, infile) 109 self.assertRaises(gs.BadSignatureError, gs.ParseSignatures, infile)
110 110
111 def testParseSignatures_CommentsIgnored(self): 111 def testParseSignatures_CommentsIgnored(self):
112 my_sigs = [] 112 my_sigs = []
113 my_sigs.append('# a comment') 113 my_sigs.append('# a comment')
114 my_sigs.append(SIMPLE_SIGNATURES[0][0]) 114 my_sigs.append(SIMPLE_SIGNATURES[0][0])
115 my_sigs.append('# another comment') 115 my_sigs.append('# another comment')
116 my_sigs.append(SIMPLE_SIGNATURES[0][0]) 116 my_sigs.append(SIMPLE_SIGNATURES[0][0])
117 my_sigs.append('# a third comment') 117 my_sigs.append('# a third comment')
118 my_sigs.append(SIMPLE_SIGNATURES[0][0]) 118 my_sigs.append(SIMPLE_SIGNATURES[0][0])
119 my_sigs.append('// a fourth comment')
120 my_sigs.append(SIMPLE_SIGNATURES[0][0])
121 my_sigs.append('//')
122 my_sigs.append(SIMPLE_SIGNATURES[0][0])
119 123
120 file_contents = '\n'.join(my_sigs) 124 file_contents = '\n'.join(my_sigs)
121 infile = StringIO.StringIO(file_contents) 125 infile = StringIO.StringIO(file_contents)
122 signatures = gs.ParseSignatures(infile) 126 signatures = gs.ParseSignatures(infile)
123 self.assertEqual(3, len(signatures)) 127 self.assertEqual(5, len(signatures))
124 128
125 129
126 class WindowsLibUnittest(unittest.TestCase): 130 class WindowsLibUnittest(unittest.TestCase):
127 def testWriteWindowsDefFile(self): 131 def testWriteWindowsDefFile(self):
128 module_name = 'my_module-1' 132 module_name = 'my_module-1'
129 signatures = [sig[1] for sig in SIMPLE_SIGNATURES] 133 signatures = [sig[1] for sig in SIMPLE_SIGNATURES]
130 outfile = StringIO.StringIO() 134 outfile = StringIO.StringIO()
131 gs.WriteWindowsDefFile(module_name, signatures, outfile) 135 gs.WriteWindowsDefFile(module_name, signatures, outfile)
132 contents = outfile.getvalue() 136 contents = outfile.getvalue()
133 137
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 msg='Expected "%s" in %s' % (decl, contents)) 292 msg='Expected "%s" in %s' % (decl, contents))
289 decl = gs.PosixStubWriter.InitializeModuleName(name) 293 decl = gs.PosixStubWriter.InitializeModuleName(name)
290 self.assertTrue(contents.find(decl) != -1, 294 self.assertTrue(contents.find(decl) != -1,
291 msg='Expected "%s" in %s' % (decl, contents)) 295 msg='Expected "%s" in %s' % (decl, contents))
292 decl = gs.PosixStubWriter.UninitializeModuleName(name) 296 decl = gs.PosixStubWriter.UninitializeModuleName(name)
293 self.assertTrue(contents.find(decl) != -1, 297 self.assertTrue(contents.find(decl) != -1,
294 msg='Expected "%s" in %s' % (decl, contents)) 298 msg='Expected "%s" in %s' % (decl, contents))
295 299
296 if __name__ == '__main__': 300 if __name__ == '__main__':
297 unittest.main() 301 unittest.main()
OLDNEW
« no previous file with comments | « tools/generate_stubs/generate_stubs.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698