- Enhance .POSIX to set -e when invoking shells, as demanded by a
[make.git] / tests / scripts / features / vpathplus
bloba37fbedd479f5233a99d2e85fb75a4dfd8eb1b75
1 #                                                                    -*-perl-*-
2 $description = "Tests the new VPATH+ functionality added in 3.76.";
4 $details = "";
6 $VP = "$workdir$pathsep";
8 open(MAKEFILE,"> $makefile");
10 # The Contents of the MAKEFILE ...
12 print MAKEFILE "VPATH = $VP\n";
14 print MAKEFILE <<'EOMAKE';
16 SHELL = /bin/sh
18 .SUFFIXES: .a .b .c .d
19 .PHONY: general rename notarget intermediate
21 %.a:
22 %.b:
23 %.c:
24 %.d:
26 %.a : %.b
27         cat $^ > $@
28 %.b : %.c
29         cat $^ > $@ 2>/dev/null || exit 1
30 %.c :: %.d
31         cat $^ > $@
33 # General testing info:
35 general: foo.b
36 foo.b: foo.c bar.c
38 # Rename testing info:
40 rename: $(VPATH)/foo.c foo.d
42 # Target not made testing info:
44 notarget: notarget.b
45 notarget.c: notarget.d
46         -@echo "not creating $@ from $^"
48 # Intermediate files:
50 intermediate: inter.a
52 EOMAKE
54 close(MAKEFILE);
56 @touchedfiles = ();
58 $off = -500;
60 sub touchfiles {
61   foreach (@_) {
62     &utouch($off, $_);
63     $off += 10;
64     push(@touchedfiles, $_);
65   }
68 # Run the general-case test
70 &touchfiles("$VP/foo.d", "$VP/bar.d", "$VP/foo.c", "$VP/bar.c", "foo.b", "bar.d");
72 &run_make_with_options($makefile,"general",&get_logfile);
74 push(@touchedfiles, "bar.c");
76 $answer = "cat bar.d > bar.c
77 cat ${VP}foo.c bar.c > foo.b 2>/dev/null || exit 1
79 &compare_output($answer,&get_logfile(1));
81 # Test rules that don't make the target correctly
83 &touchfiles("$VP/notarget.c", "notarget.b", "notarget.d");
85 &run_make_with_options($makefile,"notarget",&get_logfile,512);
87 $answer = "not creating notarget.c from notarget.d
88 cat notarget.c > notarget.b 2>/dev/null || exit 1
89 $make_name: *** [notarget.b] Error 1
92 &compare_output($answer,&get_logfile(1));
94 # Test intermediate file handling (part 1)
96 &touchfiles("$VP/inter.d");
98 &run_make_with_options($makefile,"intermediate",&get_logfile);
100 push(@touchedfiles, "inter.a", "inter.b");
102 $answer = "cat ${VP}inter.d > inter.c
103 cat inter.c > inter.b 2>/dev/null || exit 1
104 cat inter.b > inter.a
105 rm inter.b inter.c
107 &compare_output($answer,&get_logfile(1));
109 # Test intermediate file handling (part 2)
111 &utouch(-20, "inter.a");
112 &utouch(-10, "$VP/inter.b");
113 &touch("$VP/inter.d");
115 push(@touchedfiles, "$VP/inter.b", "$VP/inter.d");
117 &run_make_with_options($makefile,"intermediate",&get_logfile);
119 $answer = "cat ${VP}inter.d > inter.c
120 cat inter.c > inter.b 2>/dev/null || exit 1
121 cat inter.b > inter.a
122 rm inter.c
124 &compare_output($answer,&get_logfile(1));
126 unlink @touchedfiles unless $keep;