本文整理汇总了Python中webkitpy.w3c.test_parser.TestParser类的典型用法代码示例。如果您正苦于以下问题:Python TestParser类的具体用法?Python TestParser怎么用?Python TestParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TestParser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_analyze_test_reftest_multiple_matches
def test_analyze_test_reftest_multiple_matches(self):
test_html = """<head>
<link rel="match" href="green-box-ref.xht" />
<link rel="match" href="blue-box-ref.xht" />
<link rel="match" href="orange-box-ref.xht" />
</head>
"""
oc = OutputCapture()
oc.capture_output()
try:
test_path = "/some/madeup/path/"
parser = TestParser(options, test_path + "somefile.html")
test_info = parser.analyze_test(test_contents=test_html)
finally:
_, _, logs = oc.restore_output()
self.assertNotEqual(test_info, None, "did not find a test")
self.assertTrue("test" in test_info.keys(), "did not find a test file")
self.assertTrue("reference" in test_info.keys(), "did not find a reference file")
self.assertTrue(test_info["reference"].startswith(test_path), "reference path is not correct")
self.assertFalse("refsupport" in test_info.keys(), "there should be no refsupport files for this test")
self.assertFalse("jstest" in test_info.keys(), "test should not have been analyzed as a jstest")
self.assertEqual(
logs, "Multiple references are not supported. Importing the first ref defined in somefile.html\n"
)
开发者ID:zhangdinet,项目名称:blink,代码行数:26,代码来源:test_parser_unittest.py
示例2: test_analyze_wpt_manual_test
def test_analyze_wpt_manual_test(self):
"""Tests analyze_test() with a manual test that is not in csswg-test."""
test_html = """<html>
<head>
<title>CSS Test: DESCRIPTION OF TEST</title>
<link rel="author" title="NAME_OF_AUTHOR" />
<style type="text/css"><![CDATA[
CSS FOR TEST
]]></style>
</head>
<body>
CONTENT OF TEST
</body>
</html>
"""
test_path = '/some/madeup/path/'
parser = TestParser(test_path + 'somefile-manual.html', MockHost())
test_info = parser.analyze_test(test_contents=test_html)
self.assertNotEqual(test_info, None, 'test_info is None')
self.assertTrue('test' in test_info.keys(), 'did not find a test file')
self.assertFalse('reference' in test_info.keys(), 'shold not have found a reference file')
self.assertFalse('refsupport' in test_info.keys(), 'there should be no refsupport files for this test')
self.assertFalse('jstest' in test_info.keys(), 'test should not be a jstest')
开发者ID:mirror,项目名称:chromium,代码行数:25,代码来源:test_parser_unittest.py
示例3: test_analyze_test_reftest_with_ref_support_Files
def test_analyze_test_reftest_with_ref_support_Files(self):
""" Tests analyze_test() using a reftest that has refers to a reference file outside of the tests directory and the reference file has paths to other support files """
test_html = """<html>
<head>
<link rel="match" href="../reference/green-box-ref.xht" />
</head>
"""
ref_html = """<head>
<link href="support/css/ref-stylesheet.css" rel="stylesheet" type="text/css">
<style type="text/css">
background-image: url("../../support/some-image.png")
</style>
</head>
<body>
<div><img src="../support/black96x96.png" alt="Image download support must be enabled" /></div>
</body>
</html>
"""
test_path = '/some/madeup/path/'
parser = TestParser(options, test_path + 'somefile.html')
test_info = parser.analyze_test(test_contents=test_html, ref_contents=ref_html)
self.assertNotEqual(test_info, None, 'did not find a test')
self.assertTrue('test' in test_info.keys(), 'did not find a test file')
self.assertTrue('reference' in test_info.keys(), 'did not find a reference file')
self.assertTrue(test_info['reference'].startswith(test_path), 'reference path is not correct')
self.assertTrue('refsupport' in test_info.keys(), 'there should be refsupport files for this test')
self.assertEquals(len(test_info['refsupport']), 3, 'there should be 3 support files in this reference')
self.assertFalse('jstest' in test_info.keys(), 'test should not have been analyzed as a jstest')
开发者ID:335969568,项目名称:Blink-1,代码行数:30,代码来源:test_parser_unittest.py
示例4: test_analyze_pixel_test_all_true
def test_analyze_pixel_test_all_true(self):
""" Tests analyze_test() using a test that is neither a reftest or jstest with all=False """
test_html = """<html>
<head>
<title>CSS Test: DESCRIPTION OF TEST</title>
<link rel="author" title="NAME_OF_AUTHOR" />
<style type="text/css"><![CDATA[
CSS FOR TEST
]]></style>
</head>
<body>
CONTENT OF TEST
</body>
</html>
"""
# Set options to 'all' so this gets found
options['all'] = True
test_path = '/some/madeup/path/'
parser = TestParser(options, test_path + 'somefile.html')
test_info = parser.analyze_test(test_contents=test_html)
self.assertNotEqual(test_info, None, 'test_info is None')
self.assertTrue('test' in test_info.keys(), 'did not find a test file')
self.assertFalse('reference' in test_info.keys(), 'shold not have found a reference file')
self.assertFalse('refsupport' in test_info.keys(), 'there should be no refsupport files for this test')
self.assertFalse('jstest' in test_info.keys(), 'test should not be a jstest')
开发者ID:335969568,项目名称:Blink-1,代码行数:28,代码来源:test_parser_unittest.py
示例5: test_analyze_test_reftest_match_and_mismatch
def test_analyze_test_reftest_match_and_mismatch(self):
test_html = """<head>
<link rel="match" href="green-box-ref.xht" />
<link rel="match" href="blue-box-ref.xht" />
<link rel="mismatch" href="orange-box-notref.xht" />
</head>
"""
oc = OutputCapture()
oc.capture_output()
try:
test_path = '/some/madeup/path/'
parser = TestParser(options, test_path + 'somefile.html')
test_info = parser.analyze_test(test_contents=test_html)
finally:
_, _, logs = oc.restore_output()
self.assertNotEqual(test_info, None, 'did not find a test')
self.assertTrue('test' in test_info.keys(), 'did not find a test file')
self.assertTrue('reference' in test_info.keys(), 'did not find a reference file')
self.assertTrue(test_info['reference'].startswith(test_path), 'reference path is not correct')
self.assertFalse('refsupport' in test_info.keys(), 'there should be no refsupport files for this test')
self.assertFalse('jstest' in test_info.keys(), 'test should not have been analyzed as a jstest')
self.assertEqual(logs, 'Multiple references are not supported. Importing the first ref defined in somefile.html\n')
开发者ID:335969568,项目名称:Blink-1,代码行数:25,代码来源:test_parser_unittest.py
示例6: find_importable_tests
def find_importable_tests(self, directory):
# FIXME: use filesystem
for root, dirs, files in os.walk(directory):
_log.info('Scanning ' + root + '...')
total_tests = 0
reftests = 0
jstests = 0
dirs[:] = [subdir for subdir in dirs if self.should_keep_subdir(root, subdir)]
copy_list = []
for filename in files:
# FIXME: This block should really be a separate function, but the early-continues make that difficult.
if filename.startswith('.') or filename.endswith('.pl'):
continue # For some reason the w3c repo contains random perl scripts we don't care about.
fullpath = os.path.join(root, filename)
mimetype = mimetypes.guess_type(fullpath)
if not 'html' in str(mimetype[0]) and not 'application/xhtml+xml' in str(mimetype[0]) and not 'application/xml' in str(mimetype[0]):
copy_list.append({'src': fullpath, 'dest': filename})
continue
test_parser = TestParser(vars(self.options), filename=fullpath)
test_info = test_parser.analyze_test()
if test_info is None:
continue
if 'reference' in test_info.keys():
reftests += 1
total_tests += 1
test_basename = os.path.basename(test_info['test'])
# Add the ref file, following WebKit style.
# FIXME: Ideally we'd support reading the metadata
# directly rather than relying on a naming convention.
# Using a naming convention creates duplicate copies of the
# reference files.
ref_file = os.path.splitext(test_basename)[0] + '-expected'
ref_file += os.path.splitext(test_basename)[1]
copy_list.append({'src': test_info['reference'], 'dest': ref_file, 'reference_support_info': test_info['reference_support_info']})
copy_list.append({'src': test_info['test'], 'dest': filename})
elif 'jstest' in test_info.keys():
jstests += 1
total_tests += 1
copy_list.append({'src': fullpath, 'dest': filename})
else:
total_tests += 1
copy_list.append({'src': fullpath, 'dest': filename})
if copy_list:
# Only add this directory to the list if there's something to import
self.import_list.append({'dirname': root, 'copy_list': copy_list,
'reftests': reftests, 'jstests': jstests, 'total_tests': total_tests})
开发者ID:,项目名称:,代码行数:58,代码来源:
示例7: is_js_test
def is_js_test(self, test_path):
"""Checks whether a given file is a testharness.js test.
Args:
test_path: A file path relative to the layout tests directory.
This might correspond to a deleted file or a non-test.
"""
absolute_path = self.host.filesystem.join(self.finder.layout_tests_dir(), test_path)
test_parser = TestParser(absolute_path, self.host)
if not test_parser.test_doc:
return False
return test_parser.is_jstest()
开发者ID:,项目名称:,代码行数:12,代码来源:
示例8: test_analyze_manual_wpt_test
def test_analyze_manual_wpt_test(self):
""" Tests analyze_test() using a manual jstest """
test_html = """<head>
<link href="/resources/testharness.css" rel="stylesheet" type="text/css">
<script src="/resources/testharness.js"></script>
</head>
"""
test_path = os.path.join(os.path.sep, 'some', 'madeup', 'path')
parser = TestParser(options, os.path.join(test_path, 'somefile-manual.html'))
test_info = parser.analyze_test(test_contents=test_html)
self.assertTrue(test_info['manualtest'], 'test_info is None')
开发者ID:edcwconan,项目名称:webkit,代码行数:13,代码来源:test_parser_unittest.py
示例9: test_analyze_manual_wpt_test
def test_analyze_manual_wpt_test(self):
""" Tests analyze_test() using a manual jstest """
test_html = """<head>
<link href="/resources/testharness.css" rel="stylesheet" type="text/css">
<script src="/resources/testharness.js"></script>
</head>
"""
test_path = '/some/madeup/path/'
parser = TestParser(options, test_path + 'somefile-manual.html')
test_info = parser.analyze_test(test_contents=test_html)
self.assertEqual(test_info, None, 'test_info is None')
开发者ID:AndriyKalashnykov,项目名称:webkit,代码行数:13,代码来源:test_parser_unittest.py
示例10: test_analyze_test_reftest_one_match
def test_analyze_test_reftest_one_match(self):
test_html = """<head>
<link rel="match" href="green-box-ref.xht" />
</head>
"""
test_path = '/some/madeup/path/'
parser = TestParser(options, test_path + 'somefile.html')
test_info = parser.analyze_test(test_contents=test_html)
self.assertNotEqual(test_info, None, 'did not find a test')
self.assertTrue('test' in test_info.keys(), 'did not find a test file')
self.assertTrue('reference' in test_info.keys(), 'did not find a reference file')
self.assertTrue(test_info['reference'].startswith(test_path), 'reference path is not correct')
self.assertFalse('refsupport' in test_info.keys(), 'there should be no refsupport files for this test')
self.assertFalse('jstest' in test_info.keys(), 'test should not have been analyzed as a jstest')
开发者ID:335969568,项目名称:Blink-1,代码行数:15,代码来源:test_parser_unittest.py
示例11: test_analyze_jstest
def test_analyze_jstest(self):
""" Tests analyze_test() using a jstest """
test_html = """<head>
<link href="/resources/testharness.css" rel="stylesheet" type="text/css">
<script src="/resources/testharness.js"></script>
</head>
"""
test_path = '/some/madeup/path/'
parser = TestParser(options, test_path + 'somefile.html')
test_info = parser.analyze_test(test_contents=test_html)
self.assertNotEqual(test_info, None, 'test_info is None')
self.assertTrue('test' in test_info.keys(), 'did not find a test file')
self.assertFalse('reference' in test_info.keys(), 'shold not have found a reference file')
self.assertFalse('refsupport' in test_info.keys(), 'there should be no refsupport files for this test')
self.assertTrue('jstest' in test_info.keys(), 'test should be a jstest')
开发者ID:335969568,项目名称:Blink-1,代码行数:17,代码来源:test_parser_unittest.py
示例12: test_reference_test
def test_reference_test(self):
""" Tests analyze_test() using a test that is a reference file having a <link rel="match"> tag"""
test_html = """<html>
<head>
<title>CSS Test: DESCRIPTION OF TEST</title>
<link rel="match" href="test-ref.html" />
<link rel="author" title="NAME_OF_AUTHOR" />
<style type="text/css"><![CDATA[
CSS FOR TEST
]]></style>
</head>
<body>
CONTENT OF TEST
</body>
</html>
"""
test_path = os.path.join(os.path.sep, 'some', 'madeup', 'path')
parser = TestParser(options, os.path.join(test_path, 'test-ref.html'))
test_info = parser.analyze_test(test_contents=test_html)
self.assertTrue('referencefile' in test_info, 'test should be detected as reference file')
开发者ID:edcwconan,项目名称:webkit,代码行数:22,代码来源:test_parser_unittest.py
示例13: test_analyze_csswg_manual_test
def test_analyze_csswg_manual_test(self):
"""Tests analyze_test() using a test that is neither a reftest or jstest, in csswg-test"""
test_html = """<html>
<head>
<title>CSS Test: DESCRIPTION OF TEST</title>
<link rel="author" title="NAME_OF_AUTHOR" />
<style type="text/css"><![CDATA[
CSS FOR TEST
]]></style>
</head>
<body>
CONTENT OF TEST
</body>
</html>
"""
parser = TestParser('/some/csswg-test/path/somefile.html', MockHost())
test_info = parser.analyze_test(test_contents=test_html)
self.assertIsNotNone(test_info, 'test_info should not be None')
self.assertIn('test', test_info.keys(), 'should find a test file')
self.assertNotIn('reference', test_info.keys(), 'shold not have found a reference file')
self.assertNotIn('refsupport', test_info.keys(), 'there should be no refsupport files for this test')
self.assertNotIn('jstest', test_info.keys(), 'test should not be a jstest')
开发者ID:mirror,项目名称:chromium,代码行数:23,代码来源:test_parser_unittest.py
示例14: test_analyze_pixel_test_all_false
def test_analyze_pixel_test_all_false(self):
"""Tests analyze_test() using a test that is neither a reftest or jstest, with -all=False"""
test_html = """<html>
<head>
<title>CSS Test: DESCRIPTION OF TEST</title>
<link rel="author" title="NAME_OF_AUTHOR" />
<style type="text/css"><![CDATA[
CSS FOR TEST
]]></style>
</head>
<body>
CONTENT OF TEST
</body>
</html>
"""
# Set 'all' to False so this gets skipped.
options = {'all': False}
test_path = '/some/madeup/path/'
parser = TestParser(test_path + 'somefile.html', MockHost(), options)
test_info = parser.analyze_test(test_contents=test_html)
self.assertEqual(test_info, None, 'test should have been skipped')
开发者ID:ollie314,项目名称:chromium,代码行数:23,代码来源:test_parser_unittest.py
示例15: test_analyze_test_reftest_multiple_matches
def test_analyze_test_reftest_multiple_matches(self):
test_html = """<head>
<link rel="match" href="green-box-ref.xht" />
<link rel="match" href="blue-box-ref.xht" />
<link rel="match" href="orange-box-ref.xht" />
</head>
"""
oc = OutputCapture()
oc.capture_output()
try:
test_path = '/some/madeup/path/'
parser = TestParser(options, test_path + 'somefile.html')
test_info = parser.analyze_test(test_contents=test_html)
finally:
output, _, _ = oc.restore_output()
self.assertNotEqual(test_info, None, 'did not find a test')
self.assertTrue('test' in test_info.keys(), 'did not find a test file')
self.assertTrue('reference' in test_info.keys(), 'did not find a reference file')
self.assertTrue(test_info['reference'].startswith(test_path), 'reference path is not correct')
self.assertFalse('refsupport' in test_info.keys(), 'there should be no refsupport files for this test')
self.assertFalse('jstest' in test_info.keys(), 'test should not have been analyzed as a jstest')
self.assertTrue(output.startswith('Warning'), 'no warning about multiple matches')
开发者ID:Anthony-Biget,项目名称:openjfx,代码行数:24,代码来源:test_parser_unittest.py
示例16: test_analyze_pixel_test_all_false
def test_analyze_pixel_test_all_false(self):
""" Tests analyze_test() using a test that is neither a reftest or jstest, with -all=False """
test_html = """<html>
<head>
<title>CSS Test: DESCRIPTION OF TEST</title>
<link rel="author" title="NAME_OF_AUTHOR" />
<style type="text/css"><![CDATA[
CSS FOR TEST
]]></style>
</head>
<body>
CONTENT OF TEST
</body>
</html>
"""
# Set all to false so this gets skipped
options['all'] = False
test_path = os.path.join(os.path.sep, 'some', 'madeup', 'path')
parser = TestParser(options, os.path.join(test_path, 'somefile.html'))
test_info = parser.analyze_test(test_contents=test_html)
self.assertEqual(test_info, None, 'test should have been skipped')
开发者ID:edcwconan,项目名称:webkit,代码行数:24,代码来源:test_parser_unittest.py
示例17: test_analyze_non_html_file
def test_analyze_non_html_file(self):
""" Tests analyze_test() with a file that has no html"""
# FIXME: use a mock filesystem
parser = TestParser(options, os.path.join(os.path.dirname(__file__), 'test_parser.py'))
test_info = parser.analyze_test()
self.assertEqual(test_info, None, 'no tests should have been found in this file')
开发者ID:335969568,项目名称:Blink-1,代码行数:6,代码来源:test_parser_unittest.py
示例18: find_importable_tests
def find_importable_tests(self):
"""Walks through the source directory to find what tests should be imported.
This function sets self.import_list, which contains information about how many
tests are being imported, and their source and destination paths.
"""
paths_to_skip = self.find_paths_to_skip()
for root, dirs, files in self.filesystem.walk(self.source_repo_path):
cur_dir = root.replace(self.dir_above_repo + "/", "") + "/"
_log.info(" scanning " + cur_dir + "...")
total_tests = 0
reftests = 0
jstests = 0
# Files in 'tools' are not for browser testing, so we skip them.
# See: http://testthewebforward.org/docs/test-format-guidelines.html#tools
DIRS_TO_SKIP = (".git", "test-plan", "tools")
# We copy all files in 'support', including HTML without metadata.
# See: http://testthewebforward.org/docs/test-format-guidelines.html#support-files
DIRS_TO_INCLUDE = ("resources", "support")
if dirs:
for d in DIRS_TO_SKIP:
if d in dirs:
dirs.remove(d)
for path in paths_to_skip:
path_base = path.replace(self.options.destination + "/", "")
path_base = path_base.replace(cur_dir, "")
path_full = self.filesystem.join(root, path_base)
if path_base in dirs:
dirs.remove(path_base)
if not self.options.dry_run and self.import_in_place:
_log.info(" pruning %s", path_base)
self.filesystem.rmtree(path_full)
else:
_log.info(" skipping %s", path_base)
copy_list = []
for filename in files:
path_full = self.filesystem.join(root, filename)
path_base = path_full.replace(self.source_repo_path + "/", "")
path_base = self.destination_directory.replace(self.layout_tests_dir + "/", "") + "/" + path_base
if path_base in paths_to_skip:
if not self.options.dry_run and self.import_in_place:
_log.info(" pruning %s", path_base)
self.filesystem.remove(path_full)
continue
else:
continue
# FIXME: This block should really be a separate function, but the early-continues make that difficult.
if filename.startswith(".") or filename.endswith(".pl"):
# The w3cs repos may contain perl scripts, which we don't care about.
continue
if filename == "OWNERS" or filename == "reftest.list":
# These files fail our presubmits.
# See http://crbug.com/584660 and http://crbug.com/582838.
continue
fullpath = self.filesystem.join(root, filename)
mimetype = mimetypes.guess_type(fullpath)
if (
"html" not in str(mimetype[0])
and "application/xhtml+xml" not in str(mimetype[0])
and "application/xml" not in str(mimetype[0])
):
copy_list.append({"src": fullpath, "dest": filename})
continue
if self.filesystem.basename(root) in DIRS_TO_INCLUDE:
copy_list.append({"src": fullpath, "dest": filename})
continue
test_parser = TestParser(fullpath, self.host, vars(self.options))
test_info = test_parser.analyze_test()
if test_info is None:
continue
if self.path_too_long(path_full):
_log.warning(
"%s skipped due to long path. "
"Max length from repo base %d chars; see http://crbug.com/609871.",
path_full,
MAX_PATH_LENGTH,
)
continue
if "reference" in test_info.keys():
test_basename = self.filesystem.basename(test_info["test"])
# Add the ref file, following WebKit style.
# FIXME: Ideally we'd support reading the metadata
# directly rather than relying on a naming convention.
# Using a naming convention creates duplicate copies of the
# reference files.
ref_file = self.filesystem.splitext(test_basename)[0] + "-expected"
#.........这里部分代码省略.........
开发者ID:ollie314,项目名称:chromium,代码行数:101,代码来源:test_importer.py
示例19: find_importable_tests
def find_importable_tests(self, directory):
# FIXME: use filesystem
paths_to_skip = self.find_paths_to_skip()
for root, dirs, files in os.walk(directory):
cur_dir = root.replace(self.dir_above_repo + "/", "") + "/"
_log.info(" scanning " + cur_dir + "...")
total_tests = 0
reftests = 0
jstests = 0
DIRS_TO_SKIP = (".git", ".hg")
if dirs:
for d in DIRS_TO_SKIP:
if d in dirs:
dirs.remove(d)
for path in paths_to_skip:
path_base = path.replace(self.options.destination + "/", "")
path_base = path_base.replace(cur_dir, "")
path_full = self.filesystem.join(root, path_base)
if path_base in dirs:
dirs.remove(path_base)
if not self.options.dry_run and self.import_in_place:
_log.info(" pruning %s" % path_base)
self.filesystem.rmtree(path_full)
else:
_log.info(" skipping %s" % path_base)
copy_list = []
for filename in files:
path_full = self.filesystem.join(root, filename)
path_base = path_full.replace(directory + "/", "")
path_base = self.destination_directory.replace(self.layout_tests_dir + "/", "") + "/" + path_base
if path_base in paths_to_skip:
if not self.options.dry_run and self.import_in_place:
_log.info(" pruning %s" % path_base)
self.filesystem.remove(path_full)
continue
else:
continue
# FIXME: This block should really be a separate function, but the early-continues make that difficult.
if filename.startswith(".") or filename.endswith(".pl"):
continue # For some reason the w3c repo contains random perl scripts we don't care about.
fullpath = os.path.join(root, filename)
mimetype = mimetypes.guess_type(fullpath)
if (
not "html" in str(mimetype[0])
and not "application/xhtml+xml" in str(mimetype[0])
and not "application/xml" in str(mimetype[0])
):
copy_list.append({"src": fullpath, "dest": filename})
continue
if root.endswith("resources"):
copy_list.append({"src": fullpath, "dest": filename})
continue
test_parser = TestParser(vars(self.options), filename=fullpath)
test_info = test_parser.analyze_test()
if test_info is None:
continue
if "reference" in test_info.keys():
reftests += 1
total_tests += 1
test_basename = os.path.basename(test_info["test"])
# Add the ref file, following WebKit style.
# FIXME: Ideally we'd support reading the metadata
# directly rather than relying on a naming convention.
# Using a naming convention creates duplicate copies of the
# reference files.
ref_file = os.path.splitext(test_basename)[0] + "-expected"
# Make sure to use the extension from the *reference*, not
# from the test, because at least flexbox tests use XHTML
# references but HTML tests.
ref_file += os.path.splitext(test_info["reference"])[1]
copy_list.append(
{
"src": test_info["reference"],
"dest": ref_file,
"reference_support_info": test_info["reference_support_info"],
}
)
copy_list.append({"src": test_info["test"], "dest": filename})
elif "jstest" in test_info.keys():
jstests += 1
total_tests += 1
copy_list.append({"src": fullpath, "dest": filename})
else:
total_tests += 1
copy_list.append({"src": fullpath, "dest": filename})
#.........这里部分代码省略.........
开发者ID:joone,项目名称:blink-crosswalk,代码行数:101,代码来源:test_importer.py
示例20: find_importable_tests
def find_importable_tests(self, directory):
# FIXME: use filesystem
paths_to_skip = self.find_paths_to_skip()
for root, dirs, files in os.walk(directory):
cur_dir = root.replace(self.dir_above_repo + '/', '') + '/'
_log.info(' scanning ' + cur_dir + '...')
total_tests = 0
reftests = 0
jstests = 0
DIRS_TO_SKIP = ('.git', '.hg')
if dirs:
for d in DIRS_TO_SKIP:
if d in dirs:
dirs.remove(d)
for path in paths_to_skip:
path_base = path.replace(self.options.destination + '/', '')
path_base = path_base.replace(cur_dir, '')
path_full = self.filesystem.join(root, path_base)
if path_base in dirs:
dirs.remove(path_base)
if not self.options.dry_run and self.import_in_place:
_log.info(" pruning %s" % path_base)
self.filesystem.rmtree(path_full)
else:
_log.info(" skipping %s" % path_base)
copy_list = []
for filename in files:
path_full = self.filesystem.join(root, filename)
path_base = path_full.replace(directory + '/', '')
path_base = self.destination_directory.replace(self.layout_tests_dir + '/', '') + '/' + path_base
if path_base in paths_to_skip:
if not self.options.dry_run and self.import_in_place:
_log.info(" pruning %s" % path_base)
self.filesystem.remove(path_full)
continue
else:
continue
# FIXME: This block should really be a separate function, but the early-continues make that difficult.
if filename.startswith('.') or filename.endswith('.pl'):
continue # For some reason the w3c repo contains random perl scripts we don't care about.
fullpath = os.path.join(root, filename)
mimetype = mimetypes.guess_type(fullpath)
if not 'html' in str(mimetype[0]) and not 'application/xhtml+xml' in str(mimetype[0]) and not 'application/xml' in str(mimetype[0]):
copy_list.append({'src': fullpath, 'dest': filename})
continue
if root.endswith('resources'):
copy_list.append({'src': fullpath, 'dest': filename})
continue
test_parser = TestParser(vars(self.options), filename=fullpath)
test_info = test_parser.analyze_test()
if test_info is None:
continue
if 'reference' in test_info.keys():
reftests += 1
total_tests += 1
test_basename = os.path.basename(test_info['test'])
# Add the ref file, following WebKit style.
# FIXME: Ideally we'd support reading the metadata
# directly rather than relying on a naming convention.
# Using a naming convention creates duplicate copies of the
# reference files.
ref_file = os.path.splitext(test_basename)[0] + '-expected'
ref_file += os.path.splitext(test_basename)[1]
copy_list.append({'src': test_info['reference'], 'dest': ref_file, 'reference_support_info': test_info['reference_support_info']})
copy_list.append({'src': test_info['test'], 'dest': filename})
elif 'jstest' in test_info.keys():
jstests += 1
total_tests += 1
copy_list.append({'src': fullpath, 'dest': filename})
else:
total_tests += 1
copy_list.append({'src': fullpath, 'dest': filename})
if copy_list:
# Only add this directory to the list if there's something to import
self.import_list.append({'dirname': root, 'copy_list': copy_list,
'reftests': reftests, 'jstests': jstests, 'total_tests': total_tests})
开发者ID:janRucka,项目名称:blink,代码行数:92,代码来源:test_importer.py
注:本文中的webkitpy.w3c.test_parser.TestParser类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论