Esempio n. 1
0
    def test_invalid_type(self):
        """Test that a condition which is not callable raises an exception."""

        m = Mach(os.getcwd())
        m.define_category('testing', 'Mach unittest', 'Testing for mach core', 10)
        self.assertRaises(MachError, m.load_commands_from_file,
                os.path.join(self.provider_dir, 'conditions_invalid.py'))
Esempio n. 2
0
    def test_invalid_type(self):
        """Test that a condition which is not callable raises an exception."""

        m = Mach(os.getcwd())
        m.define_category('testing', 'Mach unittest', 'Testing for mach core', 10)
        self.assertRaises(MachError, m.load_commands_from_file,
                          os.path.join(self.provider_dir, 'conditions_invalid.py'))
def main(args):
    m = Mach(os.getcwd())
    m.define_category('docker', 'Docker',
        'Common actions involving Docker')
    import vcttesting.docker_mach_commands

    return m.run(args)
Esempio n. 4
0
    def _run_mach(self,
                  args,
                  provider_file=None,
                  entry_point=None,
                  context_handler=None):
        m = Mach(os.getcwd())
        m.define_category('testing', 'Mach unittest', 'Testing for mach core',
                          10)
        m.populate_context_handler = context_handler

        if provider_file:
            m.load_commands_from_file(
                os.path.join(self.provider_dir, provider_file))

        if entry_point:
            m.load_commands_from_entry_point(entry_point)

        stdout = StringIO()
        stderr = StringIO()
        stdout.encoding = 'UTF-8'
        stderr.encoding = 'UTF-8'

        try:
            result = m.run(args, stdout=stdout, stderr=stderr)
        except SystemExit:
            result = None

        return (result, stdout.getvalue(), stderr.getvalue())
Esempio n. 5
0
    def test_invalid_type(self):
        """Test that a condition which is not callable raises an exception."""

        m = Mach(os.getcwd())
        m.define_category("testing", "Mach unittest", "Testing for mach core",
                          10)
        self.assertRaises(
            MachError,
            m.load_commands_from_file,
            os.path.join(PROVIDER_DIR, "conditions_invalid.py"),
        )
Esempio n. 6
0
    def get_mach(self, provider_file=None, entry_point=None, context_handler=None):
        m = Mach(os.getcwd())
        m.define_category('testing', 'Mach unittest', 'Testing for mach core', 10)
        m.populate_context_handler = context_handler

        if provider_file:
            m.load_commands_from_file(os.path.join(self.provider_dir, provider_file))

        if entry_point:
            m.load_commands_from_entry_point(entry_point)

        return m
Esempio n. 7
0
    def get_mach(self, provider_file=None, entry_point=None, context_handler=None):
        m = Mach(os.getcwd())
        m.define_category('testing', 'Mach unittest', 'Testing for mach core', 10)
        m.populate_context_handler = context_handler

        if provider_file:
            m.load_commands_from_file(os.path.join(self.provider_dir, provider_file))

        if entry_point:
            m.load_commands_from_entry_point(entry_point)

        return m
Esempio n. 8
0
    def test_invalid_context_message(self):
        """Test that commands which do not pass all their conditions
        print the proper failure message."""

        def is_bar():
            """Bar must be true"""
        fail_conditions = [is_bar]

        for name in ('cmd_bar', 'cmd_foobar'):
            result, stdout, stderr = self._run_mach([name])
            self.assertEquals(1, result)

            fail_msg = Mach._condition_failed_message(name, fail_conditions)
            self.assertEquals(fail_msg.rstrip(), stdout.rstrip())

        for name in ('cmd_bar_ctx', 'cmd_foobar_ctx'):
            result, stdout, stderr = self._run_mach([name], _populate_context)
            self.assertEquals(1, result)

            fail_msg = Mach._condition_failed_message(name, fail_conditions)
            self.assertEquals(fail_msg.rstrip(), stdout.rstrip())
Esempio n. 9
0
    def test_invalid_context_message(self):
        """Test that commands which do not pass all their conditions
        print the proper failure message."""

        def is_bar():
            """Bar must be true"""
        fail_conditions = [is_bar]

        for name in ('cmd_bar', 'cmd_foobar'):
            result, stdout, stderr = self._run_mach([name])
            self.assertEquals(1, result)

            fail_msg = Mach._condition_failed_message(name, fail_conditions)
            self.assertEquals(fail_msg.rstrip(), stdout.rstrip())

        for name in ('cmd_bar_ctx', 'cmd_foobar_ctx'):
            result, stdout, stderr = self._run_mach([name], _populate_context)
            self.assertEquals(1, result)

            fail_msg = Mach._condition_failed_message(name, fail_conditions)
            self.assertEquals(fail_msg.rstrip(), stdout.rstrip())
Esempio n. 10
0
File: common.py Progetto: 0X1A/servo
    def _run_mach(self, args, provider_file=None, entry_point=None, context_handler=None):
        m = Mach(os.getcwd())
        m.define_category('testing', 'Mach unittest', 'Testing for mach core', 10)
        m.populate_context_handler = context_handler

        if provider_file:
            m.load_commands_from_file(os.path.join(self.provider_dir, provider_file))

        if entry_point:
            m.load_commands_from_entry_point(entry_point)

        stdout = StringIO()
        stderr = StringIO()
        stdout.encoding = 'UTF-8'
        stderr.encoding = 'UTF-8'

        try:
            result = m.run(args, stdout=stdout, stderr=stderr)
        except SystemExit:
            result = None

        return (result, stdout.getvalue(), stderr.getvalue())
Esempio n. 11
0
    def get_mach(cls,
                 provider_files=None,
                 entry_point=None,
                 context_handler=None):
        m = Mach(os.getcwd())
        m.define_category('testing', 'Mach unittest', 'Testing for mach core',
                          10)
        m.define_category('misc', 'Mach misc', 'Testing for mach core', 20)
        m.populate_context_handler = context_handler

        if provider_files:
            if isinstance(provider_files, six.string_types):
                provider_files = [provider_files]

            for path in provider_files:
                m.load_commands_from_file(os.path.join(cls.provider_dir, path))

        if entry_point:
            m.load_commands_from_entry_point(entry_point)

        return m
Esempio n. 12
0
    def inner(provider_files=None, entry_point=None, context_handler=None):
        m = Mach(os.getcwd())
        m.define_category("testing", "Mach unittest", "Testing for mach core",
                          10)
        m.define_category("misc", "Mach misc", "Testing for mach core", 20)
        m.populate_context_handler = context_handler or _populate_context

        if provider_files:
            if isinstance(provider_files, six.string_types):
                provider_files = [provider_files]

            for path in provider_files:
                m.load_commands_from_file(os.path.join(PROVIDER_DIR, path))

        if entry_point:
            m.load_commands_from_entry_point(entry_point)

        return m