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..3318a38b82b5f076a54a4df2e8c12b833c413dff 100644 |
| --- a/src/end_to_end_test.py |
| +++ b/src/end_to_end_test.py |
| @@ -68,42 +68,50 @@ 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_directories=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_directories: Set of directory names to ignore. Note that all |
| + children will be ignored too. |
| - 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_directories: |
| + ignore_directories = set() |
| + |
| + filepaths = set() |
| + for dirname, dirnames, filenames in os.walk(directory, topdown=True): |
| + basename = os.path.basename(os.path.normpath(dirname)) |
|
Matt Giuca
2016/02/05 00:23:49
This is descending into the ignored directory, and
|
| + if basename in ignore_directories: |
| + dirnames[:] = [] |
| + 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'}) |
| + self.assertEqual(expected_files, actual_files) |
| def test_all_correct_contents(self): |
| """Tests that the content of all non-static output files is expected.""" |