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

Unified Diff: src/end_to_end_test.py

Issue 1662833005: Fixes Caterpillar crashing while generating report. (Closed) Base URL: https://github.com/chromium/caterpillar.git@master
Patch Set: Response to CR Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/caterpillar.py ('k') | src/report/report.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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."""
« no previous file with comments | « src/caterpillar.py ('k') | src/report/report.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698