def test_import_dir_with_no_tests(self):
        host = MockHost()
        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'
            }))
        oc = OutputCapture()
        oc.capture_output()
        try:
            importer.do_import()
        finally:
            oc.restore_output()
Ejemplo n.º 2
0
    def run(self):
        logging.info('Monitoring process ID: %s' % self.process_id)

        self.debugger = SyscallTracer(
            options=optparse.Values({
                'fork': False,
                'enter': False,
                'show_ip': False,
                'trace_exec': True,
                'no_stdout': False,
                'pid': self.process_id,
                'show_pid': True,
            }),
            program=None,
            ignore_syscall_callback=self.ignore_syscall_callback,
            syscall_callback=self.syscall_callback,
            event_callback=self.event_callback,
            quit_callback=self.quit_callback)
        self.debugger.main()
Ejemplo n.º 3
0
    def test_lint_test_files__errors(self):
        options = optparse.Values({'platform': 'test', 'debug_rwt_logging': False})
        host = MockHost()

        # FIXME: incorrect complaints about spacing pylint: disable=C0322
        port = host.port_factory.get(options.platform, options=options)
        port.expectations_dict = lambda: {'foo': '-- syntax error1', 'bar': '-- syntax error2'}

        host.port_factory.get = lambda platform, options=None: port
        host.port_factory.all_port_names = lambda platform=None: [port.name()]

        logging_stream = StringIO.StringIO()

        res = lint_test_expectations.lint(host, options, logging_stream)

        self.assertEqual(res, -1)
        self.assertIn('Lint failed', logging_stream.getvalue())
        self.assertIn('foo:1', logging_stream.getvalue())
        self.assertIn('bar:1', logging_stream.getvalue())
    def test_server_fails_to_start_throws_exception(self):
        host = MockHost()
        options = optparse.Values()
        options.ensure_value("results_directory", "/mock/output_dir")
        port = Port(host, "test", options)
        server = WebPlatformTestServer(port, "wpttest",
                                       "/mock/output_dir/pid.txt")
        server._check_that_all_ports_are_available = lambda: True
        server._is_server_running_on_all_ports = lambda: True
        host.filesystem.write_text_file(
            "/mock-checkout/LayoutTests/resources/testharness.js", "0")
        host.filesystem.write_text_file(
            "/mock-checkout/LayoutTests/imported/w3c/web-platform-tests/resources/testharness.js",
            "0")

        server.start()
        server.stop()
        server._process.poll = lambda: 1
        self.assertRaises(ServerError, server.start)
Ejemplo n.º 5
0
 def assert_execute_outputs(
         self, command, args=None, expected_stdout="", expected_stderr="",
         expected_exception=None, expected_logs=None, options=optparse.Values(), tool=MockWebKitPatch()):
     args = args or []
     options.blocks = None
     options.cc = 'MOCK cc'
     options.component = 'MOCK component'
     options.confirm = True
     options.email = 'MOCK email'
     options.git_commit = 'MOCK git commit'
     options.obsolete_patches = True
     options.open_bug = True
     options.port = 'MOCK port'
     options.update_changelogs = False
     options.quiet = True
     options.reviewer = 'MOCK reviewer'
     OutputCapture().assert_outputs(
         self, command.execute, [options, args, tool], expected_stdout=expected_stdout,
         expected_stderr=expected_stderr, expected_exception=expected_exception, expected_logs=expected_logs)
Ejemplo n.º 6
0
    def format_parameters(self):
        self.keyname = self.novaclient.keypairs.list().pop().name

        self.testcase.assertTrue(self.heatclient)

        full_paramstr = ';'.join([self.stack_paramstr,
                                  'KeyName=' + self.keyname,
                                  'LinuxDistribution=' + self.distribution])
        template_params = optparse.Values({'parameters': full_paramstr})

        # Format parameters and create the stack
        parameters = {}
        parameters['StackName'] = self.stackname
        template_path = os.path.join(basepath,
                                     'templates',
                                     self.template_file)
        parameters['TemplateBody'] = open(template_path).read()
        parameters.update(self.heatclient.format_parameters(template_params))
        return parameters
