Пример #1
0
 def __init__(self, filesystem=None):
     self.finder = TestFinder(filesystem or FileSystem())
     self.stream = sys.stderr
Пример #2
0
 def test_chdir__notexists(self):
     fs = FileSystem()
     newdir = '/dirdoesnotexist'
     if sys.platform == 'win32':
         newdir = 'c:\\dirdoesnotexist'
     self.assertRaises(OSError, fs.chdir, newdir)
Пример #3
0
 def test_exists__false(self):
     fs = FileSystem()
     self.assertFalse(fs.exists(self._missing_file))
Пример #4
0
 def test_read_text_file__missing(self):
     fs = FileSystem()
     self.assertRaises(IOError, fs.read_text_file, self._missing_file)
Пример #5
0
CHROME_DRIVER_URL = "http://chromedriver.storage.googleapis.com/"
FIREFOX_RELEASES_URL = "https://api.github.com/repos/mozilla/geckodriver/releases"

# Putting the autoinstall code into webkitpy/thirdparty/__init__.py
# ensures that no autoinstalling occurs until a caller imports from
# webkitpy.thirdparty.  This is useful if the caller wants to configure
# logging prior to executing autoinstall code.

# FIXME: If any of these servers is offline, webkit-patch breaks (and maybe
# other scripts do, too). See <http://webkit.org/b/42080>.

# We put auto-installed third-party modules in this directory--
#
#     webkitpy/thirdparty/autoinstalled

fs = FileSystem()
fs.maybe_make_directory(_AUTOINSTALLED_DIR)

init_path = fs.join(_AUTOINSTALLED_DIR, "__init__.py")
if not fs.exists(init_path):
    fs.write_text_file(init_path, "")

readme_path = fs.join(_AUTOINSTALLED_DIR, "README")
if not fs.exists(readme_path):
    fs.write_text_file(
        readme_path, "This directory is auto-generated by WebKit and is "
        "safe to delete.\nIt contains needed third-party Python "
        "packages automatically downloaded from the web.")


class AutoinstallImportHook(object):
Пример #6
0
 def __init__(self, cwd, executive=None, filesystem=None):
     self.cwd = cwd
     self._executive = executive or Executive()
     self._filesystem = filesystem or FileSystem()
     self.checkout_root = self.find_checkout_root(self.cwd)
Пример #7
0
 def test_isdir__false(self):
     fs = FileSystem()
     self.assertFalse(fs.isdir(self._this_file))
Пример #8
0
 def test_win(self):
     # This tests the actual windows platform, to ensure we get the same
     # results that we get in test_mocked_win().
     if sys.platform != 'win32':
         return
     self.assert_filesystem_normalizes(FileSystem())
Пример #9
0
 def setUp(self):
     self.executive = Executive()
     self.fs = FileSystem()
     self.original_cwd = self.fs.getcwd()
Пример #10
0
 def __init__(self, expectations, timeout, ignore_param):
     self._expectations = expectations
     self._timeout = timeout
     self._ignore_param = ignore_param
     self._base_dir = WebKitFinder(
         FileSystem()).path_from_webkit_base('WebDriverTests')
Пример #11
0
 def __init__(self, platform_info=None):
     # We cannot get the PlatformInfo object from a SystemHost because
     # User is part of SystemHost itself.
     self._platform_info = platform_info or PlatformInfo(
         sys, platform, FileSystem(), Executive())
Пример #12
0
def detect_scm_system(path, patch_directories=None):
    return SCMDetector(FileSystem(),
                       Executive()).detect_scm_system(path, patch_directories)
Пример #13
0
 def __init__(self):
     self._pylintrc = WebKitFinder(FileSystem()).path_from_webkit_base('Tools', 'Scripts', 'webkitpy', 'pylintrc')
Пример #14
0
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import logging
import os
import json
import sys

from multiprocessing import Process, Queue
from webkitpy.common.system.filesystem import FileSystem
from webkitpy.common.webkit_finder import WebKitFinder
import webkitpy.thirdparty.autoinstalled.mozlog
import webkitpy.thirdparty.autoinstalled.mozprocess
from mozlog import structuredlog

w3c_tools_dir = WebKitFinder(FileSystem()).path_from_webkit_base(
    'WebDriverTests', 'imported', 'w3c', 'tools')


def _ensure_directory_in_path(directory):
    if not directory in sys.path:
        sys.path.insert(0, directory)


_ensure_directory_in_path(os.path.join(w3c_tools_dir, 'webdriver'))
_ensure_directory_in_path(os.path.join(w3c_tools_dir, 'wptrunner'))

from wptrunner.executors.base import WdspecExecutor, WebDriverProtocol
from wptrunner.webdriver_server import WebDriverServer

