summaryrefslogtreecommitdiff
path: root/dmake/tests/targets-28
blob: 0943eb6677ff9114cc6d59b9d18efc57025696fb (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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#!/bin/sh

# 25.08.2007 Volker Quetschke
# Check that dmake handles dependencies correctly.
# (issue 64572)

: ${DMAKEPROG:=dmake}
file1="mfile1.mk"
file2="aa.x"
file3="aa.y"
file4="aa.z"
tmpfiles="$file1 $file2 $file3 $file4"

trap '{ echo "trapped signal - removing temporary files" ; rm -rf $tmpfiles ; }' 1 2 3 15

# Remove files from prior failed run
rm -rf $tmpfiles

# Remember to quote variables in generated makefiles( $ -> \$ ).
# Test 1
cat > $file1 <<EOT
SHELL*:=/bin/sh
SHELLFLAGS*:=-ce

aa.x : aa.y
	@echo nothing

aa.y :
	@echo \$@

EOT

# Create test environment
touch aa.x
# Avoid that aa.x has the same time stamp as aa.y after
# that has been rebuild.
sleep 1

output1=`eval ${DMAKEPROG} -rf $file1 2>&1`
result1=$?

if test $result1 = 0 && echo $output1 | grep 'Warning: -- Target \[aa.x\] was made but the time stamp has not been updated.' > /dev/null 2>&1 ; then
  echo "Subtest 1: OK"
  result1=0
else
  echo "Subtest 1: Wrong result: $output1"
  echo
  result1=1
fi


# Remember to quote variables in generated makefiles( $ -> \$ ).
# Test 2 - Warn if virtual targets have a corresponding file.
cat > $file1 <<EOT
SHELL*:=/bin/sh
SHELLFLAGS*:=-ce

aa.x : aa.y
	@echo X\$@X
	@touch \$@

# Should warn - aa.y exists.
aa.y : aa.z

aa.z :
	@printf Z\$@Z

EOT

# Create test environment
rm -f aa.x
touch aa.y
# Avoid the same time after build.
sleep 1

output2=`eval ${DMAKEPROG} -rf $file1 2>&1`
result2=$?

if test $result2 = 0 && echo $output2 | grep 'Warning: -- Found file corresponding to virtual target \[aa.y\].' > /dev/null 2>&1 ; then
  echo "Subtest 2: OK"
  result2=0
else
  echo "Subtest 2: Wrong result: $output2"
  echo
  result2=1
fi


# Remember to quote variables in generated makefiles( $ -> \$ ).
# Test 3
cat > $file1 <<EOT
SHELL*:=/bin/sh
SHELLFLAGS*:=-ce

aa.x : aa.y
	@echo X\$@X
	@touch \$@

aa.y : aa.z

aa.z :
	@printf Z\$@Z
	@touch \$@

EOT

# Create test environment
rm -f aa.y
touch aa.z ; sleep 1 ; touch aa.x
# Avoid the same time after build.
sleep 1

# This tests that aa.x is not build as the dependency chain is intact with
# the virtual target aa.y having the same time stamp as aa.z.
output3=`eval ${DMAKEPROG} -vm -rf $file1 2>&1`
result3=$?

if test $result3 = 0 && echo "$output3" | grep "aa.x' is up to date"  > /dev/null 2>&1 ; then
  echo "Subtest 3: OK"
  result3=0
else
  echo "Subtest 3: Wrong result: :$output3:"
  echo
  result3=1
fi


# Remember to quote variables in generated makefiles( $ -> \$ ).
# Test 4
cat > $file1 <<EOT
SHELL*:=/bin/sh
SHELLFLAGS*:=-ce

aa.x : aa.y
	@echo Build \$@
	@touch \$@

aa.y : aa.z

aa.z :
	@printf Z\$@Z
	@touch \$@

EOT

# Create test environment
touch aa.z ; sleep 1 ; touch aa.x
# Create a file for the virtual target that is newer than aa.x
sleep 1 ; touch aa.y
# Avoid the same time after build.
sleep 1

# This tests that aa.x is build.
output4=`eval ${DMAKEPROG} -rf $file1 2>&1`
result4=$?

if test $result4 = 0 -a "$output4" = "Build aa.x" ; then
  echo "Subtest 4: OK"
  result4=0
else
  echo "Subtest 4: Wrong result: :$output4:"
  echo
  result4=1
fi


if test $result1 -eq 0 -a $result2 -eq 0 \
    -a $result3 -eq 0 -a $result4 -eq 0  ; then
  echo "Success - Cleaning up"
  rm -rf $tmpfiles
  exit
else
  echo "Failure!"
  exit 1
fi