Ejemplo n.º 7
0
    def test_import_dir_with_no_tests_and_no_hg(self):
        host = MockHost()
        host.executive = MockExecutive2(exception=OSError())
        host.filesystem = MockFileSystem(files=FAKE_FILES)

        importer = TestImporter(
            host, FAKE_SOURCE_DIR,
            optparse.Values({
                "overwrite": False,
                'destination': 'w3c',
                'test_paths': [FAKE_TEST_PATH]
            }))

        oc = OutputCapture()
        oc.capture_output()
        try:
            importer.do_import()
        finally:
            oc.restore_output()
Ejemplo n.º 8
0
def inject_options(roles, options):
    new_options = optparse.Values(options.__dict__)
    for key in ('ignore', 'select'):

        if 'set-' + key in roles:
            values = [
                value.strip() for value in roles['set-' + key].split(',')
            ]
            setattr(new_options, key, values)

        if 'add-' + key in roles:
            values = {
                value.strip()
                for value in roles['add-' + key].split(',')
            }
            values.update(new_options.__dict__[key])
            setattr(new_options, key, list(values))

    return new_options
Ejemplo n.º 9
0
def rtactivate(nameserver, tags):
    def activate_action(object, ec_index):
        object.activate_in_ec(ec_index)

    for tag in tags:

        # check if/unless attribute in rtactivate tags
        exec_flag = True
        if tag.attributes.get(u'if'):
            val = tag.attributes.get(u'if').value
            arg = val.split(" ")[1].strip(")")  # To "USE_WALKING"
            exec_flag = get_flag_from_argv(arg)
        if tag.attributes.get(u'unless'):
            val = tag.attributes.get(u'unless').value
            arg = val.split(" ")[1].strip(")")  # To "USE_WALKING"
            exec_flag = not get_flag_from_argv(arg)
        if not exec_flag:
            continue

        cmd_path = nameserver + "/" + tag.attributes.get("component").value
        full_path = path.cmd_path_to_full_path(cmd_path)
        # print >>sys.stderr, "[rtmlaunch] activate %s"%(full_path)
        try:
            state = wait_component(full_path)
            if state == 'Active':
                continue
            else:
                print >> sys.stderr, "[rtmlaunch] Activate <-", state, full_path
        except Exception, e:
            print >> sys.stderr, '\033[31m[rtmlaunch] Could not Activate (', cmd_path, ') : ', e, '\033[0m'
            return 1
        try:
            options = optparse.Values({"ec_index": 0, 'verbose': False})
            try:
                state_control_base.alter_component_state(
                    activate_action, cmd_path, full_path, options, None)
            except Exception, e:  # openrtm 1.1.0
                state_control_base.alter_component_states(
                    activate_action, [(cmd_path, full_path)], options, None)
        except Exception, e:
            print >> sys.stderr, '[rtmlaunch] {0}: {1}'.format(
                os.path.basename(sys.argv[0]), e)
            return 1
    def test_corrupted_subserver_files(self):
        host = MockHost()
        options = optparse.Values()
        options.ensure_value("results_directory", "/mock/output_dir")
        port = Port(host, "test", options)
        server = WebPlatformTestServer(port, "wpttest",
                                       "/mock/output_dir/pid.txt")
        server._check_that_all_ports_are_available = lambda: True
        server._is_server_running_on_all_ports = lambda: True
        host.filesystem.write_text_file(
            "/mock-checkout/LayoutTests/resources/testharness.js", "0")
        host.filesystem.write_text_file(
            "/mock-checkout/LayoutTests/imported/w3c/web-platform-tests/resources/testharness.js",
            "0")

        host.filesystem.write_text_file(
            "/mock_output_dir/wpttest_servers.json", "0")
        server.stop()
        self.assertFalse(
            host.filesystem.exists("/mock/output_dir/wpttest_servers.json"))

        host.filesystem.write_text_file(
            "/mock_output_dir/wpttest_servers.json", "[0,")
        server.start()
        self.assertFalse(
            host.filesystem.exists("/mock/output_dir/wpttest_servers.json"))
        server.stop()

        host.filesystem.write_text_file(
            "/mock_output_dir/wpttest_servers.json",
            "[{'protocol': 'http', 'port': 80 }]")
        server.start()
        self.assertFalse(
            host.filesystem.exists("/mock/output_dir/wpttest_servers.json"))
        server.stop()

        host.filesystem.write_text_file(
            "/mock_output_dir/wpttest_servers.json",
            "[{'protocol': 'http', 'port': 80, 'pid': {} }]")
        server.start()
        self.assertFalse(
            host.filesystem.exists("/mock/output_dir/wpttest_servers.json"))
        server.stop()
