Chromium Code Reviews| Index: src/end_to_end_test.py |
| diff --git a/src/end_to_end_test.py b/src/end_to_end_test.py |
| index 8c3582154c9e9bb3cc253fe54c07e95a1a37b6bd..16d2099af8adc3f008f834ea381b684f005b1c37 100644 |
| --- a/src/end_to_end_test.py |
| +++ b/src/end_to_end_test.py |
| @@ -68,42 +68,53 @@ class TestEndToEndConvert(caterpillar_test.TestCaseWithTempDir): |
| if not os.path.exists(self.config_path): |
| raise RuntimeError('Configuration file generation failed.') |
| + if process.wait(): |
| + raise subprocess.CalledProcessError() |
| - process = subprocess.Popen( |
| + if not os.path.exists(self.config_path): |
| + raise RuntimeError('Configuration file generation failed.') |
| + |
| + output = subprocess.check_output( |
| [CATERPILLAR_PATH, 'convert', '-c', self.config_path, self.input_dir, |
| - self.output_dir], |
| - stdin=subprocess.PIPE, |
| - stdout=subprocess.PIPE, |
| - stderr=subprocess.STDOUT) |
| - process.wait() |
| + self.output_dir]) |
| - def test_output_matches_reference(self): |
| - """Tests that the output matches the reference output.""" |
| - expected_files = set() |
| - for dirname, _, filenames in os.walk(TTS_REFERENCE_PATH): |
| - for filename in filenames: |
| - relpath = os.path.relpath( |
| - os.path.join(dirname, filename), TTS_REFERENCE_PATH) |
| - expected_files.add(relpath) |
| + def get_relative_filepaths(self, directory, ignore_folders=None): |
| + """Returns all relative filepaths in a directory and children. |
| - for dirname, _, filenames in os.walk(self.output_dir): |
| - for filename in filenames: |
| - relpath = os.path.relpath( |
| - os.path.join(dirname, filename), self.output_dir) |
| - self.assertIn(relpath, expected_files) |
| + Args: |
| + directory: Path to directory. |
| + ignore_folders: List of folder names to ignore. |
|
Matt Giuca
2016/02/04 06:36:34
directory / folder are interchangeable, so don't m
Matthew Alger
2016/02/04 22:47:06
Done.
|
| - expected_files = set() |
| - for dirname, _, filenames in os.walk(self.output_dir): |
| - for filename in filenames: |
| - relpath = os.path.relpath( |
| - os.path.join(dirname, filename), self.output_dir) |
| - expected_files.add(relpath) |
| + Returns: |
| + set of relative filepaths. |
| + """ |
| + if not ignore_folders: |
| + ignore_folders = [] |
| + |
| + filepaths = set() |
| + for dirname, _, filenames in os.walk(directory): |
| + skip = False |
| + for folder in ignore_folders: |
| + if folder in dirname: |
|
Matt Giuca
2016/02/04 06:36:34
This is not precise enough. If ignore_folders = ['
Matthew Alger
2016/02/04 22:47:06
Oh, that's much cleaner. Done.
|
| + skip = True |
| + break |
| + |
| + if skip: |
| + continue |
| - for dirname, _, filenames in os.walk(TTS_REFERENCE_PATH): |
| for filename in filenames: |
| - relpath = os.path.relpath( |
| - os.path.join(dirname, filename), TTS_REFERENCE_PATH) |
| - self.assertIn(relpath, expected_files) |
| + relpath = os.path.relpath(os.path.join(dirname, filename), directory) |
| + filepaths.add(relpath) |
| + |
| + return filepaths |
| + |
| + def test_output_matches_reference(self): |
| + """Tests that the output matches the reference output.""" |
| + expected_files = self.get_relative_filepaths(TTS_REFERENCE_PATH, |
| + ['bower_components']) |
| + actual_files = self.get_relative_filepaths(self.output_dir, |
| + ['bower_components']) |
|
Matt Giuca
2016/02/04 06:36:34
{'bower_components'}
Matthew Alger
2016/02/04 22:47:06
Done.
|
| + self.assertEqual(expected_files, actual_files) |
| def test_all_correct_contents(self): |
| """Tests that the content of all non-static output files is expected.""" |