pytest_runner = None
Пример #15
0
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import logging
import os
import json
import sys

from webkitpy.common.system.filesystem import FileSystem
from webkitpy.common.webkit_finder import WebKitFinder
import webkitpy.thirdparty.autoinstalled.mozlog
import webkitpy.thirdparty.autoinstalled.mozprocess
from mozlog import structuredlog

w3c_tools_dir = WebKitFinder(FileSystem()).path_from_webkit_base('WebDriverTests', 'imported', 'w3c', 'tools')


def _ensure_directory_in_path(directory):
    if not directory in sys.path:
        sys.path.insert(0, directory)
_ensure_directory_in_path(os.path.join(w3c_tools_dir, 'webdriver'))
_ensure_directory_in_path(os.path.join(w3c_tools_dir, 'wptrunner'))

from wptrunner.executors.base import WdspecExecutor, WebDriverProtocol
from wptrunner.webdriver_server import WebDriverServer

pytest_runner = None


def do_delayed_imports():
Пример #16
0
 def __init__(self, filesystem=None):
     self.finder = Finder(filesystem or FileSystem())
     self.printer = Printer(sys.stderr)
     self._options = None
Пример #17
0
 def load_test_repositories(filesystem=FileSystem()):
     webkit_finder = WebKitFinder(filesystem)
     test_repositories_path = webkit_finder.path_from_webkit_base(
         'LayoutTests', 'imported', 'w3c', 'resources', 'TestRepositories')
     return json.loads(filesystem.read_text_file(test_repositories_path))
Пример #18
0
def parse_args(args):
    description = """
To import a web-platform-tests test suite named xyz, use: 'import-w3c-tests web-platform-tests/xyz'.
To import a csswg-test test suite named abc, use 'import-w3c-tests csswg-test/abc'.
To import a web-platform-tests/csswg-test test suite from a specific folder, use 'import-w3c-tests web-platform-tests/xyz -s my-folder-containing-web-platform-tests-folder'"""
    parser = argparse.ArgumentParser(
        prog='import-w3c-tests [web-platform-tests/test-suite-name...]',
        description=description,
        formatter_class=argparse.RawDescriptionHelpFormatter)

    parser.add_argument(
        '-n',
        '--no-overwrite',
        dest='overwrite',
        action='store_false',
        default=True,
        help=
        'Flag to prevent duplicate test files from overwriting existing tests. By default, they will be overwritten'
    )
    parser.add_argument(
        '-l',
        '--no-links-conversion',
        dest='convert_test_harness_links',
        action='store_false',
        default=True,
        help=
        'Do not change links (testharness js or css e.g.). This option only applies when providing a source directory, in which case by default, links are converted to point to WebKit testharness files. When tests are downloaded from W3C repository, links are converted for CSS tests and remain unchanged for WPT tests'
    )

    parser.add_argument(
        '-a',
        '--all',
        action='store_true',
        default=False,
        help=
        'Import all tests including reftests, JS tests, and manual/pixel tests. By default, only reftests and JS tests are imported'
    )
    fs = FileSystem()
    parser.add_argument(
        '-d',
        '--dest-dir',
        dest='destination',
        default=fs.join('imported', 'w3c'),
        help=
        'Import into a specified directory relative to the LayoutTests root. By default, imports into imported/w3c'
    )

    parser.add_argument(
        '-s',
        '--src-dir',
        dest='source',
        default=None,
        help=
        'Import from a specific folder which contains web-platform-tests and/or csswg-test folders. If not provided, the script will clone the necessary repositories.'
    )

    parser.add_argument('-v',
                        '--verbose',
                        action='store_true',
                        default=False,
                        help='Print maximal log')
    parser.add_argument(
        '--no-fetch',
        action='store_false',
        dest='fetch',
        default=True,
        help=
        'Do not fetch the repositories. By default, repositories are fetched if a source directory is not provided'
    )
    parser.add_argument(
        '--import-all',
        action='store_true',
        default=False,
        help=
        'Ignore the import-expectations.json file. All tests will be imported. This option only applies when tests are downloaded from W3C repository'
    )

    parser.add_argument(
        '--clean-dest-dir',
        action='store_true',
        dest='clean_destination_directory',
        default=False,
        help=
        'Clean destination directory. All files in the destination directory will be deleted except for WebKit specific files (test expectations, .gitignore...) before new tests import. Dangling test expectations (expectation file that is no longer related to a test) are removed after tests import.'
    )

    options, args = parser.parse_known_args(args)
    return options, args
Пример #19
0
 def test_isdir__true(self):
     fs = FileSystem()
     self.assertTrue(fs.isdir(self._this_dir))
