Exemplo n.º 1
0
def test_testprofile_update_test_list():
    """ TestProfile.update() updates TestProfile.test_list """
    profile1 = profile.TestProfile()
    profile1.test_list['group1/test1'] = 'test1'

    baseline = {'group1/test1': 'test3', 'group2/test2': 'test2'}

    profile2 = profile.TestProfile()
    profile2.test_list = baseline

    profile1.update(profile2)

    nt.assert_dict_equal(profile1.test_list, baseline)
Exemplo n.º 2
0
def test_testprofile_update_test_list():
    """profile.TestProfile.update(): updates TestProfile.test_list"""
    profile1 = profile.TestProfile()
    group1 = grouptools.join('group1', 'test1')
    group2 = grouptools.join('group1', 'test2')

    profile1.test_list[group1] = utils.Test(['test1'])

    profile2 = profile.TestProfile()
    profile2.test_list[group1] = utils.Test(['test3'])
    profile2.test_list[group2] = utils.Test(['test2'])

    profile1.update(profile2)

    nt.assert_dict_equal(profile1.test_list, profile2.test_list)
Exemplo n.º 3
0
def check_flatten(tests, testlist):
    """ TestProfile.prepare_test_list flattens TestProfile.tests """
    profile_ = profile.TestProfile()
    profile_.tests = tests
    profile_._flatten_group_hierarchy()

    nt.assert_dict_equal(profile_.test_list, testlist)
Exemplo n.º 4
0
def test_testprofile_group_manager_no_name_args_gt_one():
    """TestProfile.group_manager: no name and len(args) > 1 is valid"""
    prof = profile.TestProfile()
    with prof.group_manager(utils.Test, 'foo') as g:
        g(['a', 'b'])

    nt.assert_in(grouptools.join('foo', 'a b'), prof.test_list)
Exemplo n.º 5
0
 def fixture(self):
     orig = profile.TestProfile()
     orig.test_list['foo'] = utils.Test(['foo'])
     orig.test_list['bar'] = utils.Test(['bar'])
     orig.filters = [lambda name, _: name != 'bar']
     orig.forced_test_list = ['foo']
     return orig
Exemplo n.º 6
0
def test_testprofile_group_manager_is_added():
    """TestProfile.group_manager: Tests are added to the profile"""
    prof = profile.TestProfile()
    with prof.group_manager(utils.Test, 'foo') as g:
        g(['a', 'b'], 'a')

    nt.assert_in(grouptools.join('foo', 'a'), prof.test_list)
Exemplo n.º 7
0
    def test_update_test_list(self):
        """profile.TestProfile.update(): updates TestProfile.test_list"""
        profile1 = profile.TestProfile()
        group1 = grouptools.join('group1', 'test1')
        group2 = grouptools.join('group1', 'test2')

        profile1.test_list[group1] = utils.Test(['test1'])

        profile2 = profile.TestProfile()
        profile2.test_list[group1] = utils.Test(['test3'])
        profile2.test_list[group2] = utils.Test(['test2'])

        with profile1.allow_reassignment:
            profile1.update(profile2)

        assert dict(profile1.test_list) == dict(profile2.test_list)
Exemplo n.º 8
0
def test_testprofile_set_dmesg_true():
    """ Dmesg returns an apropriate dmesg is ste to True """
    if not platform.platform().startswith('Linux'):
        raise SkipTest('No dmesg support on this platform')
    profile_ = profile.TestProfile()
    profile_.dmesg = True
    assert isinstance(profile_.dmesg, dmesg.LinuxDmesg)
Exemplo n.º 9
0
def test_testprofile_set_dmesg_false():
    """profile.TestProfile: Dmesg returns a DummyDmesg if set to False"""
    utils.platform_check('linux')
    profile_ = profile.TestProfile()
    profile_.dmesg = True
    profile_.dmesg = False
    nt.ok_(isinstance(profile_.dmesg, dmesg.DummyDmesg))
Exemplo n.º 10
0
 def test_set_dmesg_true(self):
     """profile.TestProfile: Dmesg returns an appropriate dmesg is set to
     True.
     """
     profile_ = profile.TestProfile()
     profile_.dmesg = True
     assert isinstance(profile_.dmesg, dmesg.LinuxDmesg)