Ejemplo n.º 11
0
    def test_default_expectations_ordering(self):
        port = self.make_port()
        for path in port.default_expectations_files():
            port.host.filesystem.write_text_file(path, '')
        ordered_dict = port.expectations_dict()
        self.assertEqual(port.path_to_generic_test_expectations_file(),
                         list(ordered_dict)[0])

        options = optparse.Values(
            dict(additional_expectations=['/tmp/foo', '/tmp/bar']))
        port = self.make_port(options=options)
        for path in port.default_expectations_files():
            port.host.filesystem.write_text_file(path, '')
        port.host.filesystem.write_text_file('/tmp/foo', 'foo')
        port.host.filesystem.write_text_file('/tmp/bar', 'bar')
        ordered_dict = port.expectations_dict()
        self.assertEqual(
            list(ordered_dict)[-2:], options.additional_expectations)
        self.assertEqual(list(ordered_dict.values())[-2:], ['foo', 'bar'])
Ejemplo n.º 12
0
 def test_only_wpt_in_android_override_files(self):
     options = optparse.Values({
         'additional_expectations': [],
         'platform': 'test',
         'debug_rwt_logging': False
     })
     host = MockHost()
     port = host.port_factory.get(options.platform, options=options)
     raw_expectations = ('# results: [ Failure ]\n'
                         'external/wpt/test.html [ Failure ]\n'
                         'non-wpt/test.html [ Failure ]\n')
     for path in PRODUCTS_TO_EXPECTATION_FILE_PATHS.values():
         host.filesystem.write_text_file(path, raw_expectations)
     host.port_factory.get = lambda platform, options=None: port
     host.port_factory.all_port_names = lambda platform=None: [port.name()]
     port.test_exists = lambda _: True
     port.tests = lambda _: {'external/wpt/test.html', 'non-wpt/test.html'}
     failures, _ = lint_test_expectations.lint(host, options)
     self.assertTrue(all('is for a non WPT test' in f for f in failures))
Ejemplo n.º 13
0
    def __init__(self,
                 stdin="/dev/null",
                 stdout="/dev/null",
                 stderr="/dev/null",
                 conf="./insync.conf",
                 pidfile=None,
                 user=None,
                 group=None):
        options = dict(
            stdin=stdin,
            stdout=stdout,
            stderr=stderr,
            pidfile=pidfile,
            user=user,
            group=group,
            conf=conf,
        )

        self.options = optparse.Values(options)
    def _TestArguments(self, force):
        opts = optparse.Values(
            dict(status_filter=None, force=force, kill=False))

        def _CancelCb(job_id):
            self.assertTrue(job_id in ("24185", "3252"))
            return (True, "%s will be cancelled" % job_id)

        cl = _ClientForCancelJob(_CancelCb, NotImplemented)
        self.assertEqual(
            gnt_job.CancelJobs(opts, ["24185", "3252"],
                               cl=cl,
                               _stdout_fn=self._ToStdout,
                               _ask_fn=NotImplemented), constants.EXIT_SUCCESS)
        self.assertEqual(cl.cancelled, ["24185", "3252"])
        self.assertEqual(self.stdout, [
            "24185 will be cancelled",
            "3252 will be cancelled",
        ])
Ejemplo n.º 15
0
 def parse_dest(self, dest):
     try:
         dest, ssl = re.subn("^imaps:", "imap:", dest)
         dest = urlparse(dest)
         options = optparse.Values()
         options.ssl = bool(ssl)
         options.host = dest.hostname
         options.port = [143, 993][options.ssl]
         if dest.port:
             options.port = dest.port
         if dest.username:
             options.user = urllib.unquote(dest.username)
         if dest.password:
             options.password = urllib.unquote(dest.password)
         if len(dest.path):
             options.box = dest.path[1:] # trim the first `/'
         return options
     except:
         self.error("Invalid DEST")
