Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python2 | 1 #!/usr/bin/env python2 |
| 2 # -*- coding: utf-8 -*- | 2 # -*- coding: utf-8 -*- |
| 3 | 3 |
| 4 # Copyright 2016 Google Inc. All Rights Reserved. | 4 # Copyright 2016 Google Inc. All Rights Reserved. |
| 5 # | 5 # |
| 6 # Licensed under the Apache License, Version 2.0 (the "License"); | 6 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 # you may not use this file except in compliance with the License. | 7 # you may not use this file except in compliance with the License. |
| 8 # You may obtain a copy of the License at | 8 # You may obtain a copy of the License at |
| 9 # | 9 # |
| 10 # http://www.apache.org/licenses/LICENSE-2.0 | 10 # http://www.apache.org/licenses/LICENSE-2.0 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 [CATERPILLAR_PATH, 'convert', '-c', self.config_path, self.input_dir, | 73 [CATERPILLAR_PATH, 'convert', '-c', self.config_path, self.input_dir, |
| 74 self.output_dir], | 74 self.output_dir], |
| 75 stdin=subprocess.PIPE, | 75 stdin=subprocess.PIPE, |
| 76 stdout=subprocess.PIPE, | 76 stdout=subprocess.PIPE, |
| 77 stderr=subprocess.STDOUT) | 77 stderr=subprocess.STDOUT) |
| 78 process.wait() | 78 process.wait() |
| 79 | 79 |
| 80 def test_output_matches_reference(self): | 80 def test_output_matches_reference(self): |
| 81 """Tests that the output matches the reference output.""" | 81 """Tests that the output matches the reference output.""" |
| 82 expected_files = set() | 82 expected_files = set() |
| 83 for dirname, _, filenames in os.walk(TTS_REFERENCE_PATH): | 83 for dirname, _, filenames in os.walk(TTS_REFERENCE_PATH): |
|
Matt Giuca
2016/02/04 05:10:31
This has almost the same thing four times. I think
Matthew Alger
2016/02/04 05:44:01
Done.
We ignore bower_components because it is wh
| |
| 84 if 'bower_components' in dirname: | |
| 85 continue | |
| 86 | |
| 84 for filename in filenames: | 87 for filename in filenames: |
| 85 relpath = os.path.relpath( | 88 relpath = os.path.relpath( |
| 86 os.path.join(dirname, filename), TTS_REFERENCE_PATH) | 89 os.path.join(dirname, filename), TTS_REFERENCE_PATH) |
| 87 expected_files.add(relpath) | 90 expected_files.add(relpath) |
| 88 | 91 |
| 89 for dirname, _, filenames in os.walk(self.output_dir): | 92 for dirname, _, filenames in os.walk(self.output_dir): |
| 93 if 'bower_components' in dirname: | |
| 94 continue | |
| 95 | |
| 90 for filename in filenames: | 96 for filename in filenames: |
| 91 relpath = os.path.relpath( | 97 relpath = os.path.relpath( |
| 92 os.path.join(dirname, filename), self.output_dir) | 98 os.path.join(dirname, filename), self.output_dir) |
| 93 self.assertIn(relpath, expected_files) | 99 self.assertIn(relpath, expected_files) |
| 94 | 100 |
| 95 expected_files = set() | 101 expected_files = set() |
| 96 for dirname, _, filenames in os.walk(self.output_dir): | 102 for dirname, _, filenames in os.walk(self.output_dir): |
| 103 if 'bower_components' in dirname: | |
| 104 continue | |
| 105 | |
| 97 for filename in filenames: | 106 for filename in filenames: |
| 98 relpath = os.path.relpath( | 107 relpath = os.path.relpath( |
| 99 os.path.join(dirname, filename), self.output_dir) | 108 os.path.join(dirname, filename), self.output_dir) |
| 100 expected_files.add(relpath) | 109 expected_files.add(relpath) |
| 101 | 110 |
| 102 for dirname, _, filenames in os.walk(TTS_REFERENCE_PATH): | 111 for dirname, _, filenames in os.walk(TTS_REFERENCE_PATH): |
| 112 if 'bower_components' in dirname: | |
| 113 continue | |
| 114 | |
| 103 for filename in filenames: | 115 for filename in filenames: |
| 104 relpath = os.path.relpath( | 116 relpath = os.path.relpath( |
| 105 os.path.join(dirname, filename), TTS_REFERENCE_PATH) | 117 os.path.join(dirname, filename), TTS_REFERENCE_PATH) |
| 106 self.assertIn(relpath, expected_files) | 118 self.assertIn(relpath, expected_files) |
| 107 | 119 |
| 108 def test_all_correct_contents(self): | 120 def test_all_correct_contents(self): |
| 109 """Tests that the content of all non-static output files is expected.""" | 121 """Tests that the content of all non-static output files is expected.""" |
| 110 for dirname, _, filenames in os.walk(TTS_REFERENCE_PATH): | 122 for dirname, _, filenames in os.walk(TTS_REFERENCE_PATH): |
| 111 for filename in filenames: | 123 for filename in filenames: |
| 112 if filename == caterpillar.SW_SCRIPT_NAME: | 124 if filename == caterpillar.SW_SCRIPT_NAME: |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 '\n'.join(difflib.unified_diff( | 167 '\n'.join(difflib.unified_diff( |
| 156 output_data.split('\n'), | 168 output_data.split('\n'), |
| 157 reference_data.split('\n'), | 169 reference_data.split('\n'), |
| 158 fromfile=reference_sw_path, | 170 fromfile=reference_sw_path, |
| 159 tofile=output_sw_path, | 171 tofile=output_sw_path, |
| 160 n=0)))) | 172 n=0)))) |
| 161 | 173 |
| 162 | 174 |
| 163 if __name__ == '__main__': | 175 if __name__ == '__main__': |
| 164 unittest.main() | 176 unittest.main() |
| OLD | NEW |