Exemplo n.º 11
0
def test_testprofile_groupmanager_name_str():
    """TestProfile.group_manager: if args is a string it is not joined."""
    prof = profile.TestProfile()
    # Yes, this is really about supporting gleantest anyway.
    with prof.group_manager(GleanTest, 'foo') as g:
        g('abc')

    nt.ok_(grouptools.join('foo', 'abc') in prof.test_list)
Exemplo n.º 12
0
def test_testprofile_groupmanager_kwargs_overwrite():
    """TestProfile.group_manager: default_args are overwritten by kwargs."""
    prof = profile.TestProfile()
    with prof.group_manager(utils.Test, 'foo', run_concurrent=True) as g:
        g(['a'], run_concurrent=False)

    test = prof.test_list[grouptools.join('foo', 'a')]
    nt.assert_equal(test.run_concurrent, False)
Exemplo n.º 13
0
def test_testprofile_set_dmesg_false():
    """ Dmesg returns a DummyDmesg if set to False """
    if not platform.platform().startswith('Linux'):
        raise SkipTest('No dmesg support on this platform')
    profile_ = profile.TestProfile()
    profile_.dmesg = True
    profile_.dmesg = False
    assert isinstance(profile_.dmesg, dmesg.DummyDmesg)
Exemplo n.º 14
0
def test_testprofile_allow_reassignment():
    """TestProfile: allow_reassignment wrapper works."""
    prof = profile.TestProfile()
    prof.test_list['a'] = utils.Test(['foo'])
    with prof.allow_reassignment:
        prof.test_list['a'] = utils.Test(['bar'])

    nt.ok_(prof.test_list['a'].command == ['bar'])
Exemplo n.º 15
0
def test_testprofile_groupmanager_default_args():
    """TestProfile.group_manager: group_manater kwargs are passed to the Test."""
    prof = profile.TestProfile()
    with prof.group_manager(utils.Test, 'foo', run_concurrent=True) as g:
        g(['a'])

    test = prof.test_list[grouptools.join('foo', 'a')]
    nt.assert_equal(test.run_concurrent, True)
Exemplo n.º 16
0
    def test_matches_include_caps(self):
        """TestProfile.prepare_test_list: matches capitalized tests."""
        env = core.Options(exclude_filter=['test9'])

        profile_ = profile.TestProfile()
        profile_.test_list = self.data
        profile_._prepare_test_list(env)

        nt.assert_not_in(grouptools.join('group4', 'Test9'), profile_.test_list)
Exemplo n.º 17
0
def test_testprofile_allow_reassignment_with_groupmanager():
    """TestProfile: allow_reassignment wrapper works with groupmanager."""
    testname = grouptools.join('a', 'b')
    prof = profile.TestProfile()
    prof.test_list[testname] = utils.Test(['foo'])
    with prof.allow_reassignment:
        with prof.group_manager(utils.Test, 'a') as g:
            g(['bar'], 'b')

    nt.ok_(prof.test_list[testname].command == ['bar'])
Exemplo n.º 18
0
    def test_matches_include_caps(self):
        """profile.TestProfile.prepare_test_list: matches capitalized tests"""
        self.opts.exclude_filter = ['test9']

        profile_ = profile.TestProfile()
        profile_.test_list = self.data
        profile_._prepare_test_list()

        nt.assert_not_in(grouptools.join('group4', 'Test9'),
                         profile_.test_list)
Exemplo n.º 19
0
def check_mixed_flatten(tests, testlist):
    """ flattening is correct when tests and test_list are defined """
    profile_ = profile.TestProfile()
    profile_.tests = tests
    profile_.test_list['test8'] = 'other'
    profile_._flatten_group_hierarchy()

    baseline = {'test8': 'other'}
    baseline.update(testlist)

    nt.assert_dict_equal(profile_.test_list, baseline)
Exemplo n.º 20
0
    def test_matches_filter_mar_2(self):
        """profile.TestProfile.prepare_test_list: 'not env.filter or matches_any_regex()' mar is False"""
        self.opts.include_filter = ['test5']

        profile_ = profile.TestProfile()
        profile_.test_list = self.data
        profile_._prepare_test_list()

        baseline = {grouptools.join('group3', 'test5'): 'other'}

        nt.assert_dict_equal(profile_.test_list, baseline)
Exemplo n.º 21
0
def test_matches_filter_mar_2(data):
    """ Tests 'not env.filter or matches_any_regex() mar is False"""
    env = core.Options(include_filter=['test5'])

    profile_ = profile.TestProfile()
    profile_.test_list = data
    profile_._prepare_test_list(env)

    baseline = {'group3/test5': 'other'}

    nt.assert_dict_equal(profile_.test_list, baseline)