Ejemplo n.º 16
0
    def test_rebaseline_test_internal_with_port_that_lacks_buildbot(self):
        self.tool.executive = MockExecutive()

        port = self.tool.port_factory.get('test-win-win7')
        self._write(
            port.host.filesystem.join(
                port.layout_tests_dir(),
                'platform/test-win-win10/failures/expected/image-expected.txt'
            ), 'original win10 result')

        oc = OutputCapture()
        try:
            options = optparse.Values({
                'optimize': True,
                'builder': 'MOCK Win10',
                'port_name': None,
                'suffixes': 'txt',
                'verbose': True,
                'test': 'failures/expected/image.html',
                'results_directory': None,
                'build_number': None
            })
            oc.capture_output()
            self.command.execute(options, [], self.tool)
        finally:
            out, _, _ = oc.restore_output()

        self.assertMultiLineEqual(
            self._read(
                self.tool.filesystem.join(
                    port.layout_tests_dir(),
                    'platform/test-win-win10/failures/expected/image-expected.txt'
                )), 'MOCK Web result, convert 404 to None=True')
        self.assertFalse(
            self.tool.filesystem.exists(
                self.tool.filesystem.join(
                    port.layout_tests_dir(),
                    'platform/test-win-win7/failures/expected/image-expected.txt'
                )))
        self.assertMultiLineEqual(
            out,
            '{"remove-lines": [{"test": "failures/expected/image.html", "port_name": "test-win-win10"}]}\n'
        )
Ejemplo n.º 17
0
    def test_rebaseline_test_internal_with_port_that_lacks_buildbot(self):
        self.tool.executive = MockExecutive()

        port = self.tool.port_factory.get('test-win-win7')
        baseline_relative_path = 'platform/test-win-win10/failures/expected/image-expected.txt'
        baseline_local_absolute_path = port.host.filesystem.join(
            port.web_tests_dir(), baseline_relative_path)
        self._write(baseline_local_absolute_path, 'original win10 result')
        actual_result_url = (
            'https://test-results.appspot.com/data/layout_results/MOCK_Win10/'
            + 'results/layout-test-results/failures/expected/image-actual.txt')
        self.tool.web.urls[actual_result_url] = 'new win10 result'

        oc = OutputCapture()
        try:
            options = optparse.Values({
                'optimize': True,
                'builder': 'MOCK Win10',
                'port_name': None,
                'suffixes': 'txt',
                'verbose': True,
                'test': 'failures/expected/image.html',
                'results_directory': None,
                'build_number': None,
                'step_name': None,
                'flag_specific': None,
            })
            oc.capture_output()
            self.command.execute(options, [], self.tool)
        finally:
            out, _, _ = oc.restore_output()

        self.assertItemsEqual(self.tool.web.urls_fetched, [actual_result_url])
        self.assertMultiLineEqual(self._read(baseline_local_absolute_path),
                                  'new win10 result')
        self.assertFalse(
            self.tool.filesystem.exists(
                self.tool.filesystem.join(
                    port.web_tests_dir(),
                    'platform/test-win-win7/failures/expected/image-expected.txt'
                )))
        # We should not change TestExpectations for unexpected failures.
        self.assertMultiLineEqual(out, '')
Ejemplo n.º 18
0
def handle_args(argv):
    """Gets the config name from the command line arguments."""
    if len(argv) <= 1:
        usage('Must specify a config.')
    if argv[1] in ('-h', '--help', 'help'):
        usage()

    dry_run = False
    nohooks = False
    no_history = False
    force = False
    while len(argv) >= 2:
        arg = argv[1]
        if not arg.startswith('-'):
            break
        argv.pop(1)
        if arg in ('-n', '--dry-run'):
            dry_run = True
        elif arg == '--nohooks':
            nohooks = True
        elif arg == '--no-history':
            no_history = True
        elif arg == '--force':
            force = True
        else:
            usage('Invalid option %s.' % arg)

    def looks_like_arg(arg):
        return arg.startswith('--') and arg.count('=') == 1

    bad_parms = [x for x in argv[2:] if not looks_like_arg(x)]
    if bad_parms:
        usage('Got bad arguments %s' % bad_parms)

    config = argv[1]
    props = argv[2:]
    return (optparse.Values({
        'dry_run': dry_run,
        'nohooks': nohooks,
        'no_history': no_history,
        'force': force
    }), config, props)
