summaryrefslogtreecommitdiff
path: root/tests/scripts/features/vpathplus
blob: 9e935c54dc0ca4c605d42fee9657118a2df960c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#                                                                    -*-perl-*-
$description = "Tests the new VPATH+ functionality added in 3.76.";

$details = "";

mkdir('work');

$VP = "work$pathsep";

@touchedfiles = ();

$off = -500;

sub touchfiles {
  foreach (@_) {
    &utouch($off, $_);
    $off += 10;
    push(@touchedfiles, $_);
  }
}

&touchfiles("$VP/foo.d", "$VP/bar.d", "$VP/foo.c", "$VP/bar.c", "foo.b", "bar.d");

# Run the general-case test

run_make_test(qq!VPATH = $VP! . q!
.SUFFIXES: .a .b .c .d
.PHONY: general rename notarget intermediate

%.a:
%.b:
%.c:
%.d:

%.a : %.b ; cat $^ > $@
%.b : %.c ; cat $^ > $@ 2>/dev/null || exit 1
%.c :: %.d ; cat $^ > $@

# General testing info:

general: foo.b
foo.b: foo.c bar.c

# Rename testing info:

rename: $(VPATH)/foo.c foo.d

# Target not made testing info:

notarget: notarget.b
notarget.c: notarget.d ; -@echo "not creating $@ from $^"

# Intermediate files:

intermediate: inter.a
!,
    'general', "cat bar.d > bar.c\ncat ${VP}foo.c bar.c > foo.b 2>/dev/null || exit 1\n");

push(@touchedfiles, "bar.c");

# Test rules that don't make the target correctly

&touchfiles("$VP/notarget.c", "notarget.b", "notarget.d");

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);

# Test intermediate file handling (part 1)

&touchfiles("$VP/inter.d");

my $be = pack("L", 1) eq pack("N", 1);
my $intfiles = $be ? "inter.c inter.b" : "inter.b inter.c";

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");

push(@touchedfiles, "inter.a", "inter.b");

# Test intermediate file handling (part 2)

&utouch(-20, "inter.a");
&utouch(-10, "$VP/inter.b");
&touch("$VP/inter.d");

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");

push(@touchedfiles, "$VP/inter.b", "$VP/inter.d");

unlink @touchedfiles unless $keep;

1;