No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gmake / tests / scripts / features / export
blob1690ee80193e4d248418515aeee8200c1b9a0377
1 #                                                                    -*-perl-*-
2 $description = "Check GNU make export/unexport commands.";
4 $details = "";
6 # The test driver cleans out our environment for us so we don't have to worry
7 # about that here.
9 open(MAKEFILE,"> $makefile");
11 # The Contents of the MAKEFILE ...
13 print MAKEFILE <<'EOMAKE';
15 FOO = foo
16 BAR = bar
17 BOZ = boz
19 export BAZ = baz
20 export BOZ
22 BITZ = bitz
23 BOTZ = botz
25 export BITZ BOTZ
26 unexport BOTZ
28 ifdef EXPORT_ALL
29 export
30 endif
32 ifdef UNEXPORT_ALL
33 unexport
34 endif
36 ifdef EXPORT_ALL_PSEUDO
37 .EXPORT_ALL_VARIABLES:
38 endif
40 all:
41         @echo "FOO=$(FOO) BAR=$(BAR) BAZ=$(BAZ) BOZ=$(BOZ) BITZ=$(BITZ) BOTZ=$(BOTZ)"
42         @echo "FOO=$$FOO BAR=$$BAR BAZ=$$BAZ BOZ=$$BOZ BITZ=$$BITZ BOTZ=$$BOTZ"
44 EOMAKE
46 close(MAKEFILE);
48 # TEST 0: basics
50 &run_make_with_options($makefile,"",&get_logfile,0);
52 $answer = "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
53 FOO= BAR= BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n";
55 &compare_output($answer,&get_logfile(1));
57 # TEST 1: make sure vars inherited from the parent are exported
59 $ENV{FOO} = 1;
61 &run_make_with_options($makefile,"",&get_logfile,0);
63 $answer = "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
64 FOO=foo BAR= BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n";
66 &compare_output($answer,&get_logfile(1));
68 delete $ENV{FOO};
70 # TEST 2: global export.  Explicit unexport takes precedence.
72 &run_make_with_options($makefile,"EXPORT_ALL=1",&get_logfile,0);
74 $answer = "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
75 FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n";
77 &compare_output($answer,&get_logfile(1));
79 # TEST 3: global unexport.  Explicit export takes precedence.
81 &run_make_with_options($makefile,"UNEXPORT_ALL=1",&get_logfile,0);
83 $answer = "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
84 FOO= BAR= BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n";
86 &compare_output($answer,&get_logfile(1));
88 # TEST 4: both: in the above makefile the unexport comes last so that rules.
90 &run_make_with_options($makefile,"EXPORT_ALL=1 UNEXPORT_ALL=1",&get_logfile,0);
92 $answer = "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
93 FOO= BAR= BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n";
95 &compare_output($answer,&get_logfile(1));
97 # TEST 5: test the pseudo target.
99 &run_make_with_options($makefile,"EXPORT_ALL_PSEUDO=1",&get_logfile,0);
101 $answer = "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
102 FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n";
104 &compare_output($answer,&get_logfile(1));
107 # TEST 6: Test the expansion of variables inside export
109 $makefile2 = &get_tmpfile;
111 open(MAKEFILE, "> $makefile2");
113 print MAKEFILE <<'EOF';
115 foo = f-ok
116 bar = b-ok
118 FOO = foo
119 F = f
121 BAR = bar
122 B = b
124 export $(FOO)
125 export $(B)ar
127 all:
128         @echo foo=$(foo) bar=$(bar)
129         @echo foo=$$foo bar=$$bar
133 close(MAKEFILE);
135 &run_make_with_options($makefile2,"",&get_logfile,0);
136 $answer = "foo=f-ok bar=b-ok\nfoo=f-ok bar=b-ok\n";
137 &compare_output($answer,&get_logfile(1));
140 # TEST 7: Test the expansion of variables inside unexport
142 $makefile3 = &get_tmpfile;
144 open(MAKEFILE, "> $makefile3");
146 print MAKEFILE <<'EOF';
148 foo = f-ok
149 bar = b-ok
151 FOO = foo
152 F = f
154 BAR = bar
155 B = b
157 export foo bar
159 unexport $(FOO)
160 unexport $(B)ar
162 all:
163         @echo foo=$(foo) bar=$(bar)
164         @echo foo=$$foo bar=$$bar
168 close(MAKEFILE);
170 &run_make_with_options($makefile3,"",&get_logfile,0);
171 $answer = "foo=f-ok bar=b-ok\nfoo= bar=\n";
172 &compare_output($answer,&get_logfile(1));
175 # TEST 7: Test exporting multiple variables on the same line
177 $makefile4 = &get_tmpfile;
179 open(MAKEFILE, "> $makefile4");
181 print MAKEFILE <<'EOF';
183 A = a
184 B = b
185 C = c
186 D = d
187 E = e
188 F = f
189 G = g
190 H = h
191 I = i
192 J = j
194 SOME = A B C
196 export F G H I J
198 export D E $(SOME)
200 all: ; @echo A=$$A B=$$B C=$$C D=$$D E=$$E F=$$F G=$$G H=$$H I=$$I J=$$J
203 close(MAKEFILE);
205 &run_make_with_options($makefile4,"",&get_logfile,0);
206 $answer = "A=a B=b C=c D=d E=e F=f G=g H=h I=i J=j\n";
207 &compare_output($answer,&get_logfile(1));
210 # TEST 8: Test unexporting multiple variables on the same line
212 $makefile5 = &get_tmpfile;
214 open(MAKEFILE, "> $makefile5");
216 print MAKEFILE <<'EOF';
218 A = a
219 B = b
220 C = c
221 D = d
222 E = e
223 F = f
224 G = g
225 H = h
226 I = i
227 J = j
229 SOME = A B C
231 unexport F G H I J
233 unexport D E $(SOME)
235 all: ; @echo A=$$A B=$$B C=$$C D=$$D E=$$E F=$$F G=$$G H=$$H I=$$I J=$$J
238 close(MAKEFILE);
240 @ENV{qw(A B C D E F G H I J)} = qw(1 2 3 4 5 6 7 8 9 10);
242 &run_make_with_options($makefile5,"",&get_logfile,0);
243 $answer = "A= B= C= D= E= F= G= H= I= J=\n";
244 &compare_output($answer,&get_logfile(1));
246 delete @ENV{qw(A B C D E F G H I J)};
249 # This tells the test driver that the perl test script executed properly.