Ejemplo n.º 19
0
    def test_virtual_test_redundant_expectation(self):
        options = optparse.Values({
            'additional_expectations': [],
            'platform': 'test',
            'debug_rwt_logging': False
        })
        host = MockHost()

        port = host.port_factory.get(options.platform, options=options)
        port.virtual_test_suites = lambda: [
            VirtualTestSuite(
                prefix='foo', bases=['test', 'external/wpt'], args=['--foo'])
        ]
        test_expectations = (
            '# tags: [ mac win ]\n'
            '# tags: [ debug release ]\n'
            '# results: [ Failure Pass ]\n'
            '[ mac ] test/test1.html [ Failure ]\n'
            '[ mac debug ] virtual/foo/test/test1.html [ Failure ]\n'
            '[ win ] virtual/foo/test/test1.html [ Failure ]\n'
            '[ mac release ] virtual/foo/test/test1.html [ Pass ]\n'
            'test/test2.html [ Failure ]\n'
            'crbug.com/1234 virtual/foo/test/test2.html [ Failure ]\n'
            'test/subtest/test2.html [ Failure ]\n'
            'virtual/foo/test/subtest/* [ Pass ]\n'
            'virtual/foo/test/subtest/test2.html [ Failure ]\n'
            'external/wpt/wpt.html [ Failure ]\n'
            # TODO(crbug.com/1080691): This is redundant with the above one, but
            # for now we intentially ignore it.
            'virtual/foo/external/wpt/wpt.html [ Failure ]\n')
        port.expectations_dict = lambda: {
            'testexpectations': test_expectations
        }
        port.test_exists = lambda test: True
        host.port_factory.get = lambda platform=None, options=None: port
        host.port_factory.all_port_names = lambda platform=None: [port.name()]

        failures, warnings = lint_test_expectations.lint(host, options)
        self.assertEqual(failures, [])

        self.assertEquals(len(warnings), 1)
        self.assertRegexpMatches(warnings[0], ':5 .*redundant with.* line 4$')
Ejemplo n.º 20
0
    def test_extra_files_errors(self):
        options = optparse.Values({
            'platform': 'test',
            'debug_rwt_logging': False
        })
        host = MockHost()

        port = host.port_factory.get(options.platform, options=options)
        port.expectations_dict = lambda: {}

        host.port_factory.get = lambda platform, options=None: port
        host.port_factory.all_port_names = lambda platform=None: [port.name()]
        host.filesystem.write_text_file(
            '/test.checkout/wtests/LeakExpectations', '-- syntax error')

        res = lint_test_expectations.lint(host, options)

        self.assertTrue(res)
        all_logs = ''.join(self.logMessages())
        self.assertIn('LeakExpectations:1', all_logs)
Ejemplo n.º 21
0
def get_parsed_args():
    parser = optparse.OptionParser()
    parser.add_option('-c',
                      '--clean',
                      action='store_true',
                      default=False,
                      dest='clean')
    parser.add_option('-v',
                      '--verbose',
                      action='store_true',
                      default=False,
                      dest='verbose',
                      help='Print out stacktraces for errors in checks')

    try:
        options, args = parser.parse_args()
    except SystemExit:
        # Ignore parse errors
        options, args = optparse.Values({'clean': False}), []
    return options, args
Ejemplo n.º 22
0
    def dropIndexes(self):
        if len(self.index_create_cmds) > 0:
            popup_message(
                "Index drop previously executed",
                "A prior execution of index drop has been detected. This invocation is aborted."
            )
            return

        opts = self.dbPane.getDbOptions()
        dbConn = getDbConnection(optparse.Values(opts))
        indexes = dbConn.execute(
            "SELECT (schemaname || '.' || indexname) index_name, indexdef index_create_cmd \
                                    FROM pg_indexes \
                                   WHERE tablename = 'v_fact_data' AND indexname NOT LIKE 'v_fact_data_test_pkey'"
        )
        for index in indexes:
            self.index_create_cmds.append(index.index_create_cmd)
            dbConn.execute("DROP INDEX %s" % index.index_name)

        dbConn.close()