Пример #20
0
 def cleanup_http_lock(self):
     """Delete the lock file if exists."""
     if os.path.exists(self._process_lock_file_name):
         _log.debug("Removing lock file: %s" % self._process_lock_file_name)
         FileSystem().remove(self._process_lock_file_name)
Пример #21
0
 def test_join(self):
     fs = FileSystem()
     self.assertEqual(fs.join('foo', 'bar'), os.path.join('foo', 'bar'))
Пример #22
0
 def __init__(self, filesystem=None):
     self.finder = Finder(filesystem or FileSystem())
     self.printer = Printer(sys.stderr)
     self._options = None
     self.upload_style = 'release'
Пример #23
0
    def test_sep(self):
        fs = FileSystem()

        self.assertEqual(fs.sep, os.sep)
        self.assertEqual(fs.join("foo", "bar"), os.path.join("foo", "bar"))
Пример #24
0
 def __init__(self, fileset, filename, filesystem=None):
     self._filename = filename
     self._fileset = fileset
     self._contents = None
     self._filesystem = filesystem or FileSystem()
Пример #25
0
 def __init__(self, filesystem=None):
     self._fs = filesystem or FileSystem()
Пример #26
0
def parse_args(args):
    parser = argparse.ArgumentParser(
        prog='import-w3c-tests [w3c_test_source_directory]')

    parser.add_argument(
        '-n',
        '--no-overwrite',
        dest='overwrite',
        action='store_false',
        default=True,
        help=
        'Flag to prevent duplicate test files from overwriting existing tests. By default, they will be overwritten'
    )
    parser.add_argument(
        '-l',
        '--no-links-conversion',
        dest='convert_test_harness_links',
        action='store_false',
        default=True,
        help=
        'Do not change links (testharness js or css e.g.). This option only applies when providing a source directory, in which case by default, links are converted to point to WebKit testharness files. When tests are downloaded from W3C repository, links are converted for CSS tests and remain unchanged for WPT tests'
    )

    parser.add_argument(
        '-a',
        '--all',
        action='store_true',
        default=False,
        help=
        'Import all tests including reftests, JS tests, and manual/pixel tests. By default, only reftests and JS tests are imported'
    )
    fs = FileSystem()
    parser.add_argument(
        '-d',
        '--dest-dir',
        dest='destination',
        default=fs.join('imported', 'w3c'),
        help=
        'Import into a specified directory relative to the LayoutTests root. By default, imports into imported/w3c'
    )

    list_of_repositories = ' or '.join([
        test_repository['name']
        for test_repository in TestDownloader.load_test_repositories()
    ])
    parser.add_argument(
        '-t',
        '--test-path',
        action='append',
        dest='test_paths',
        default=[],
        help=
        'Import only tests in the supplied subdirectory of the source directory. Can be supplied multiple times to give multiple paths. For tests directly cloned from W3C repositories, use '
        + list_of_repositories + ' prefixes to filter specific tests')

    parser.add_argument('-v',
                        '--verbose',
                        action='store_true',
                        default=False,
                        help='Print maximal log')
    parser.add_argument(
        '--no-fetch',
        action='store_false',
        dest='fetch',
        default=True,
        help=
        'Do not fetch the repositories. By default, repositories are fetched if a source directory is not provided'
    )
    parser.add_argument(
        '--import-all',
        action='store_true',
        default=False,
        help=
        'Ignore the ImportExpectations file. All tests will be imported. This option only applies when tests are downloaded from W3C repository'
    )

    parser.add_argument(
        '--clean-dest-dir',
        action='store_true',
        dest='clean_destination_directory',
        default=False,
        help=
        'Clean destination directory. All files in the destination directory will be deleted except for WebKit specific files (test expectations, .gitignore...) before new tests import. Dangling test expectations (expectation file that is no longer related to a test) are removed after tests import.'
    )

    options, args = parser.parse_known_args(args)
    if len(args) > 1:
        parser.error('Incorrect number of arguments')
    return options, args
Пример #27
0
 def test_exists__true(self):
     fs = FileSystem()
     self.assertTrue(fs.exists(self._this_file))
Пример #28
0
 def __init__(self, path, filesystem=None):
     self.path = path
     self._filesystem = filesystem or FileSystem()
Пример #29
0
 def test_getcwd(self):
     fs = FileSystem()
     self.assertTrue(fs.exists(fs.getcwd()))
Пример #30
0
 def __init__(self, filesystem=None, webkit_finder=None):
     self.filesystem = filesystem or FileSystem()
     self.finder = Finder(self.filesystem)
     self.printer = Printer(sys.stderr)
     self.webkit_finder = webkit_finder or WebKitFinder(self.filesystem)
     self._options = None