diff options
author | dpranke@google.com <dpranke@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-12 01:00:08 +0000 |
---|---|---|
committer | dpranke@google.com <dpranke@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-12 01:00:08 +0000 |
commit | 5d56ba000c0f51a91632708a27cb25367120a61d (patch) | |
tree | cf538e223301f204aab984185237e57aa16a66bc /webkit | |
parent | 9d88364cfcdbdcda08f317a488ffdf84227dacc2 (diff) | |
download | chromium_src-5d56ba000c0f51a91632708a27cb25367120a61d.zip chromium_src-5d56ba000c0f51a91632708a27cb25367120a61d.tar.gz chromium_src-5d56ba000c0f51a91632708a27cb25367120a61d.tar.bz2 |
Add a --find-baselines option to run_webkit_tests.
Specifying this option will output a CSV-delimited table of layout test
files and the platform directories where their results are located.
Refactor path_utils.ExpectedFilename() into a separate routine to split
the results files into top-of-platform dir + relative path accordingly.
BUG=none
R=pam@chromium.org
TEST=none
Review URL: http://codereview.chromium.org/164299
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23134 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/tools/layout_tests/layout_package/path_utils.py | 62 | ||||
-rwxr-xr-x | webkit/tools/layout_tests/run_webkit_tests.py | 19 |
2 files changed, 68 insertions, 13 deletions
diff --git a/webkit/tools/layout_tests/layout_package/path_utils.py b/webkit/tools/layout_tests/layout_package/path_utils.py index 97bdfd4..9d05d18 100644 --- a/webkit/tools/layout_tests/layout_package/path_utils.py +++ b/webkit/tools/layout_tests/layout_package/path_utils.py @@ -170,11 +170,16 @@ def GetPlatformDirs(platform): return platform_dirs -def ExpectedFilename(filename, suffix, platform): - """Given a test name, returns an absolute path to its expected results. +def ExpectedBaseline(filename, suffix, platform): + """Given a test name, finds where the baseline result is located. The + result is returned as a pair of values, the absolute path to top of the test + results directory, and the relative path from there to the results file. - If no expected results are found in any of the searched directories, the - directory in which the test itself is located will be returned. + Both return values will be in the format appropriate for the + current platform (e.g., "\\" for path separators on Windows). + + If the results file is not found, then None will be returned for the + directory, but the expected relative pathname will still be returned. Args: filename: absolute filename to test file @@ -183,29 +188,60 @@ def ExpectedFilename(filename, suffix, platform): platform: the most-specific directory name to use to build the search list of directories, e.g., 'chromium-win', or 'chromium-mac-leopard' (we follow the WebKit format) + Returns + platform_dir - abs path to the top of the results tree (or test tree), + or None if the file doesn't exist. + results_filename - relative path from top of tree to the results file + (os.path.join of the two gives you the full path to the file, unless + None was returned.) """ testname = os.path.splitext(RelativeTestFilename(filename))[0] + # While we still have tests in LayoutTests/, chrome/, and pending/, we need # to strip that outer directory. # TODO(pamg): Once we upstream all of chrome/ and pending/, clean this up. - testdir, testname = testname.split('/', 1) - results_filename = testname + '-expected' + suffix + platform_filename = testname + '-expected' + suffix + testdir, base_filename = platform_filename.split('/', 1) platform_dirs = GetPlatformDirs(platform) for platform_dir in platform_dirs: # TODO(pamg): Clean this up once we upstream everything in chrome/ and # pending/. if os.path.basename(platform_dir).startswith('chromium'): - platform_file = os.path.join(platform_dir, testdir, results_filename) + if os.path.exists(os.path.join(platform_dir, platform_filename)): + return platform_dir, platform_filename else: - platform_file = os.path.join(platform_dir, results_filename) - if os.path.exists(platform_file): - return platform_file + if os.path.exists(os.path.join(platform_dir, base_filename)): + return platform_dir, base_filename # If it wasn't found in a platform directory, return the expected result - # in the test's directory, even if no such file actually exists. - return os.path.join(os.path.dirname(filename), - os.path.basename(results_filename)) + # in the test directory, even if no such file actually exists. + platform_dir = LayoutTestsDir(filename) + if os.path.exists(os.path.join(platform_dir, platform_filename)): + return platform_dir, platform_filename + return None, platform_filename + +def ExpectedFilename(filename, suffix, platform): + """Given a test name, returns an absolute path to its expected results. + + If no expected results are found in any of the searched directories, the + directory in which the test itself is located will be returned. The return + value is in the format appropriate for the platform (e.g., "\\" for + path separators on windows). + + Args: + filename: absolute filename to test file + suffix: file suffix of the expected results, including dot; e.g. '.txt' + or '.png'. This should not be None, but may be an empty string. + platform: the most-specific directory name to use to build the + search list of directories, e.g., 'chromium-win', or + 'chromium-mac-leopard' (we follow the WebKit format) + """ + (platform_dir, platform_filename) = ExpectedBaseline(filename, suffix, + platform) + if platform_dir: + return os.path.join(platform_dir, platform_filename) + return os.path.join(LayoutTestsDir(filename), platform_filename) def ImageDiffBinaryPath(target): """Gets the full path to the image_diff binary for the target build diff --git a/webkit/tools/layout_tests/run_webkit_tests.py b/webkit/tools/layout_tests/run_webkit_tests.py index 056af73..da34c7b 100755 --- a/webkit/tools/layout_tests/run_webkit_tests.py +++ b/webkit/tools/layout_tests/run_webkit_tests.py @@ -1049,6 +1049,21 @@ def main(options, args): "lint succeeded.") return + if options.find_baselines: + # Record where we found each baseline, then exit. + print("html,txt,checksum,png"); + for t in test_runner._test_files: + (expected_txt_dir, expected_txt_file) = path_utils.ExpectedBaseline( + t, '.txt', options.platform) + (expected_png_dir, expected_png_file) = path_utils.ExpectedBaseline( + t, '.png', options.platform) + (expected_checksum_dir, + expected_checksum_file) = path_utils.ExpectedBaseline( + t, '.checksum', options.platform) + print("%s,%s,%s,%s" % (path_utils.RelativeTestFilename(t), + expected_txt_dir, expected_checksum_dir, expected_png_dir)) + return + try: test_shell_binary_path = path_utils.TestShellBinaryPath(options.target) except path_utils.PathNotFound: @@ -1185,5 +1200,9 @@ if '__main__' == __name__: default=None, help=("Run a the tests in batches (n), after every " "n tests, the test shell is relaunched.")) + option_parser.add_option("", "--find-baselines", action="store_true", + default=False, + help="Prints a table mapping tests to their " + "expected results") options, args = option_parser.parse_args() main(options, args) |