示例#1
0
 def test_should_run_runall_and_skip_play_nice(self):
     q = cmd.QuibbleCmd()
     args = cmd.parse_arguments(args=['--run', 'all', '--skip', 'phpunit'])
     stages = q.stages_to_run(args.run, args.skip, args.commands)
     expected_stages = default_stages.copy()
     expected_stages.remove('phpunit')
     self.assertEqual(expected_stages, stages,
                      '--run=all respects --skip')
示例#2
0
def test_plan(expected, args, env):

    with mock.patch.dict('os.environ', env, clear=True):
        cmd_args = cmd.parse_arguments(args)
        plan = cmd.QuibbleCmd().build_execution_plan(cmd_args)

    printable_plan = [str(command) for command in plan]

    assert printable_plan == expected
示例#3
0
 def test_build_execution_plan_adds_ZUUL_PROJECT(self, _):
     env = {'ZUUL_PROJECT': 'mediawiki/extensions/ZuulProjectEnvVar'}
     with mock.patch.dict('os.environ', env, clear=True):
         q = cmd.QuibbleCmd()
         args = cmd.parse_arguments(
             args=['--packages-source=composer'])
         with mock.patch('quibble.commands.ZuulClone') as mock_clone:
             q.build_execution_plan(args)
     self.assertEqual(
         [
             'mediawiki/core',  # must be first
             'mediawiki/extensions/ZuulProjectEnvVar',
             'mediawiki/skins/Vector',
         ],
         mock_clone.call_args[1]['projects'])
示例#4
0
    def test_build_execution_plan_does_not_duplicate_hardcoded_repos(self, _):
        hardcoded_repos = [
            'mediawiki/core',
            'mediawiki/skins/Vector',
            ]

        for repo in hardcoded_repos:
            q = cmd.QuibbleCmd()
            args = cmd.parse_arguments(
                args=['--packages-source=composer'])
            with mock.patch.dict('os.environ', {'ZUUL_PROJECT': repo},
                                 clear=True):
                with mock.patch('quibble.commands.ZuulClone') \
                        as mock_clone:
                    q.build_execution_plan(args)
            self.assertEqual(
                [
                    'mediawiki/core',  # must be first
                    'mediawiki/skins/Vector',
                ],
                mock_clone.call_args[1]['projects'])
示例#5
0
    def test_build_execution_plan(self):
        args = cmd.parse_arguments(args=[])
        plan = cmd.QuibbleCmd().build_execution_plan(args)

        self.assertIsInstance(plan[0], quibble.commands.ReportVersions)
        self.assertIsInstance(plan[1], quibble.commands.EnsureDirectory)
示例#6
0
 def test_project_branch_arg(self):
     args = cmd.parse_arguments(args=[])
     self.assertEqual([], args.project_branch)
示例#7
0
 def test_command_used_multiple_times(self):
     args = cmd.parse_arguments(args=['-c', 'true', '-c', 'false'])
     self.assertEqual(['true', 'false'], args.commands)
示例#8
0
 def test_command_does_not_shallow_next_arg(self):
     args = cmd.parse_arguments(args=['--command', '/bin/true', 'repo'])
     self.assertEqual(['/bin/true'], args.commands)
     self.assertEqual(['repo'], args.projects)
示例#9
0
 def test_skip_option_does_not_shallow_next_arg(self):
     args = cmd.parse_arguments(args=['--skip', 'phpunit', 'repo'])
     self.assertEqual(['phpunit'], args.skip)
     self.assertEqual(['repo'], args.projects)
示例#10
0
    def test_args_defaults_in_docker(self, _):
        args = cmd.parse_arguments([])

        self.assertEqual('/srv/git', args.git_cache)
        self.assertEqual('/workspace', args.workspace)
示例#11
0
 def test_command_skip_all_stages(self):
     q = cmd.QuibbleCmd()
     args = cmd.parse_arguments(args=['-c', '/bin/true'])
     stages = q.stages_to_run(args.run, args.skip, args.commands)
     self.assertEqual([], stages,
                      'User command must skip all stages')
示例#12
0
 def test_should_run_running_a_single_stage(self):
     q = cmd.QuibbleCmd()
     args = cmd.parse_arguments(args=['--run', 'phpunit'])
     stages = q.stages_to_run(args.run, args.skip, args.commands)
     self.assertEqual(['phpunit'], stages,
                      '--run runs exactly the given stage')
示例#13
0
 def test_should_run_skips_a_stage(self):
     q = cmd.QuibbleCmd()
     args = cmd.parse_arguments(args=['--skip', 'phpunit'])
     stages = q.stages_to_run(args.run, args.skip, args.commands)
     self.assertEqual(['foo'], stages,
                      '--skip skips the stage')
示例#14
0
 def test_should_run_skippall_runs_no_stage(self):
     q = cmd.QuibbleCmd()
     args = cmd.parse_arguments(args=['--skip', 'all'])
     stages = q.stages_to_run(args.run, args.skip, args.commands)
     self.assertEqual([], stages,
                      '--skip=all skips all stages')
示例#15
0
 def test_should_run_runall_accepts_all_stages(self):
     q = cmd.QuibbleCmd()
     args = cmd.parse_arguments(args=['--run', 'all'])
     stages = q.stages_to_run(args.run, args.skip, args.commands)
     self.assertEqual(default_stages, stages,
                      '--run=all runs all stages')
示例#16
0
 def test_should_run_accepts_all_stages_by_default(self):
     q = cmd.QuibbleCmd()
     args = cmd.parse_arguments(args=[])
     stages = q.stages_to_run(args.run, args.skip, args.commands)
     self.assertEqual(default_stages, stages,
                      'must runs all stages by default')
示例#17
0
 def test_skip_option_is_comma_separated(self):
     args = cmd.parse_arguments(args=['--skip=phpunit,qunit'])
     self.assertEqual(['phpunit', 'qunit'], args.skip)
示例#18
0
    def test_args_defaults(self, _):
        args = cmd.parse_arguments([])

        self.assertEqual('ref', args.git_cache)
        self.assertEqual(os.getcwd(), args.workspace)
        self.assertEqual('log', args.log_dir)