def setup_deps(self): def custom_deps(src, dst): return (src[0] == 'p0' and src[1] == 'e0' and dst[0] == 'p1' and dst[1] == 'e1') kindspec = { 'fully': udeps.fully, 'by_part': udeps.by_part, 'by_case': udeps.by_case, 'any': udeps.any(udeps.source(udeps.part_is('p0')), udeps.dest(udeps.env_is('e1'))), 'all': udeps.all(udeps.part_is('p0'), udeps.dest(udeps.env_is('e0'))), 'custom': custom_deps, 'nodeps': lambda s, d: False, } self.valid_systems = ['sys0:p0', 'sys0:p1'] self.valid_prog_environs = ['e0', 'e1'] self.executable = 'echo' self.executable_opts = [self.name] self.sanity_patterns = sn.assert_found(self.name, self.stdout) if self.kind == 'default': self.depends_on('Test0') else: self.depends_on('Test0', kindspec[self.kind])
def test_dependecies_how_functions_undoc(): t0_cases = [(p, e) for p in ['p0', 'p1'] for e in ['e0', 'e1', 'e2']] t1_cases = [(p, e) for p in ['p0', 'p1', 'p2'] for e in ['e0', 'e1']] how = udeps.part_is('p0') deps = {(t0, t1) for t0 in t0_cases for t1 in t1_cases if how(t0, t1)} assert deps == {(t0, t1) for t0 in t0_cases for t1 in t1_cases if (t0[0] == 'p0' and t1[0] == 'p0')} assert len(deps) == 6 how = udeps.source(udeps.part_is('p0')) deps = {(t0, t1) for t0 in t0_cases for t1 in t1_cases if how(t0, t1)} assert deps == {(t0, t1) for t0 in t0_cases for t1 in t1_cases if t0[0] == 'p0'} assert len(deps) == 18 how = udeps.dest(udeps.part_is('p0')) deps = {(t0, t1) for t0 in t0_cases for t1 in t1_cases if how(t0, t1)} assert deps == {(t0, t1) for t0 in t0_cases for t1 in t1_cases if t1[0] == 'p0'} assert len(deps) == 12 how = udeps.env_is('e0') deps = {(t0, t1) for t0 in t0_cases for t1 in t1_cases if how(t0, t1)} assert deps == {(t0, t1) for t0 in t0_cases for t1 in t1_cases if (t0[1] == 'e0' and t1[1] == 'e0')} assert len(deps) == 6 how = udeps.source(udeps.env_is('e0')) deps = {(t0, t1) for t0 in t0_cases for t1 in t1_cases if how(t0, t1)} assert deps == {(t0, t1) for t0 in t0_cases for t1 in t1_cases if t0[1] == 'e0'} assert len(deps) == 12 how = udeps.dest(udeps.env_is('e0')) deps = {(t0, t1) for t0 in t0_cases for t1 in t1_cases if how(t0, t1)} assert deps == {(t0, t1) for t0 in t0_cases for t1 in t1_cases if t1[1] == 'e0'} assert len(deps) == 18 how = udeps.any(udeps.source(udeps.part_is('p0')), udeps.dest(udeps.env_is('e1'))) deps = {(t0, t1) for t0 in t0_cases for t1 in t1_cases if how(t0, t1)} assert deps == {(t0, t1) for t0 in t0_cases for t1 in t1_cases if (t0[0] == 'p0' or t1[1] == 'e1')} assert len(deps) == 27 how = udeps.all(udeps.source(udeps.part_is('p0')), udeps.dest(udeps.env_is('e1'))) deps = {(t0, t1) for t0 in t0_cases for t1 in t1_cases if how(t0, t1)} assert deps == {(t0, t1) for t0 in t0_cases for t1 in t1_cases if (t0[0] == 'p0' and t1[1] == 'e1')} assert len(deps) == 9