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 import os | 6 import os |
7 import sys | 7 import sys |
8 import unittest | 8 import unittest |
9 | 9 |
10 from compiler import GenerateSchema | 10 from compiler import GenerateSchema |
(...skipping 14 matching lines...) Expand all Loading... |
25 TESTS_DIR/test_filename.idl | 25 TESTS_DIR/test_filename.idl |
26 and compares it to the output in the file: | 26 and compares it to the output in the file: |
27 TESTS_DIR/test_filename.dart | 27 TESTS_DIR/test_filename.dart |
28 ''' | 28 ''' |
29 file_rel = os.path.join(TESTS_DIR, test_filename) | 29 file_rel = os.path.join(TESTS_DIR, test_filename) |
30 | 30 |
31 output_dir = None | 31 output_dir = None |
32 if REBASE_MODE: | 32 if REBASE_MODE: |
33 output_dir = TESTS_DIR | 33 output_dir = TESTS_DIR |
34 output_code = GenerateSchema('dart', ['%s.idl' % file_rel], TESTS_DIR, | 34 output_code = GenerateSchema('dart', ['%s.idl' % file_rel], TESTS_DIR, |
35 output_dir, None, None, None) | 35 output_dir, '', None, None, []) |
36 | 36 |
37 if not REBASE_MODE: | 37 if not REBASE_MODE: |
38 with open('%s.dart' % file_rel) as f: | 38 with open('%s.dart' % file_rel) as f: |
39 expected_output = f.read() | 39 expected_output = f.read() |
40 # Remove the first line of the output code (as it contains the filename). | 40 # Remove the first line of the output code (as it contains the filename). |
41 # Also remove all blank lines, ignoring them from the comparison. | 41 # Also remove all blank lines, ignoring them from the comparison. |
42 # Compare with lists instead of strings for clearer diffs (especially with | 42 # Compare with lists instead of strings for clearer diffs (especially with |
43 # whitespace) when a test fails. | 43 # whitespace) when a test fails. |
44 self.assertEqual([l for l in expected_output.split('\n') if l], | 44 self.assertEqual([l for l in expected_output.split('\n') if l], |
45 [l for l in output_code.split('\n')[1:] if l]) | 45 [l for l in output_code.split('\n')[1:] if l]) |
(...skipping 26 matching lines...) Expand all Loading... |
72 def testTags(self): | 72 def testTags(self): |
73 self._RunTest('tags') | 73 self._RunTest('tags') |
74 | 74 |
75 | 75 |
76 if __name__ == '__main__': | 76 if __name__ == '__main__': |
77 if '--rebase' in sys.argv: | 77 if '--rebase' in sys.argv: |
78 print "Running in rebase mode." | 78 print "Running in rebase mode." |
79 REBASE_MODE = True | 79 REBASE_MODE = True |
80 sys.argv.remove('--rebase') | 80 sys.argv.remove('--rebase') |
81 unittest.main() | 81 unittest.main() |
OLD | NEW |