Ejemplo n.º 23
0
 def test_process(self):
     self.create('somechannel-20130316.log')
     self.create('somechannel-20130316.log.html')
     self.create('somechannel-20130317.log')
     self.create('somechannel-20130318.log')
     options = optparse.Values(dict(searchbox=True, dircproxy=True,
                                    pattern='*.log', force=False,
                                    prefix='IRC logs for ', output_dir=None,
                                    style='xhtmltable', title='IRC logs'))
     process(self.tmpdir, options)
     self.assertTrue(os.path.exists(self.filename('index.html')))
     if hasattr(os, 'symlink'):
         self.assertTrue(os.path.exists(self.filename('latest.log.html')))
     self.assertTrue(os.path.exists(self.filename('irclog.css')))
     self.assertTrue(os.path.exists(
         self.filename('somechannel-20130316.log.html')))
     self.assertTrue(os.path.exists(
         self.filename('somechannel-20130317.log.html')))
     self.assertTrue(os.path.exists(
         self.filename('somechannel-20130318.log.html')))
Ejemplo n.º 24
0
def configure_pg_hba_ambaridb_users():
  args = optparse.Values()
  configure_postgres_username_password(args)

  with open(PG_HBA_CONF_FILE, "a") as pgHbaConf:
    pgHbaConf.write("\n")
    pgHbaConf.write("local  all  " + args.postgres_username +
                    ",mapred md5")
    pgHbaConf.write("\n")
    pgHbaConf.write("host  all   " + args.postgres_username +
                    ",mapred 0.0.0.0/0  md5")
    pgHbaConf.write("\n")
    pgHbaConf.write("host  all   " + args.postgres_username +
                    ",mapred ::/0 md5")
    pgHbaConf.write("\n")
  command = PG_HBA_RELOAD_CMD.format(PG_HBA_DIR)
  retcode, out, err = run_os_command(command)
  if not retcode == 0:
    print err
    sys.exit(retcode)
Ejemplo n.º 25
0
    def simplifyExtent(self):
        taxonKey = int(self.taxonKeyToSimplify.get())

        print("Simplifying taxon: %s" % taxonKey)

        dbConn = getDbConnection(optparse.Values(self.dbPane.getDbOptions()))

        dbConn.execute((
            "WITH ext(taxon_key, geom) AS (" +
            "  SELECT e.taxon_key, (st_dump(geom)).geom" +
            "    FROM distribution.taxon_extent e" +
            "   WHERE e.taxon_key = %(tk)s" + ")" +
            "UPDATE distribution.taxon_extent e" +
            "   SET geom = (SELECT ST_MULTI(ST_Union(ST_Buffer(ST_SimplifyPreserveTopology(geom, 0.01), 0.25)))"
            + "                         FROM ext" +
            "                        GROUP BY ext.taxon_key)" +
            " WHERE e.taxon_key = %(tk)s") % {"tk": taxonKey})

        print("Taxon %s simplified. Please review resulting extent." %
              taxonKey)
    def test_lint_test_files__errors(self):
        options = optparse.Values({'platform': 'test', 'debug_rwt_logging': False})
        host = MockHost()

        port = host.port_factory.get(options.platform, options=options)
        port.expectations_dict = lambda: {'foo': '-- syntax error1', 'bar': '-- syntax error2'}

        host.port_factory.get = lambda platform, options=None: port
        host.port_factory.all_port_names = lambda platform=None: [port.name()]

        logging_stream = StringIO.StringIO()
        logger, handler = lint_test_expectations.set_up_logging(logging_stream)
        try:
            res = lint_test_expectations.lint(host, options)
        finally:
            lint_test_expectations.tear_down_logging(logger, handler)

        self.assertTrue(res)
        self.assertIn('foo:1', logging_stream.getvalue())
        self.assertIn('bar:1', logging_stream.getvalue())
    def test_lint_flag_specific_expectation_errors(self):
        options = optparse.Values({'platform': 'test', 'debug_rwt_logging': False})
        host = MockHost()

        port = host.port_factory.get(options.platform, options=options)
        port.expectations_dict = lambda: {'flag-specific': 'does/not/exist', 'noproblem': ''}

        host.port_factory.get = lambda platform, options=None: port
        host.port_factory.all_port_names = lambda platform=None: [port.name()]

        logging_stream = StringIO.StringIO()
        logger, handler = lint_test_expectations.set_up_logging(logging_stream)
        try:
            res = lint_test_expectations.lint(host, options)
        finally:
            lint_test_expectations.tear_down_logging(logger, handler)

        self.assertTrue(res)
        self.assertIn('flag-specific:1 Path does not exist. does/not/exist', logging_stream.getvalue())
        self.assertNotIn('noproblem', logging_stream.getvalue())
