4 # Permission is hereby granted, free of charge, to any person obtaining
5 # a copy of this software and associated documentation files (the
6 # "Software"), to deal in the Software without restriction, including
7 # without limitation the rights to use, copy, modify, merge, publish,
8 # distribute, sublicense, and/or sell copies of the Software, and to
9 # permit persons to whom the Software is furnished to do so, subject to
10 # the following conditions:
12 # The above copyright notice and this permission notice shall be included
13 # in all copies or substantial portions of the Software.
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
16 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
17 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
42 def _actionAppend(a1, a2):
44 for curr_a in [a1, a2]:
45 if isinstance(curr_a, MyAction):
47 elif isinstance(curr_a, MyListAction):
48 all.extend(curr_a.list)
49 elif type(curr_a) == type([1,2]):
52 raise 'Cannot Combine Actions'
53 return MyListAction(all)
56 def __add__(self, other):
57 return _actionAppend(self, other)
59 def __radd__(self, other):
60 return _actionAppend(other, self)
62 class MyAction(MyActionBase):
66 def __call__(self, target, source, env, errfunc):
67 global built_it, built_target, built_source, built_args, built_order
72 built_order = built_order + 1
73 self.order = built_order
76 class MyListAction(MyActionBase):
77 def __init__(self, list):
79 def __call__(self, target, source, env, errfunc):
81 A(target, source, env, errfunc)
83 class MyNonGlobalAction(MyActionBase):
87 self.built_target = None
88 self.built_source = None
90 def __call__(self, target, source, env, errfunc):
91 # Okay, so not ENTIRELY non-global...
94 self.built_target = target
95 self.built_source = source
97 built_order = built_order + 1
98 self.order = built_order
102 def __init__(self, **kw):
104 self._dict.update(kw)
105 def __getitem__(self, key):
106 return self._dict[key]
107 def Dictionary(self, *args):
109 def Override(self, overrides):
110 d = self._dict.copy()
112 return apply(Environment, (), d)
113 def _update(self, dict):
114 self._dict.update(dict)
117 def __init__(self, is_explicit=1):
118 self.env = Environment()
120 self.action = MyAction()
121 self.is_explicit = is_explicit
122 def targets(self, t):
124 def get_actions(self):
126 def get_contents(self, target, source, env):
129 class NoneBuilder(Builder):
130 def execute(self, target, source, env):
131 Builder.execute(self, target, source, env)
134 class ListBuilder(Builder):
135 def __init__(self, *nodes):
136 Builder.__init__(self)
138 def execute(self, target, source, env):
139 if hasattr(self, 'status'):
143 target = self.nodes[0]
144 self.status = Builder.execute(self, target, source, env)
147 def execute(self, target, source, env):
151 def execute(self, target, source, env):
152 raise SCons.Errors.BuildError
154 class ExceptBuilder2:
155 def execute(self, target, source, env):
160 def __call__(self, node):
162 return node.found_includes
163 def select(self, node):
166 class MyNode(SCons.Node.Node):
167 """The base Node class contains a number of do-nothing methods that
168 we expect to be overridden by real, functional Node subclasses. So
169 simulate a real, functional Node subclass.
171 def __init__(self, name):
172 SCons.Node.Node.__init__(self)
174 self.found_includes = []
177 def get_found_includes(self, env, scanner, target):
182 class NodeTestCase(unittest.TestCase):
184 def test_build(self):
185 """Test building a node
187 global built_it, built_order
189 # Make sure it doesn't blow up if no builder is set.
192 assert built_it == None
193 node.build(extra_kw_argument = 1)
194 assert built_it == None
197 node.builder_set(Builder())
198 node.env_set(Environment())
200 node.sources = ["yyy", "zzz"]
203 assert built_target == [node], built_target
204 assert built_source == ["yyy", "zzz"], built_source
208 node.builder_set(NoneBuilder())
209 node.env_set(Environment())
211 node.sources = ["rrr", "sss"]
212 node.builder.overrides = { "foo" : 1, "bar" : 2 }
215 assert built_target == [node], built_target
216 assert built_source == ["rrr", "sss"], built_source
217 assert built_args["foo"] == 1, built_args
218 assert built_args["bar"] == 2, built_args
222 lb = ListBuilder(fff, ggg)
230 fff.sources = ["hhh", "iii"]
231 ggg.sources = ["hhh", "iii"]
232 # [Charles C. 1/7/2002] Uhhh, why are there no asserts here?
233 # [SK, 15 May 2003] I dunno, let's add some...
237 assert built_target == [fff], built_target
238 assert built_source == ["hhh", "iii"], built_source
242 assert built_target == [ggg], built_target
243 assert built_source == ["hhh", "iii"], built_source
249 # NOTE: No env_set()! We should pull the environment from the builder.
250 b.env = Environment()
251 b.overrides = { "on" : 3, "off" : 4 }
255 assert built_target[0] == jjj, built_target[0]
256 assert built_source == [], built_source
257 assert built_args["on"] == 3, built_args
258 assert built_args["off"] == 4, built_args
263 node.builder_set(Builder())
264 node.env_set(Environment())
265 node.sources = ["yyy", "zzz"]
266 pre1 = MyNonGlobalAction()
267 pre2 = MyNonGlobalAction()
268 post1 = MyNonGlobalAction()
269 post2 = MyNonGlobalAction()
270 node.add_pre_action(pre1)
271 node.add_pre_action(pre2)
272 node.add_post_action(post1)
273 node.add_post_action(post2)
278 assert post1.built_it
279 assert post2.built_it
280 assert pre1.order == 1, pre1.order
281 assert pre2.order == 2, pre1.order
282 # The action of the builder itself is order 3...
283 assert post1.order == 4, pre1.order
284 assert post2.order == 5, pre1.order
286 for act in [ pre1, pre2, post1, post2 ]:
287 assert type(act.built_target[0]) == type(MyNode("bar")), type(act.built_target[0])
288 assert str(act.built_target[0]) == "xxx", str(act.built_target[0])
289 assert act.built_source == ["yyy", "zzz"], act.built_source
291 def test_built(self):
292 """Test the built() method"""
293 class SubNode(SCons.Node.Node):
299 assert n.cleared, n.cleared
301 def test_retrieve_from_cache(self):
302 """Test the base retrieve_from_cache() method"""
303 n = SCons.Node.Node()
304 r = n.retrieve_from_cache()
307 def test_visited(self):
308 """Test the base visited() method
310 Just make sure it's there and we can call it.
312 n = SCons.Node.Node()
315 def test_depends_on(self):
316 """Test the depends_on() method
318 parent = SCons.Node.Node()
319 child = SCons.Node.Node()
320 parent.add_dependency([child])
321 assert parent.depends_on([child])
323 def test_builder_set(self):
324 """Test setting a Node's Builder
326 node = SCons.Node.Node()
329 assert node.builder == b
331 def test_has_builder(self):
332 """Test the has_builder() method
334 n1 = SCons.Node.Node()
335 assert n1.has_builder() == 0
336 n1.builder_set(Builder())
337 assert n1.has_builder() == 1
339 def test_has_explicit_builder(self):
340 """Test the has_explicit_builder() method
342 n1 = SCons.Node.Node()
343 assert not n1.has_explicit_builder()
344 n1.builder_set(Builder(is_explicit=1))
345 assert n1.has_explicit_builder()
346 n1.builder_set(Builder(is_explicit=None))
347 assert not n1.has_explicit_builder()
349 def test_multiple_side_effect_has_builder(self):
350 """Test the multiple_side_effect_has_builder() method
352 n1 = SCons.Node.Node()
353 assert n1.multiple_side_effect_has_builder() == 0
354 n1.builder_set(Builder())
355 assert n1.multiple_side_effect_has_builder() == 1
357 def test_is_derived(self):
358 """Test the is_derived() method
360 n1 = SCons.Node.Node()
361 n2 = SCons.Node.Node()
362 n3 = SCons.Node.Node()
364 n2.builder_set(Builder())
367 assert n1.is_derived() == 0
368 assert n2.is_derived() == 1
369 assert n3.is_derived() == 1
371 def test_alter_targets(self):
372 """Test the alter_targets() method
374 n = SCons.Node.Node()
375 t, m = n.alter_targets()
379 def test_current(self):
380 """Test the default current() method
382 node = SCons.Node.Node()
383 assert node.current() is None
385 def test_env_set(self):
386 """Test setting a Node's Environment
388 node = SCons.Node.Node()
393 def test_get_actions(self):
394 """Test fetching a Node's action list
396 node = SCons.Node.Node()
397 node.builder_set(Builder())
398 a = node.builder.get_actions()
399 assert isinstance(a[0], MyAction), a[0]
401 def test_calc_bsig(self):
402 """Test generic build signature calculation
405 def __init__(self, val):
408 def __init__(self, val):
410 def collect(self, args):
411 return reduce(lambda x, y: x+y, args, self.val)
413 node = SCons.Node.Node()
414 result = node.calc_bsig(Calculator(222))
415 assert result == 222, result
416 result = node.calc_bsig(Calculator(333))
417 assert result == 222, result
419 def test_calc_csig(self):
420 """Test generic content signature calculation
423 def __init__(self, val):
426 def __init__(self, val):
428 def signature(self, args):
431 node = SCons.Node.Node()
432 result = node.calc_csig(Calculator(444))
433 assert result == 444, result
434 result = node.calc_csig(Calculator(555))
435 assert result == 444, result
437 def test_gen_binfo(self):
438 """Test generating a build information structure
441 def __init__(self, val):
444 def __init__(self, val):
446 def collect(self, args):
447 return reduce(lambda x, y: x+y, args, self.val)
450 node = SCons.Node.Node()
451 binfo = node.gen_binfo(Calculator(666))
452 assert isinstance(binfo, SCons.Node.BuildInfo), binfo
453 assert hasattr(binfo, 'bsources')
454 assert hasattr(binfo, 'bsourcesigs')
455 assert hasattr(binfo, 'bdepends')
456 assert hasattr(binfo, 'bdependsigs')
457 assert hasattr(binfo, 'bimplicit')
458 assert hasattr(binfo, 'bimplicitsigs')
459 assert binfo.bsig == 666, binfo.bsig
461 def test_explain(self):
462 """Test explaining why a Node must be rebuilt
464 node = SCons.Node.Node()
465 node.exists = lambda: None
466 node.__str__ = lambda: 'xyzzy'
467 result = node.explain()
468 assert result == "building `xyzzy' because it doesn't exist\n", result
470 node = SCons.Node.Node()
471 result = node.explain()
472 assert result == None, result
478 node.get_stored_info = Null_BInfo
479 node.__str__ = lambda: 'null_binfo'
480 result = node.explain()
481 assert result == "Cannot explain why `null_binfo' is being rebuilt: No previous build information found\n", result
483 # XXX additional tests for the guts of the functionality some day
485 def test_del_binfo(self):
486 """Test deleting the build information from a Node
488 node = SCons.Node.Node()
491 assert not hasattr(node, 'binfo'), node
493 def test_store_info(self):
494 """Test calling the method to store build information
498 node = SCons.Node.Node()
499 node.store_info(Entry())
501 def test_get_stored_info(self):
502 """Test calling the method to fetch stored build information
504 node = SCons.Node.Node()
505 result = node.get_stored_info()
506 assert result is None, result
508 def test_set_always_build(self):
509 """Test setting a Node's always_build value
511 node = SCons.Node.Node()
512 node.set_always_build()
513 assert node.always_build
514 node.set_always_build(3)
515 assert node.always_build == 3
517 def test_set_precious(self):
518 """Test setting a Node's precious value
520 node = SCons.Node.Node()
524 assert node.precious == 7
526 def test_exists(self):
527 """Test evaluating whether a Node exists.
529 node = SCons.Node.Node()
533 def test_exists(self):
534 """Test evaluating whether a Node exists locally or in a repository.
536 node = SCons.Node.Node()
540 class MyNode(SCons.Node.Node):
548 def test_prepare(self):
549 """Test preparing a node to be built
551 node = SCons.Node.Node()
553 n1 = SCons.Node.Node()
554 n1.builder_set(Builder())
556 node.implicit_dict = {}
557 node._add_child(node.implicit, node.implicit_dict, [n1])
559 node.prepare() # should not throw an exception
561 n2 = SCons.Node.Node()
564 node.implicit_dict = {}
565 node._add_child(node.implicit, node.implicit_dict, [n2])
567 node.prepare() # should not throw an exception
569 n3 = SCons.Node.Node()
571 node.implicit_dict = {}
572 node._add_child(node.implicit, node.implicit_dict, [n3])
574 node.prepare() # should not throw an exception
576 class MyNode(SCons.Node.Node):
581 node.implicit_dict = {}
582 node._add_child(node.implicit, node.implicit_dict, [n4])
586 except SCons.Errors.StopError:
588 assert exc_caught, "did not catch expected StopError"
590 def test_add_dependency(self):
591 """Test adding dependencies to a Node's list.
593 node = SCons.Node.Node()
594 assert node.depends == []
596 zero = SCons.Node.Node()
598 one = SCons.Node.Node()
599 two = SCons.Node.Node()
600 three = SCons.Node.Node()
601 four = SCons.Node.Node()
602 five = SCons.Node.Node()
603 six = SCons.Node.Node()
605 node.add_dependency(zero)
606 assert node.depends == [zero]
607 node.add_dependency([one])
608 assert node.depends == [zero, one]
609 node.add_dependency([two, three])
610 assert node.depends == [zero, one, two, three]
611 node.add_dependency([three, four, one])
612 assert node.depends == [zero, one, two, three, four]
615 node.add_depends([[five, six]])
619 raise "did not catch expected exception"
620 assert node.depends == [zero, one, two, three, four]
623 def test_add_source(self):
624 """Test adding sources to a Node's list.
626 node = SCons.Node.Node()
627 assert node.sources == []
629 zero = SCons.Node.Node()
630 one = SCons.Node.Node()
631 two = SCons.Node.Node()
632 three = SCons.Node.Node()
633 four = SCons.Node.Node()
634 five = SCons.Node.Node()
635 six = SCons.Node.Node()
637 node.add_source(zero)
638 assert node.sources == [zero]
639 node.add_source([one])
640 assert node.sources == [zero, one]
641 node.add_source([two, three])
642 assert node.sources == [zero, one, two, three]
643 node.add_source([three, four, one])
644 assert node.sources == [zero, one, two, three, four]
647 node.add_source([[five, six]])
651 raise "did not catch expected exception"
652 assert node.sources == [zero, one, two, three, four]
654 def test_add_ignore(self):
655 """Test adding files whose dependencies should be ignored.
657 node = SCons.Node.Node()
658 assert node.ignore == []
660 zero = SCons.Node.Node()
661 one = SCons.Node.Node()
662 two = SCons.Node.Node()
663 three = SCons.Node.Node()
664 four = SCons.Node.Node()
665 five = SCons.Node.Node()
666 six = SCons.Node.Node()
668 node.add_ignore(zero)
669 assert node.ignore == [zero]
670 node.add_ignore([one])
671 assert node.ignore == [zero, one]
672 node.add_ignore([two, three])
673 assert node.ignore == [zero, one, two, three]
674 node.add_ignore([three, four, one])
675 assert node.ignore == [zero, one, two, three, four]
678 node.add_ignore([[five, six]])
682 raise "did not catch expected exception"
683 assert node.ignore == [zero, one, two, three, four]
685 def test_get_found_includes(self):
686 """Test the default get_found_includes() method
688 node = SCons.Node.Node()
689 target = SCons.Node.Node()
691 deps = node.get_found_includes(e, None, target)
692 assert deps == [], deps
694 def test_get_implicit_deps(self):
695 """Test get_implicit_deps()
698 target = MyNode("ttt")
701 # No scanner at all returns []
702 deps = node.get_implicit_deps(env, None, target)
703 assert deps == [], deps
707 node.found_includes = [d]
709 # Simple return of the found includes
710 deps = node.get_implicit_deps(env, s, target)
711 assert deps == [d], deps
713 # No "recursive" attribute on scanner doesn't recurse
715 d.found_includes = [e]
716 deps = node.get_implicit_deps(env, s, target)
717 assert deps == [d], map(str, deps)
719 # Explicit "recursive" attribute on scanner doesn't recurse
721 deps = node.get_implicit_deps(env, s, target)
722 assert deps == [d], map(str, deps)
724 # Explicit "recursive" attribute on scanner which does recurse
726 deps = node.get_implicit_deps(env, s, target)
727 assert deps == [d, e], map(str, deps)
729 # Recursive scanning eliminates duplicates
731 d.found_includes = [e, f]
732 e.found_includes = [f]
733 deps = node.get_implicit_deps(env, s, target)
734 assert deps == [d, e, f], map(str, deps)
736 def test_get_source_scanner(self):
737 """Test fetching the source scanner for a Node
741 target = SCons.Node.Node()
742 source = SCons.Node.Node()
743 s = target.get_source_scanner(source)
750 source.backup_source_scanner = ts1
751 s = target.get_source_scanner(source)
754 target.builder = Builder()
755 target.builder.source_scanner = ts2
756 s = target.get_source_scanner(source)
759 target.source_scanner = ts3
760 s = target.get_source_scanner(source)
764 """Test Scanner functionality
767 node.builder = Builder()
768 node.env_set(Environment())
772 node.found_includes = [d]
774 assert node.target_scanner == None, node.target_scanner
775 node.target_scanner = s
776 assert node.implicit is None
780 assert node.implicit == [d], node.implicit
782 # Check that scanning a node with some stored implicit
783 # dependencies resets internal attributes appropriately
784 # if the stored dependencies need recalculation.
785 class StoredNode(MyNode):
786 def get_stored_implicit(self):
787 return ['implicit1', 'implicit2']
790 def current(self, node, sig):
792 def bsig(self, node):
797 save_default_calc = SCons.Sig.default_calc
798 save_implicit_cache = SCons.Node.implicit_cache
799 save_implicit_deps_changed = SCons.Node.implicit_deps_changed
800 save_implicit_deps_unchanged = SCons.Node.implicit_deps_unchanged
801 SCons.Sig.default_calc = NotCurrent()
802 SCons.Node.implicit_cache = 1
803 SCons.Node.implicit_deps_changed = None
804 SCons.Node.implicit_deps_unchanged = None
806 sn = StoredNode("eee")
807 sn._children = ['fake']
808 sn.target_scanner = s
812 assert sn.implicit == [], sn.implicit
813 assert not hasattr(sn, '_children'), "unexpected _children attribute"
815 SCons.Sig.default_calc = save_default_calc
816 SCons.Node.implicit_cache = save_implicit_cache
817 SCons.Node.implicit_deps_changed = save_implicit_deps_changed
818 SCons.Node.implicit_deps_unchanged = save_implicit_deps_unchanged
820 def test_scanner_key(self):
821 """Test that a scanner_key() method exists"""
822 assert SCons.Node.Node().scanner_key() == None
824 def test_children(self):
825 """Test fetching the non-ignored "children" of a Node.
827 node = SCons.Node.Node()
828 n1 = SCons.Node.Node()
829 n2 = SCons.Node.Node()
830 n3 = SCons.Node.Node()
831 n4 = SCons.Node.Node()
832 n5 = SCons.Node.Node()
833 n6 = SCons.Node.Node()
834 n7 = SCons.Node.Node()
835 n8 = SCons.Node.Node()
836 n9 = SCons.Node.Node()
837 n10 = SCons.Node.Node()
838 n11 = SCons.Node.Node()
839 n12 = SCons.Node.Node()
841 node.add_source([n1, n2, n3])
842 node.add_dependency([n4, n5, n6])
844 node.implicit_dict = {}
845 node._add_child(node.implicit, node.implicit_dict, [n7, n8, n9])
846 node._add_child(node.implicit, node.implicit_dict, [n10, n11, n12])
847 node.add_ignore([n2, n5, n8, n11])
849 kids = node.children()
850 for kid in [n1, n3, n4, n6, n7, n9, n10, n12]:
851 assert kid in kids, kid
852 for kid in [n2, n5, n8, n11]:
853 assert not kid in kids, kid
855 def test_all_children(self):
856 """Test fetching all the "children" of a Node.
858 node = SCons.Node.Node()
859 n1 = SCons.Node.Node()
860 n2 = SCons.Node.Node()
861 n3 = SCons.Node.Node()
862 n4 = SCons.Node.Node()
863 n5 = SCons.Node.Node()
864 n6 = SCons.Node.Node()
865 n7 = SCons.Node.Node()
866 n8 = SCons.Node.Node()
867 n9 = SCons.Node.Node()
868 n10 = SCons.Node.Node()
869 n11 = SCons.Node.Node()
870 n12 = SCons.Node.Node()
872 node.add_source([n1, n2, n3])
873 node.add_dependency([n4, n5, n6])
875 node.implicit_dict = {}
876 node._add_child(node.implicit, node.implicit_dict, [n7, n8, n9])
877 node._add_child(node.implicit, node.implicit_dict, [n10, n11, n12])
878 node.add_ignore([n2, n5, n8, n11])
880 kids = node.all_children()
881 for kid in [n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12]:
882 assert kid in kids, kid
884 def test_state(self):
885 """Test setting and getting the state of a node
887 node = SCons.Node.Node()
888 assert node.get_state() == None
889 node.set_state(SCons.Node.executing)
890 assert node.get_state() == SCons.Node.executing
891 assert SCons.Node.pending < SCons.Node.executing
892 assert SCons.Node.executing < SCons.Node.up_to_date
893 assert SCons.Node.up_to_date < SCons.Node.executed
894 assert SCons.Node.executed < SCons.Node.failed
896 def test_walker(self):
897 """Test walking a Node tree.
902 nw = SCons.Node.Walker(n1)
903 assert not nw.is_done()
904 assert nw.next().name == "n1"
906 assert nw.next() == None
910 n1.add_source([n2, n3])
912 nw = SCons.Node.Walker(n1)
914 assert n.name == "n2", n.name
916 assert n.name == "n3", n.name
918 assert n.name == "n1", n.name
926 n2.add_source([n4, n5])
927 n3.add_dependency([n6, n7])
929 nw = SCons.Node.Walker(n1)
930 assert nw.next().name == "n4"
931 assert nw.next().name == "n5"
932 assert nw.history.has_key(n2)
933 assert nw.next().name == "n2"
934 assert nw.next().name == "n6"
935 assert nw.next().name == "n7"
936 assert nw.history.has_key(n3)
937 assert nw.next().name == "n3"
938 assert nw.history.has_key(n1)
939 assert nw.next().name == "n1"
940 assert nw.next() == None
943 n8.add_dependency([n3])
944 n7.add_dependency([n8])
946 def cycle(node, stack):
947 global cycle_detected
950 global cycle_detected
952 nw = SCons.Node.Walker(n3, cycle_func = cycle)
954 assert n.name == "n6", n.name
956 assert n.name == "n8", n.name
957 assert cycle_detected
958 cycle_detected = None
960 assert n.name == "n7", n.name
962 assert nw.next() == None
964 def test_abspath(self):
965 """Test the get_abspath() method."""
967 assert n.get_abspath() == str(n), n.get_abspath()
969 def test_for_signature(self):
970 """Test the for_signature() method."""
972 assert n.for_signature() == str(n), n.get_abspath()
974 def test_get_string(self):
975 """Test the get_string() method."""
976 class TestNode(MyNode):
977 def __init__(self, name, sig):
978 MyNode.__init__(self, name)
981 def for_signature(self):
984 n = TestNode("foo", "bar")
985 assert n.get_string(0) == "foo", n.get_string(0)
986 assert n.get_string(1) == "bar", n.get_string(1)
988 def test_literal(self):
989 """Test the is_literal() function."""
991 assert n.is_literal()
993 def test_Annotate(self):
994 """Test using an interface-specific Annotate function."""
995 def my_annotate(node, self=self):
996 node.annotation = self.node_string
998 save_Annotate = SCons.Node.Annotate
999 SCons.Node.Annotate = my_annotate
1002 self.node_string = '#1'
1003 n = SCons.Node.Node()
1004 assert n.annotation == '#1', n.annotation
1006 self.node_string = '#2'
1007 n = SCons.Node.Node()
1008 assert n.annotation == '#2', n.annotation
1010 SCons.Node.Annotate = save_Annotate
1012 def test_clear(self):
1013 """Test clearing all cached state information."""
1014 n = SCons.Node.Node()
1018 n.includes = 'testincludes'
1019 n.found_include = {'testkey':'testvalue'}
1020 n.implicit = 'testimplicit'
1021 n.waiting_parents = ['foo', 'bar']
1025 assert n.get_state() is None, n.get_state()
1026 assert not hasattr(n, 'binfo'), n.bsig
1027 assert n.includes is None, n.includes
1028 assert n.found_includes == {}, n.found_includes
1029 assert n.implicit is None, n.implicit
1030 assert n.waiting_parents == [], n.waiting_parents
1032 def test_get_subst_proxy(self):
1033 """Test the get_subst_proxy method."""
1036 assert n.get_subst_proxy() == n, n.get_subst_proxy()
1038 def test_new_binfo(self):
1039 """Test the new_binfo() method"""
1040 n = SCons.Node.Node()
1041 result = n.new_binfo()
1042 assert isinstance(result, SCons.Node.BuildInfo), result
1044 def test_get_suffix(self):
1045 """Test the base Node get_suffix() method"""
1046 n = SCons.Node.Node()
1050 def test_generate_build_dict(self):
1051 """Test the base Node generate_build_dict() method"""
1052 n = SCons.Node.Node()
1053 dict = n.generate_build_dict()
1054 assert dict == {}, dict
1056 def test_postprocess(self):
1057 """Test calling the base Node postprocess() method"""
1058 n = SCons.Node.Node()
1061 def test_add_to_waiting_parents(self):
1062 """Test the add_to_waiting_parents() method"""
1063 n1 = SCons.Node.Node()
1064 n2 = SCons.Node.Node()
1065 assert n1.waiting_parents == [], n1.waiting_parents
1066 n1.add_to_waiting_parents(n2)
1067 assert n1.waiting_parents == [n2], n1.waiting_parents
1069 def test_call_for_all_waiting_parents(self):
1070 """Test the call_for_all_waiting_parents() method"""
1071 n1 = SCons.Node.Node()
1072 n2 = SCons.Node.Node()
1073 n1.add_to_waiting_parents(n2)
1075 def func(node, result=result):
1077 n1.call_for_all_waiting_parents(func)
1078 assert result == [n1, n2], result
1082 if __name__ == "__main__":
1083 suite = unittest.makeSuite(NodeTestCase, 'test_')
1084 if not unittest.TextTestRunner().run(suite).wasSuccessful():