summaryrefslogtreecommitdiff
path: root/ick2/buildgraph_tests.py
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2018-05-25 20:46:35 +0300
committerLars Wirzenius <liw@liw.fi>2018-05-28 18:18:38 +0300
commitf18a394d0279cf2dc3a768a0470fea2201cad016 (patch)
treec57d671f0e32056a5db6fac60d3bbe90b2187e9b /ick2/buildgraph_tests.py
parent7a4c92e7171d642a1e1fce324441710ad4d44ce9 (diff)
downloadick2-f18a394d0279cf2dc3a768a0470fea2201cad016.tar.gz
Add: BuildGraph.has_more_to_do method, refactor
Diffstat (limited to 'ick2/buildgraph_tests.py')
-rw-r--r--ick2/buildgraph_tests.py31
1 files changed, 29 insertions, 2 deletions
diff --git a/ick2/buildgraph_tests.py b/ick2/buildgraph_tests.py
index a81d2c6..e661294 100644
--- a/ick2/buildgraph_tests.py
+++ b/ick2/buildgraph_tests.py
@@ -166,6 +166,21 @@ class BuildGraphTests(unittest.TestCase):
self.assertEqual(graph.find_actions('ready'), ['1'])
self.assertEqual(graph.find_actions('blocked'), ['2'])
+ def test_tracks_nothing_to_do(self):
+ pipeline_as_dict = {
+ 'actions': [
+ {
+ 'action': 'foo',
+ },
+ {
+ 'action': 'bar',
+ },
+ ],
+ }
+ pipeline = ick2.resource_from_dict(pipeline_as_dict)
+ graph = ick2.BuildGraph()
+ graph.append_pipeline(pipeline)
+
def test_doesnt_unblock_when_deps_are_not_done(self):
pipeline_as_dict = {
'actions': [
@@ -178,12 +193,24 @@ class BuildGraphTests(unittest.TestCase):
],
}
pipeline = ick2.resource_from_dict(pipeline_as_dict)
+
graph = ick2.BuildGraph()
+ self.assertFalse(graph.has_more_to_do())
+
graph.append_pipeline(pipeline)
+ graph.set_action_status('1', 'building')
+ self.assertEqual(graph.get_action_status('2'), 'blocked')
+ self.assertTrue(graph.has_more_to_do())
- graph.unblock()
- self.assertEqual(graph.get_action_status('1'), 'ready')
+ graph.set_action_status('1', 'done')
self.assertEqual(graph.get_action_status('2'), 'blocked')
+ self.assertTrue(graph.has_more_to_do())
+
+ graph.set_action_status('2', 'ready')
+ self.assertTrue(graph.has_more_to_do())
+
+ graph.set_action_status('2', 'done')
+ self.assertFalse(graph.has_more_to_do())
def test_unblocks_when_deps_are_done(self):
pipeline_as_dict = {