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
parent 6f363de429
commit 3824b084b6
6 changed files with 31 additions and 20 deletions

View File

@ -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 = {

View File

@ -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')

View File

@ -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__))

View 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

View File

@ -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])

View File

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