Exemplo n.º 22
0
        def test_matches_filter_mar_1(self):
            """profile.TestProfile.prepare_test_list: 'not env.filter or
            matches_any_regex()' env.filter is False.

            Nothing should be filtered.
            """
            profile_ = profile.TestProfile()
            profile_.test_list = self.data
            profile_._prepare_test_list()

            assert dict(profile_.test_list) == dict(self.data)
Exemplo n.º 23
0
def test_testprofile_update_tests():
    """ TestProfile.update() updates TestProfile.tests

    TestProfile.tests is deprecated, and this test should be removed eventually

    """
    profile1 = profile.TestProfile()
    profile1.tests['group1'] = {}
    profile1.tests['group1']['test1'] = 'test1'

    profile2 = profile.TestProfile()
    baseline = {}
    baseline['group2'] = {}
    baseline['group2']['test2'] = 'test2'
    baseline['group1'] = {}
    baseline['group1']['test1'] = 'test3'
    profile2.tests = baseline

    profile1.update(profile2)

    nt.assert_dict_equal(profile1.tests, baseline)
Exemplo n.º 24
0
def test_matches_exclude_mar(data):
    """ Tests 'not matches_any_regexp() """
    env = core.Options(exclude_filter=['test5'])

    profile_ = profile.TestProfile()
    profile_.test_list = data
    profile_._prepare_test_list(env)

    baseline = copy.deepcopy(data)
    del baseline['group3/test5']

    nt.assert_dict_equal(profile_.test_list, baseline)
Exemplo n.º 25
0
    def test_matches_env_exclude(self):
        """profile.TestProfile.prepare_test_list: 'not path in env.exclude_tests'"""
        self.opts.exclude_tests.add(grouptools.join('group3', 'test5'))

        profile_ = profile.TestProfile()
        profile_.test_list = self.data
        profile_._prepare_test_list()

        baseline = copy.deepcopy(self.data)
        del baseline[grouptools.join('group3', 'test5')]

        nt.assert_dict_equal(profile_.test_list, baseline)
Exemplo n.º 26
0
    def test_matches_exclude_mar(self):
        """TestProfile.prepare_test_list: 'not matches_any_regexp()"""
        env = core.Options(exclude_filter=['test5'])

        profile_ = profile.TestProfile()
        profile_.test_list = self.data
        profile_._prepare_test_list(env)

        baseline = copy.deepcopy(self.data)
        del baseline[grouptools.join('group3', 'test5')]

        nt.assert_dict_equal(profile_.test_list, baseline)
Exemplo n.º 27
0
def test_matches_filter_mar_1(data):
    """ Tests 'not env.filter or matches_any_regex() env.filter is False

    Nothing should be filtered.

    """
    env = core.Options()

    profile_ = profile.TestProfile()
    profile_.test_list = data
    profile_._prepare_test_list(env)

    nt.assert_dict_equal(profile_.test_list, data)
Exemplo n.º 28
0
def test_matches_env_exclude(data):
    """ Tests 'not path in env.exclude_tests  """
    env = core.Options()
    env.exclude_tests.add('group3/test5')

    profile_ = profile.TestProfile()
    profile_.test_list = data
    profile_._prepare_test_list(env)

    baseline = copy.deepcopy(data)
    del baseline['group3/test5']

    nt.assert_dict_equal(profile_.test_list, baseline)
Exemplo n.º 29
0
        def test_matches_exclude_mar(self):
            """profile.TestProfile.prepare_test_list: 'not
            matches_any_regexp()'.
            """
            self.opts.exclude_filter = ['test5']

            baseline = copy.deepcopy(self.data)
            del baseline[grouptools.join('group3', 'test5')]

            profile_ = profile.TestProfile()
            profile_.test_list = self.data
            profile_._prepare_test_list()

            assert dict(profile_.test_list) == dict(baseline)
Exemplo n.º 30
0
        def test_matches_filter_mar_2(self):
            """profile.TestProfile.prepare_test_list: 'not env.filter or
            matches_any_regex()' mar is False.
            """
            self.opts.include_filter = ['test5']

            profile_ = profile.TestProfile()
            profile_.test_list = self.data
            profile_._prepare_test_list()

            baseline = {
                grouptools.join('group3', 'test5'): utils.Test(['other'])}

            assert dict(profile_.test_list) == baseline