Modified: trunk/Tools/ChangeLog (172213 => 172214)
--- trunk/Tools/ChangeLog 2014-08-07 16:23:05 UTC (rev 172213)
+++ trunk/Tools/ChangeLog 2014-08-07 16:37:59 UTC (rev 172214)
@@ -1,3 +1,37 @@
+2014-08-07 Bem Jones-Bey <[email protected]>
+
+ The support directory shouldn't be skipped unconditionally in test import
+ https://bugs.webkit.org/show_bug.cgi?id=135660
+
+ Reviewed by Ryosuke Niwa.
+
+ The 'DIRS_TO_SKIP' should only be skipped when in the root directory
+ of the test repo, as that's the only time they are special. In
+ addition, instead of hardcoding .hg and .git as special, skip all
+ directories that begin with '.', just like with files that begin with '.'.
+
+ In order to make this work, the root directory must always be
+ passed in, so the interface to the script has been changed to take the
+ root directory, and if one wants to only import a subset of the tests,
+ a new -t option can be used to limit the tests imported.
+
+ * Scripts/webkitpy/w3c/test_importer.py:
+ (main): Remove repo_dir command line argument.
+ (parse_args): Add -t option and set expected non-option args to 1.
+ (TestImporter.__init__): Remove repo_dir.
+ (TestImporter.do_import): Handle the varying number of import
+ directories.
+ (TestImporter.should_keep_subdir): Helper for find_importable_tests to
+ determine if a subdirectory should be skipped.
+ (TestImporter.find_importable_tests): Filter directories using new
+ helper.
+ (TestImporter.import_tests): Remove use of repo_dir.
+ (TestImporter.setup_destination_directory): Unused, Deleted.
+ * Scripts/webkitpy/w3c/test_importer_unittest.py:
+ (TestImporterTest.test_import_dir_with_no_tests_and_no_hg): Update for
+ new API.
+ (TestImporterTest.test_import_dir_with_no_tests): Ditto.
+
2014-08-07 Carlos Garcia Campos <[email protected]>
[GTK] Use WebKitNavigationAction also for WebKitNavigationPolicyDecision
Modified: trunk/Tools/Scripts/webkitpy/w3c/test_importer.py (172213 => 172214)
--- trunk/Tools/Scripts/webkitpy/w3c/test_importer.py 2014-08-07 16:23:05 UTC (rev 172213)
+++ trunk/Tools/Scripts/webkitpy/w3c/test_importer.py 2014-08-07 16:37:59 UTC (rev 172214)
@@ -93,22 +93,13 @@
def main(_argv, _stdout, _stderr):
options, args = parse_args()
import_dir = args[0]
- if len(args) == 1:
- repo_dir = import_dir
- else:
- repo_dir = args[1]
if not os.path.exists(import_dir):
sys.exit('Source directory %s not found!' % import_dir)
- if not os.path.exists(repo_dir):
- sys.exit('Repository directory %s not found!' % repo_dir)
- if not repo_dir in import_dir:
- sys.exit('Repository directory %s must be a parent of %s' % (repo_dir, import_dir))
-
configure_logging()
- test_importer = TestImporter(Host(), import_dir, repo_dir, options)
+ test_importer = TestImporter(Host(), import_dir, options)
test_importer.do_import()
@@ -129,23 +120,25 @@
def parse_args():
- parser = optparse.OptionParser(usage='usage: %prog [options] w3c_test_directory [repo_directory]')
+ parser = optparse.OptionParser(usage='usage: %prog [options] w3c_test_directory')
parser.add_option('-n', '--no-overwrite', dest='overwrite', action='', default=True,
help='Flag to prevent duplicate test files from overwriting existing tests. By default, they will be overwritten')
parser.add_option('-a', '--all', action='', default=False,
help='Import all tests including reftests, JS tests, and manual/pixel tests. By default, only reftests and JS tests are imported')
parser.add_option('-d', '--dest-dir', dest='destination', default='w3c',
help='Import into a specified directory relative to the LayoutTests root. By default, imports into w3c')
+ parser.add_option('-t', '--test-path', action='', dest='test_paths', default=[],
+ help='Import only tests in the supplied subdirectory of the w3c_test_directory. Can be supplied multiple times to give multiple paths')
options, args = parser.parse_args()
- if len(args) not in (1, 2):
+ if len(args) != 1:
parser.error('Incorrect number of arguments')
return options, args
class TestImporter(object):
- def __init__(self, host, source_directory, repo_dir, options):
+ def __init__(self, host, source_directory, options):
self.host = host
self.source_directory = source_directory
self.options = options
@@ -154,7 +147,6 @@
webkit_finder = WebKitFinder(self.filesystem)
self._webkit_root = webkit_finder.webkit_base()
- self.repo_dir = repo_dir
self.destination_directory = webkit_finder.path_from_webkit_base("LayoutTests", options.destination)
@@ -163,7 +155,11 @@
self.import_list = []
def do_import(self):
- self.find_importable_tests(self.source_directory)
+ if len(self.options.test_paths) == 0:
+ self.find_importable_tests(self.source_directory)
+ else:
+ for test_path in self.options.test_paths:
+ self.find_importable_tests(os.path.join(self.source_directory, test_path))
self.load_changeset()
self.import_tests()
@@ -174,6 +170,11 @@
except (OSError, ScriptError):
self.changeset = CHANGESET_NOT_AVAILABLE
+ def should_keep_subdir(self, root, subdir):
+ DIRS_TO_SKIP = ('work-in-progress', 'tools', 'support')
+ should_skip = subdir.startswith('.') or (root == self.source_directory and subdir in DIRS_TO_SKIP)
+ return not should_skip
+
def find_importable_tests(self, directory):
# FIXME: use filesystem
for root, dirs, files in os.walk(directory):
@@ -182,10 +183,7 @@
reftests = 0
jstests = 0
- DIRS_TO_SKIP = ('.git', '.hg', 'work-in-progress', 'tools', 'support')
- for d in DIRS_TO_SKIP:
- if d in dirs:
- dirs.remove(d)
+ dirs[:] = [subdir for subdir in dirs if self.should_keep_subdir(root, subdir)]
copy_list = []
@@ -273,7 +271,7 @@
orig_path = dir_to_copy['dirname']
- subpath = os.path.relpath(orig_path, self.repo_dir)
+ subpath = os.path.relpath(orig_path, self.source_directory)
new_path = os.path.join(self.destination_directory, subpath)
if not(os.path.exists(new_path)):
@@ -351,18 +349,6 @@
for prefixed_property in sorted(total_prefixed_properties, key=lambda p: total_prefixed_properties[p]):
_log.info(' %s: %s', prefixed_property, total_prefixed_properties[prefixed_property])
- def setup_destination_directory(self):
- """ Creates a destination directory that mirrors that of the source directory """
-
- new_subpath = self.source_directory[len(self.repo_dir):]
-
- destination_directory = os.path.join(self.destination_directory, new_subpath)
-
- if not os.path.exists(destination_directory):
- os.makedirs(destination_directory)
-
- _log.info('Tests will be imported into: %s', destination_directory)
-
def remove_deleted_files(self, import_directory, new_file_list):
""" Reads an import log in |import_directory|, compares it to the |new_file_list|, and removes files not in the new list."""
Modified: trunk/Tools/Scripts/webkitpy/w3c/test_importer_unittest.py (172213 => 172214)
--- trunk/Tools/Scripts/webkitpy/w3c/test_importer_unittest.py 2014-08-07 16:23:05 UTC (rev 172213)
+++ trunk/Tools/Scripts/webkitpy/w3c/test_importer_unittest.py 2014-08-07 16:37:59 UTC (rev 172214)
@@ -39,12 +39,12 @@
from webkitpy.w3c.test_importer import TestImporter
-FAKE_SOURCE_DIR = '/blink/w3c'
-FAKE_REPO_DIR = '/blink'
+FAKE_SOURCE_DIR = '/tests/csswg'
+FAKE_TEST_PATH = 'css-fake-1'
FAKE_FILES = {
- '/blink/w3c/empty_dir/README.txt': '',
- '/mock-checkout/LayoutTests/w3c/README.txt': '',
+ '/tests/csswg/css-fake-1/empty_dir/README.txt': '',
+ '/mock-checkout/LayoutTests/w3c/css-fake-1/README.txt': '',
}
class TestImporterTest(unittest.TestCase):
@@ -54,7 +54,7 @@
host.executive = MockExecutive2(exception=OSError())
host.filesystem = MockFileSystem(files=FAKE_FILES)
- importer = TestImporter(host, FAKE_SOURCE_DIR, FAKE_REPO_DIR, optparse.Values({"overwrite": False, 'destination': 'w3c'}))
+ importer = TestImporter(host, FAKE_SOURCE_DIR, optparse.Values({"overwrite": False, 'destination': 'w3c', 'test_paths': [FAKE_TEST_PATH]}))
oc = OutputCapture()
oc.capture_output()
@@ -68,7 +68,7 @@
host.executive = MockExecutive2(exception=ScriptError("abort: no repository found in '/Volumes/Source/src/wk/Tools/Scripts/webkitpy/w3c' (.hg not found)!"))
host.filesystem = MockFileSystem(files=FAKE_FILES)
- importer = TestImporter(host, FAKE_SOURCE_DIR, FAKE_REPO_DIR, optparse.Values({"overwrite": False, 'destination': 'w3c'}))
+ importer = TestImporter(host, FAKE_SOURCE_DIR, optparse.Values({"overwrite": False, 'destination': 'w3c', 'test_paths': [FAKE_TEST_PATH]}))
oc = OutputCapture()
oc.capture_output()
try: