Debian Codegraph @

tests/scripts/features/vpathplus

raw
1 # -*-perl-*-
2 $description = "Tests the new VPATH+ functionality added in 3.76.";
3
4 $details = "";
5
6 $VP = "$workdir$pathsep";
7
8 @touchedfiles = ();
9
10 $off = -500;
11
12 sub touchfiles {
13 foreach (@_) {
14 &utouch($off, $_);
15 $off += 10;
16 push(@touchedfiles, $_);
17 }
18 }
19
20 &touchfiles("$VP/foo.d", "$VP/bar.d", "$VP/foo.c", "$VP/bar.c", "foo.b", "bar.d");
21
22 # Run the general-case test
23
24 run_make_test(qq!VPATH = $VP! . q!
25 .SUFFIXES: .a .b .c .d
26 .PHONY: general rename notarget intermediate
27
28 %.a:
29 %.b:
30 %.c:
31 %.d:
32
33 %.a : %.b ; cat $^ > $@
34 %.b : %.c ; cat $^ > $@ 2>/dev/null || exit 1
35 %.c :: %.d ; cat $^ > $@
36
37 # General testing info:
38
39 general: foo.b
40 foo.b: foo.c bar.c
41
42 # Rename testing info:
43
44 rename: $(VPATH)/foo.c foo.d
45
46 # Target not made testing info:
47
48 notarget: notarget.b
49 notarget.c: notarget.d ; -@echo "not creating $@ from $^"
50
51 # Intermediate files:
52
53 intermediate: inter.a
54 !,
55 'general', "cat bar.d > bar.c\ncat ${VP}foo.c bar.c > foo.b 2>/dev/null || exit 1\n");
56
57 push(@touchedfiles, "bar.c");
58
59 # Test rules that don't make the target correctly
60
61 &touchfiles("$VP/notarget.c", "notarget.b", "notarget.d");
62
63 run_make_test(undef, 'notarget', "not creating notarget.c from notarget.d\ncat notarget.c > notarget.b 2>/dev/null || exit 1\n#MAKE#: *** [#MAKEFILE#:11: notarget.b] Error 1\n", 512);
64
65 # Test intermediate file handling (part 1)
66
67 &touchfiles("$VP/inter.d");
68
69 my $be = pack("L", 1) eq pack("N", 1);
70 my $intfiles = $be ? "inter.c inter.b" : "inter.b inter.c";
71
72 run_make_test(undef, 'intermediate', "cat ${VP}inter.d > inter.c\ncat inter.c > inter.b 2>/dev/null || exit 1\ncat inter.b > inter.a\nrm $intfiles\n");
73
74 push(@touchedfiles, "inter.a", "inter.b");
75
76 # Test intermediate file handling (part 2)
77
78 &utouch(-20, "inter.a");
79 &utouch(-10, "$VP/inter.b");
80 &touch("$VP/inter.d");
81
82 run_make_test(undef, 'intermediate', "cat ${VP}inter.d > inter.c\ncat inter.c > inter.b 2>/dev/null || exit 1\ncat inter.b > inter.a\nrm inter.c\n");
83
84 push(@touchedfiles, "$VP/inter.b", "$VP/inter.d");
85
86 unlink @touchedfiles unless $keep;
87
88 1;