merge the formfield patch from ooo-build
[ooovba.git] / dmake / tests / targets-28
blob0943eb6677ff9114cc6d59b9d18efc57025696fb
1 #!/bin/sh
3 # 25.08.2007 Volker Quetschke
4 # Check that dmake handles dependencies correctly.
5 # (issue 64572)
7 : ${DMAKEPROG:=dmake}
8 file1="mfile1.mk"
9 file2="aa.x"
10 file3="aa.y"
11 file4="aa.z"
12 tmpfiles="$file1 $file2 $file3 $file4"
14 trap '{ echo "trapped signal - removing temporary files" ; rm -rf $tmpfiles ; }' 1 2 3 15
16 # Remove files from prior failed run
17 rm -rf $tmpfiles
19 # Remember to quote variables in generated makefiles( $ -> \$ ).
20 # Test 1
21 cat > $file1 <<EOT
22 SHELL*:=/bin/sh
23 SHELLFLAGS*:=-ce
25 aa.x : aa.y
26 @echo nothing
28 aa.y :
29 @echo \$@
31 EOT
33 # Create test environment
34 touch aa.x
35 # Avoid that aa.x has the same time stamp as aa.y after
36 # that has been rebuild.
37 sleep 1
39 output1=`eval ${DMAKEPROG} -rf $file1 2>&1`
40 result1=$?
42 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
43 echo "Subtest 1: OK"
44 result1=0
45 else
46 echo "Subtest 1: Wrong result: $output1"
47 echo
48 result1=1
52 # Remember to quote variables in generated makefiles( $ -> \$ ).
53 # Test 2 - Warn if virtual targets have a corresponding file.
54 cat > $file1 <<EOT
55 SHELL*:=/bin/sh
56 SHELLFLAGS*:=-ce
58 aa.x : aa.y
59 @echo X\$@X
60 @touch \$@
62 # Should warn - aa.y exists.
63 aa.y : aa.z
65 aa.z :
66 @printf Z\$@Z
68 EOT
70 # Create test environment
71 rm -f aa.x
72 touch aa.y
73 # Avoid the same time after build.
74 sleep 1
76 output2=`eval ${DMAKEPROG} -rf $file1 2>&1`
77 result2=$?
79 if test $result2 = 0 && echo $output2 | grep 'Warning: -- Found file corresponding to virtual target \[aa.y\].' > /dev/null 2>&1 ; then
80 echo "Subtest 2: OK"
81 result2=0
82 else
83 echo "Subtest 2: Wrong result: $output2"
84 echo
85 result2=1
89 # Remember to quote variables in generated makefiles( $ -> \$ ).
90 # Test 3
91 cat > $file1 <<EOT
92 SHELL*:=/bin/sh
93 SHELLFLAGS*:=-ce
95 aa.x : aa.y
96 @echo X\$@X
97 @touch \$@
99 aa.y : aa.z
101 aa.z :
102 @printf Z\$@Z
103 @touch \$@
107 # Create test environment
108 rm -f aa.y
109 touch aa.z ; sleep 1 ; touch aa.x
110 # Avoid the same time after build.
111 sleep 1
113 # This tests that aa.x is not build as the dependency chain is intact with
114 # the virtual target aa.y having the same time stamp as aa.z.
115 output3=`eval ${DMAKEPROG} -vm -rf $file1 2>&1`
116 result3=$?
118 if test $result3 = 0 && echo "$output3" | grep "aa.x' is up to date" > /dev/null 2>&1 ; then
119 echo "Subtest 3: OK"
120 result3=0
121 else
122 echo "Subtest 3: Wrong result: :$output3:"
123 echo
124 result3=1
128 # Remember to quote variables in generated makefiles( $ -> \$ ).
129 # Test 4
130 cat > $file1 <<EOT
131 SHELL*:=/bin/sh
132 SHELLFLAGS*:=-ce
134 aa.x : aa.y
135 @echo Build \$@
136 @touch \$@
138 aa.y : aa.z
140 aa.z :
141 @printf Z\$@Z
142 @touch \$@
146 # Create test environment
147 touch aa.z ; sleep 1 ; touch aa.x
148 # Create a file for the virtual target that is newer than aa.x
149 sleep 1 ; touch aa.y
150 # Avoid the same time after build.
151 sleep 1
153 # This tests that aa.x is build.
154 output4=`eval ${DMAKEPROG} -rf $file1 2>&1`
155 result4=$?
157 if test $result4 = 0 -a "$output4" = "Build aa.x" ; then
158 echo "Subtest 4: OK"
159 result4=0
160 else
161 echo "Subtest 4: Wrong result: :$output4:"
162 echo
163 result4=1
167 if test $result1 -eq 0 -a $result2 -eq 0 \
168 -a $result3 -eq 0 -a $result4 -eq 0 ; then
169 echo "Success - Cleaning up"
170 rm -rf $tmpfiles
171 exit
172 else
173 echo "Failure!"
174 exit 1