Bug 1473498 - [mach] Enable test_dispatcher with python 3 r=firefox-build-system-reviewers,chmanchester

This test is working with minimal effort. Let's get it running to prevent
future regressions.

Differential Revision: https://phabricator.services.mozilla.com/D36098

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andrew Halberstadt 2019-07-02 21:27:35 +00:00
Родитель 6f363de429
Коммит 3824b084b6
6 изменённых файлов: 31 добавлений и 20 удалений

Просмотреть файл

@ -22,7 +22,7 @@ import sys
import six
from functools import wraps
from six.moves.configparser import RawConfigParser, NoSectionError
from six import string_types as str_type
from six import string_types
class ConfigException(Exception):
@ -62,7 +62,7 @@ class ConfigType(object):
class StringType(ConfigType):
@staticmethod
def validate(value):
if not isinstance(value, str_type):
if not isinstance(value, string_types):
raise TypeError()
@staticmethod
@ -109,7 +109,7 @@ class PositiveIntegerType(IntegerType):
class PathType(StringType):
@staticmethod
def validate(value):
if not isinstance(value, str_type):
if not isinstance(value, string_types):
raise TypeError()
@staticmethod
@ -337,7 +337,7 @@ class ConfigSettings(collections.Mapping):
extra -- A dict of additional key/value pairs to add to the
setting metadata.
"""
if isinstance(type_cls, basestring):
if isinstance(type_cls, string_types):
type_cls = TYPE_CLASSES[type_cls]
meta = {

Просмотреть файл

@ -6,7 +6,6 @@
# (mach). It is packaged as a module because everything is a library.
from __future__ import absolute_import, print_function, unicode_literals
from collections import Iterable
import argparse
import codecs
@ -17,6 +16,9 @@ import os
import sys
import traceback
import uuid
from collections import Iterable
from six import string_types
from .base import (
CommandContext,
@ -27,12 +29,10 @@ from .base import (
UnrecognizedArgumentError,
FailedCommandError,
)
from .config import ConfigSettings
from .decorators import (
CommandProvider,
)
from .config import ConfigSettings
from .dispatcher import CommandAction
from .logging import LoggingManager
from .registrar import Registrar
@ -256,11 +256,11 @@ To see more help for a specific command, run:
if module_name is None:
# Ensure parent module is present otherwise we'll (likely) get
# an error due to unknown parent.
if b'mach.commands' not in sys.modules:
mod = imp.new_module(b'mach.commands')
sys.modules[b'mach.commands'] = mod
if 'mach.commands' not in sys.modules:
mod = imp.new_module('mach.commands')
sys.modules['mach.commands'] = mod
module_name = 'mach.commands.%s' % uuid.uuid4().get_hex()
module_name = 'mach.commands.%s' % uuid.uuid4().hex
try:
imp.load_source(module_name, path)
@ -604,7 +604,7 @@ To see more help for a specific command, run:
machrc, .machrc
"""
if isinstance(paths, basestring):
if isinstance(paths, string_types):
paths = [paths]
valid_names = ('machrc', '.machrc')

Просмотреть файл

@ -4,10 +4,15 @@
from __future__ import unicode_literals
from StringIO import StringIO
import os
import unittest
try:
from StringIO import StringIO
except ImportError:
# TODO io.StringIO causes failures with Python 2 (needs to be sorted out)
from io import StringIO
from mach.main import Mach
here = os.path.abspath(os.path.dirname(__file__))

Просмотреть файл

@ -1,11 +1,16 @@
[DEFAULT]
skip-if = python == 3
subsuite = mach
[test_conditions.py]
skip-if = python == 3
[test_config.py]
skip-if = python == 3
[test_dispatcher.py]
[test_entry_point.py]
skip-if = python == 3
[test_error_output.py]
skip-if = python == 3
[test_logger.py]
skip-if = python == 3
[test_telemetry.py]
skip-if = python == 3

Просмотреть файл

@ -5,14 +5,15 @@
from __future__ import unicode_literals
import os
from cStringIO import StringIO
from io import StringIO
from mozunit import main
from six import string_types
from mach.base import CommandContext
from mach.registrar import Registrar
from mach.test.common import TestBase
from mozunit import main
here = os.path.abspath(os.path.dirname(__file__))
@ -26,7 +27,7 @@ class TestDispatcher(TestBase):
mach.settings.register_provider(provider)
if config:
if isinstance(config, basestring):
if isinstance(config, string_types):
config = StringIO(config)
mach.settings.load_fps([config])

Просмотреть файл

@ -46,7 +46,7 @@ mach:
- linux64/opt
- macosx1010-64/opt
- windows10-64/opt
python-version: [2]
python-version: [2, 3]
treeherder:
symbol: mach
run: