Exemplo n.º 1
0
    def test_taskgraph_to_json(self):
        tasks = {
            'a':
            Task(kind='test',
                 label='a',
                 description='Task A',
                 attributes={'attr': 'a-task'},
                 task={'taskdef': True}),
            'b':
            Task(
                kind='test',
                label='b',
                attributes={},
                task={'task': 'def'},
                optimization={'skip-unless-has-relevant-tests': None},
                # note that this dep is ignored, superseded by that
                # from the taskgraph's edges
                dependencies={'first': 'a'}),
        }
        graph = Graph(nodes=set('ab'), edges={('a', 'b', 'edgelabel')})
        taskgraph = TaskGraph(tasks, graph)

        res = taskgraph.to_json()

        self.assertEqual(
            res, {
                'a': {
                    'kind': 'test',
                    'label': 'a',
                    'description': 'Task A',
                    'attributes': {
                        'attr': 'a-task',
                        'kind': 'test'
                    },
                    'task': {
                        'taskdef': True
                    },
                    'dependencies': {
                        'edgelabel': 'b'
                    },
                    'soft_dependencies': [],
                    'optimization': None,
                },
                'b': {
                    'kind': 'test',
                    'label': 'b',
                    'description': '',
                    'attributes': {
                        'kind': 'test'
                    },
                    'task': {
                        'task': 'def'
                    },
                    'dependencies': {},
                    'soft_dependencies': [],
                    'optimization': {
                        'skip-unless-has-relevant-tests': None
                    },
                }
            })
Exemplo n.º 2
0
    def test_round_trip(self):
        graph = TaskGraph(
            tasks={
                "a": Task(
                    kind="fancy",
                    label="a",
                    description="Task A",
                    attributes={},
                    dependencies={"prereq": "b"},  # must match edges, below
                    optimization={"skip-unless-has-relevant-tests": None},
                    task={"task": "def"},
                ),
                "b": Task(
                    kind="pre",
                    label="b",
                    attributes={},
                    dependencies={},
                    optimization={"skip-unless-has-relevant-tests": None},
                    task={"task": "def2"},
                ),
            },
            graph=Graph(nodes={"a", "b"}, edges={("a", "b", "prereq")}),
        )

        tasks, new_graph = TaskGraph.from_json(graph.to_json())
        self.assertEqual(graph, new_graph)
Exemplo n.º 3
0
    def test_taskgraph_to_json(self):
        tasks = {
            'a':
            Task(kind='test',
                 label='a',
                 attributes={'attr': 'a-task'},
                 task={'taskdef': True}),
            'b':
            Task(
                kind='test',
                label='b',
                attributes={},
                task={'task': 'def'},
                optimizations=[['seta']],
                # note that this dep is ignored, superseded by that
                # from the taskgraph's edges
                dependencies={'first': 'a'}),
        }
        graph = Graph(nodes=set('ab'), edges={('a', 'b', 'edgelabel')})
        taskgraph = TaskGraph(tasks, graph)

        res = taskgraph.to_json()

        self.assertEqual(
            res, {
                'a': {
                    'kind': 'test',
                    'label': 'a',
                    'attributes': {
                        'attr': 'a-task',
                        'kind': 'test'
                    },
                    'task': {
                        'taskdef': True
                    },
                    'dependencies': {
                        'edgelabel': 'b'
                    },
                    'optimizations': [],
                },
                'b': {
                    'kind': 'test',
                    'label': 'b',
                    'attributes': {
                        'kind': 'test'
                    },
                    'task': {
                        'task': 'def'
                    },
                    'dependencies': {},
                    'optimizations': [['seta']],
                }
            })
Exemplo n.º 4
0
    def test_taskgraph_to_json(self):
        tasks = {
            "a": Task(
                kind="test",
                label="a",
                description="Task A",
                attributes={"attr": "a-task"},
                task={"taskdef": True},
            ),
            "b": Task(
                kind="test",
                label="b",
                attributes={},
                task={"task": "def"},
                optimization={"skip-unless-has-relevant-tests": None},
                # note that this dep is ignored, superseded by that
                # from the taskgraph's edges
                dependencies={"first": "a"},
            ),
        }
        graph = Graph(nodes=set("ab"), edges={("a", "b", "edgelabel")})
        taskgraph = TaskGraph(tasks, graph)

        res = taskgraph.to_json()

        self.assertEqual(
            res,
            {
                "a": {
                    "kind": "test",
                    "label": "a",
                    "description": "Task A",
                    "attributes": {"attr": "a-task", "kind": "test"},
                    "task": {"taskdef": True},
                    "dependencies": {"edgelabel": "b"},
                    "soft_dependencies": [],
                    "if_dependencies": [],
                    "optimization": None,
                },
                "b": {
                    "kind": "test",
                    "label": "b",
                    "description": "",
                    "attributes": {"kind": "test"},
                    "task": {"task": "def"},
                    "dependencies": {},
                    "soft_dependencies": [],
                    "if_dependencies": [],
                    "optimization": {"skip-unless-has-relevant-tests": None},
                },
            },
        )
Exemplo n.º 5
0
    def test_round_trip(self):
        graph = TaskGraph(tasks={
            'a': Task(
                kind='fancy',
                label='a',
                attributes={},
                dependencies={'prereq': 'b'},  # must match edges, below
                optimization={'seta': None},
                task={'task': 'def'}),
            'b': Task(
                kind='pre',
                label='b',
                attributes={},
                dependencies={},
                optimization={'seta': None},
                task={'task': 'def2'}),
        }, graph=Graph(nodes={'a', 'b'}, edges={('a', 'b', 'prereq')}))

        tasks, new_graph = TaskGraph.from_json(graph.to_json())
        self.assertEqual(graph, new_graph)
Exemplo n.º 6
0
    def test_round_trip(self):
        graph = TaskGraph(tasks={
            'a': Task(
                kind='fancy',
                label='a',
                description='Task A',
                attributes={},
                dependencies={'prereq': 'b'},  # must match edges, below
                optimization={'skip-unless-has-relevant-tests': None},
                task={'task': 'def'}),
            'b': Task(
                kind='pre',
                label='b',
                attributes={},
                dependencies={},
                optimization={'skip-unless-has-relevant-tests': None},
                task={'task': 'def2'}),
        }, graph=Graph(nodes={'a', 'b'}, edges={('a', 'b', 'prereq')}))

        tasks, new_graph = TaskGraph.from_json(graph.to_json())
        self.assertEqual(graph, new_graph)
Exemplo n.º 7
0
    def test_round_trip(self):
        graph = TaskGraph(
            tasks={
                'a':
                Task(
                    kind='fancy',
                    label='a',
                    attributes={},
                    dependencies={'prereq': 'b'},  # must match edges, below
                    optimizations=[['seta']],
                    task={'task': 'def'}),
                'b':
                Task(kind='pre',
                     label='b',
                     attributes={},
                     dependencies={},
                     optimizations=[['seta']],
                     task={'task': 'def2'}),
            },
            graph=Graph(nodes={'a', 'b'}, edges={('a', 'b', 'prereq')}))

        tasks, new_graph = TaskGraph.from_json(graph.to_json())
        self.assertEqual(graph, new_graph)
Exemplo n.º 8
0
    def test_taskgraph_to_json(self):
        tasks = {
            'a': Task(kind='test', label='a',
                      attributes={'attr': 'a-task'},
                      task={'taskdef': True}),
            'b': Task(kind='test', label='b',
                      attributes={},
                      task={'task': 'def'},
                      optimization={'seta': None},
                      # note that this dep is ignored, superseded by that
                      # from the taskgraph's edges
                      dependencies={'first': 'a'}),
        }
        graph = Graph(nodes=set('ab'), edges={('a', 'b', 'edgelabel')})
        taskgraph = TaskGraph(tasks, graph)

        res = taskgraph.to_json()

        self.assertEqual(res, {
            'a': {
                'kind': 'test',
                'label': 'a',
                'attributes': {'attr': 'a-task', 'kind': 'test'},
                'task': {'taskdef': True},
                'dependencies': {'edgelabel': 'b'},
                'optimization': None,
            },
            'b': {
                'kind': 'test',
                'label': 'b',
                'attributes': {'kind': 'test'},
                'task': {'task': 'def'},
                'dependencies': {},
                'optimization': {'seta': None},
            }
        })