Ejemplo n.º 28
0
 def test_get_run_command_default_and_list_expands(self):
     ui, command = self.get_test_ui_and_cmd()
     if v2_avail:
         buffer = BytesIO()
         stream = subunit.StreamResultToBytes(buffer)
         stream.status(test_id='returned', test_status='exists')
         stream.status(test_id='ids', test_status='exists')
         subunit_bytes = buffer.getvalue()
     else:
         subunit_bytes = _b('returned\nids\n')
     ui.proc_outputs = [subunit_bytes]
     ui.options = optparse.Values()
     ui.options.parallel = True
     ui.options.concurrency = 2
     self.set_config('[DEFAULT]\ntest_command=foo $IDLIST $LISTOPT\n'
                     'test_id_list_default=whoo yea\n'
                     'test_list_option=--list\n')
     fixture = self.useFixture(command.get_run_command())
     expected_cmd = 'foo returned ids '
     self.assertEqual(expected_cmd, fixture.cmd)
    def test_import_dir_with_no_tests(self):
        # FIXME: Use MockHosts instead.
        host = Host()
        host.executive = MockExecutive2(exception=ScriptError(
            "abort: no repository found in '/Volumes/Source/src/wk/Tools/Scripts/webkitpy/w3c' (.hg not found)!"
        ))

        importer = TestImporter(host, '/w3c', '/blink',
                                optparse.Values({"overwrite": False}))
        importer.source_directory = importer.path_from_webkit_root(
            "Tools", "Scripts", "webkitpy", "w3c")
        importer.destination_directory = tempfile.mkdtemp(prefix='csswg')

        oc = OutputCapture()
        oc.capture_output()
        try:
            importer.do_import()
        finally:
            oc.restore_output()
            shutil.rmtree(importer.destination_directory, ignore_errors=True)
Ejemplo n.º 30
0
    def load_command_line(self, conf_only=False):
        '''
        Load config from command line switches.
        NOTE: Not all config is available on the command line.
        '''
        # did we already parse cli (i.e. to get conf file)? don't run twice
        if self._cli_opts:
            self._update_dict(self._cli_opts)
            return
        parser = optparse.OptionParser()
        debug_grp = optparse.OptionGroup(parser, "Debug options")
        platf_grp = optparse.OptionGroup(parser, "Platform options")
        cli_options = dict(
            (k, v) for k, v in DEFAULT_OPTS.items() if ('opt' in v))
        for _, o in cli_options.items():
            group = o.pop('group', None)
            if group == 'debug':
                g = debug_grp
            elif group == 'platform':
                g = platf_grp
            else:
                g = parser
            optnames = o.pop('opt')
            g.add_option(*optnames, **o)

        parser.add_option_group(debug_grp)

        # To be revealed... one day.
        # parser.add_option_group(platf_grp)

        # pass in optparse.Values() to get only options that were specified
        options, args = parser.parse_args(values=optparse.Values())
        if len(args) > 0:
            parser.error("Unknown arguments: %s" % args)

        self._cli_opts = vars(options)
        if conf_only and 'conf' in self._cli_opts:
            self._update_dict({'conf': self._cli_opts['conf']})
            return

        self._update_dict(self._cli_opts)