Home | History | Annotate | Download | only in features
      1 #                                                                    -*-perl-*-
      2 $description = "Test order-only prerequisites.";
      3 
      4 $details = "\
      5 Create makefiles with various combinations of normal and order-only
      6 prerequisites and ensure they behave properly.  Test the \$| variable.";
      7 
      8 # TEST #0 -- Basics
      9 
     10 run_make_test('
     11 %r: | baz ; @echo $< $^ $|
     12 bar: foo
     13 foo:;@:
     14 baz:;@:',
     15               '', "foo foo baz\n");
     16 
     17 # TEST #1 -- First try: the order-only prereqs need to be built.
     18 
     19 run_make_test(q!
     20 foo: bar | baz
     21 	@echo '$$^ = $^'
     22 	@echo '$$| = $|'
     23 	touch $@
     24 
     25 .PHONY: baz
     26 
     27 bar baz:
     28 	touch $@!,
     29               '', "touch bar\ntouch baz\n\$^ = bar\n\$| = baz\ntouch foo\n");
     30 
     31 
     32 # TEST #2 -- now we do it again: baz is PHONY but foo should _NOT_ be updated
     33 
     34 run_make_test(undef, '', "touch baz\n");
     35 
     36 unlink(qw(foo bar baz));
     37 
     38 # TEST #3 -- Make sure the order-only prereq was promoted to normal.
     39 
     40 run_make_test(q!
     41 foo: bar | baz
     42 	@echo '$$^ = $^'
     43 	@echo '$$| = $|'
     44 	touch $@
     45 
     46 foo: baz
     47 
     48 .PHONY: baz
     49 
     50 bar baz:
     51 	touch $@!,
     52               '', "touch bar\ntouch baz\n\$^ = bar baz\n\$| = \ntouch foo\n");
     53 
     54 
     55 # TEST #4 -- now we do it again
     56 
     57 run_make_test(undef, '', "touch baz\n\$^ = bar baz\n\$| = \ntouch foo\n");
     58 
     59 unlink(qw(foo bar baz));
     60 
     61 # Test empty normal prereqs
     62 
     63 # TEST #5 -- make sure the parser was correct.
     64 
     65 run_make_test(q!
     66 foo:| baz
     67 	@echo '$$^ = $^'
     68 	@echo '$$| = $|'
     69 	touch $@
     70 
     71 .PHONY: baz
     72 
     73 baz:
     74 	touch $@!,
     75               '', "touch baz\n\$^ = \n\$| = baz\ntouch foo\n");
     76 
     77 # TEST #6 -- now we do it again: this time foo won't be built
     78 
     79 run_make_test(undef, '', "touch baz\n");
     80 
     81 unlink(qw(foo baz));
     82 
     83 # Test order-only in pattern rules
     84 
     85 # TEST #7 -- make sure the parser was correct.
     86 
     87 run_make_test(q!
     88 %.w : %.x | baz
     89 	@echo '$$^ = $^'
     90 	@echo '$$| = $|'
     91 	touch $@
     92 
     93 all: foo.w
     94 
     95 .PHONY: baz
     96 foo.x baz:
     97 	touch $@!,
     98               '',
     99               "touch foo.x\ntouch baz\n\$^ = foo.x\n\$| = baz\ntouch foo.w\n");
    100 
    101 # TEST #8 -- now we do it again: this time foo.w won't be built
    102 
    103 run_make_test(undef, '', "touch baz\n");
    104 
    105 unlink(qw(foo.w foo.x baz));
    106 
    107 # TEST #9 -- make sure that $< is set correctly in the face of order-only
    108 # prerequisites in pattern rules.
    109 
    110 run_make_test('
    111 %r: | baz ; @echo $< $^ $|
    112 bar: foo
    113 foo:;@:
    114 baz:;@:',
    115               '', "foo foo baz\n");
    116 
    117 
    118 1;
    119