diff options
author | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-03 20:13:55 +0000 |
---|---|---|
committer | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-03 20:13:55 +0000 |
commit | 728947148e8cade7ee8077e9451d20e18cc050ed (patch) | |
tree | b8798c0844765e3f413edfd0be12453214bb38da | |
parent | 19dfbb20957a02fae1374747e7df62d5b7fcb107 (diff) | |
download | chromium_src-728947148e8cade7ee8077e9451d20e18cc050ed.zip chromium_src-728947148e8cade7ee8077e9451d20e18cc050ed.tar.gz chromium_src-728947148e8cade7ee8077e9451d20e18cc050ed.tar.bz2 |
fix --new-baseline for image baselines on linux/mac
The previous change was causing image baselines to be treated as
text only diffs so images were being copied into the chromium-win
dir by accident. Fix this by reverting the change from test_type_base.py
and applying it to text_diff.py instead.
Review URL: http://codereview.chromium.org/20021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9100 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | webkit/tools/layout_tests/test_types/test_type_base.py | 31 | ||||
-rw-r--r-- | webkit/tools/layout_tests/test_types/text_diff.py | 40 |
2 files changed, 47 insertions, 24 deletions
diff --git a/webkit/tools/layout_tests/test_types/test_type_base.py b/webkit/tools/layout_tests/test_types/test_type_base.py index 90d5fa7..0c92cbf 100644 --- a/webkit/tools/layout_tests/test_types/test_type_base.py +++ b/webkit/tools/layout_tests/test_types/test_type_base.py @@ -19,11 +19,6 @@ import google.path_utils from layout_package import path_utils from layout_package import platform_utils -def isRenderTreeDump(data): - """Returns true if data appears to be a render tree dump as opposed to a - plain text dump.""" - return data.find("RenderView at (0,0)") != -1 - class TestArguments(object): """Struct-like wrapper for additional arguments needed by specific tests.""" # Whether to save new baseline results. @@ -81,27 +76,15 @@ class TestTypeBase(object): data: result to be saved as the new baseline modifier: type of the result file, e.g. ".txt" or ".png" """ + relative_dir = os.path.dirname(path_utils.RelativeTestFilename(filename)) + output_dir = os.path.join(path_utils.PlatformResultsDir(self._platform), + self._platform, + relative_dir) output_file = os.path.basename(os.path.splitext(filename)[0] + self.FILENAME_SUFFIX_EXPECTED + modifier) - if isRenderTreeDump(data): - relative_dir = os.path.dirname(path_utils.RelativeTestFilename(filename)) - output_dir = os.path.join(path_utils.PlatformResultsDir(self._platform), - self._platform, - relative_dir) - - google.path_utils.MaybeMakeDirectory(output_dir) - open(os.path.join(output_dir, output_file), "wb").write(data) - else: - # If it's not a render tree, then the results can be shared between all - # platforms. Copy the file into the chromium-win and chromium-mac dirs. - relative_dir = os.path.dirname(path_utils.RelativeTestFilename(filename)) - for platform in ('chromium-win', 'chromium-mac'): - output_dir = os.path.join(path_utils.PlatformResultsDir(self._platform), - platform, - relative_dir) - - google.path_utils.MaybeMakeDirectory(output_dir) - open(os.path.join(output_dir, output_file), "wb").write(data) + + google.path_utils.MaybeMakeDirectory(output_dir) + open(os.path.join(output_dir, output_file), "wb").write(data) def OutputFilename(self, filename, modifier): """Returns a filename inside the output dir that contains modifier. diff --git a/webkit/tools/layout_tests/test_types/text_diff.py b/webkit/tools/layout_tests/test_types/text_diff.py index d23a912..3561e6a 100644 --- a/webkit/tools/layout_tests/test_types/text_diff.py +++ b/webkit/tools/layout_tests/test_types/text_diff.py @@ -12,11 +12,18 @@ import errno import logging import os.path +import google.path_utils + from layout_package import path_utils from layout_package import platform_utils from layout_package import test_failures from test_types import test_type_base +def isRenderTreeDump(data): + """Returns true if data appears to be a render tree dump as opposed to a + plain text dump.""" + return data.find("RenderView at (0,0)") != -1 + class TestTextDiff(test_type_base.TestTypeBase): def GetNormalizedOutputText(self, output): # Some tests produce "\r\n" explicitly. Our system (Python/Cygwin) @@ -45,6 +52,39 @@ class TestTextDiff(test_type_base.TestTypeBase): # Normalize line endings return expected.strip("\r\n").replace("\r\n", "\n") + "\n" + def _SaveBaselineData(self, filename, data, modifier): + """Saves a new baseline file into the platform directory. + + The file will be named simply "<test>-expected<modifier>", suitable for + use as the expected results in a later run. + + Args: + filename: path to the test file + data: result to be saved as the new baseline + modifier: type of the result file, e.g. ".txt" or ".png" + """ + output_file = os.path.basename(os.path.splitext(filename)[0] + + self.FILENAME_SUFFIX_EXPECTED + modifier) + if isRenderTreeDump(data): + relative_dir = os.path.dirname(path_utils.RelativeTestFilename(filename)) + output_dir = os.path.join(path_utils.PlatformResultsDir(self._platform), + self._platform, + relative_dir) + + google.path_utils.MaybeMakeDirectory(output_dir) + open(os.path.join(output_dir, output_file), "wb").write(data) + else: + # If it's not a render tree, then the results can be shared between all + # platforms. Copy the file into the chromium-win and chromium-mac dirs. + relative_dir = os.path.dirname(path_utils.RelativeTestFilename(filename)) + for platform in ('chromium-win', 'chromium-mac'): + output_dir = os.path.join(path_utils.PlatformResultsDir(self._platform), + platform, + relative_dir) + + google.path_utils.MaybeMakeDirectory(output_dir) + open(os.path.join(output_dir, output_file), "wb").write(data) + def CompareOutput(self, filename, proc, output, test_args, target): """Implementation of CompareOutput that checks the output text against the expected text from the LayoutTest directory.""" |