VirtualBox

source: kBuild/trunk/src/kmk/tests/scripts/misc/bs-nl

Last change on this file was 3140, checked in by bird, 7 years ago

kmk: Merged in changes from GNU make 4.2.1 (2e55f5e4abdc0e38c1d64be703b446695e70b3b6 / https://git.savannah.gnu.org/git/make.git).

  • Property svn:eol-style set to native
File size: 4.0 KB
Line 
1# -*-perl-*-
2$description = "Test backslash-newline handling.";
3
4$details = "";
5
6# TEST #1
7# -------
8
9# Backslash-newlines in recipes
10
11# These are basic backslash-newlines with no tricks
12run_make_test("fast:;\@echo fa\\\nst\n",
13 '', 'fast');
14
15run_make_test("slow:;\@: no-op; echo sl\\\now\n",
16 '', 'slow');
17
18run_make_test("dquote:;\@echo \"dqu\\\note\"\n",
19 '', 'dquote');
20
21run_make_test("squote:;\@echo 'squ\\\note'\n",
22 '', "squ\\\note");
23
24# Ensure that a leading prefix character is omitted
25run_make_test("fast:;\@echo fa\\\n\tst\n",
26 '', 'fast');
27
28run_make_test("slow:;\@: no-op; echo sl\\\n\tow\n",
29 '', 'slow');
30
31run_make_test("dquote:;\@echo \"dqu\\\n\tote\"\n",
32 '', 'dquote');
33
34run_make_test("squote:;\@echo 'squ\\\n\tote'\n",
35 '', "squ\\\note");
36
37# Ensure that ONLY the leading prefix character is omitted
38run_make_test("fast:;\@echo fa\\\n\t st\n",
39 '', 'fa st');
40
41run_make_test("slow:;\@: no-op; echo sl\\\n\t\tow\n",
42 '', "sl ow");
43
44run_make_test("dquote:;\@echo \"dqu\\\n\t ote\"\n",
45 '', 'dqu ote');
46
47run_make_test("squote:;\@echo 'squ\\\n\t\t ote'\n",
48 '', "squ\\\n\t ote");
49
50# Backslash-newlines in variable values
51
52# Simple
53run_make_test(q!
54var = he\
55llo
56var:;@echo '|$(var)|'!,
57 '', "|he llo|");
58
59# Condense trailing space
60run_make_test(q!
61var = he \
62llo
63var:;@echo '|$(var)|'!,
64 '', "|he llo|");
65
66# Remove leading space
67run_make_test(q!
68var = he\
69 llo
70var:;@echo '|$(var)|'!,
71 '', "|he llo|");
72
73# Multiple bs/nl condensed
74run_make_test(q!
75var = he\
76\
77\
78 llo
79var:;@echo '|$(var)|'!,
80 '', "|he llo|");
81
82# POSIX: Preserve trailing space
83run_make_test(q!
84.POSIX:
85x = y
86var = he \
87llo
88var:;@echo '|$(var)|'!,
89 '', "|he llo|");
90
91# POSIX: One space per bs-nl
92run_make_test(q!
93.POSIX:
94x = y
95var = he\
96\
97\
98 llo
99var:;@echo '|$(var)|'!,
100 '', "|he llo|");
101
102# Savannah #39035: handle whitespace in call
103run_make_test(q!
104f = echo $(1)
105t:; @$(call f,"a \
106 b"); \
107 $(call f,"a \
108 b")
109!,
110 '', "a b\na b\n");
111
112# Savannah #38945: handle backslash CRLF
113# We need our own makefile so we can set binmode
114my $m1 = get_tmpfile();
115open(MAKEFILE, "> $m1");
116binmode(MAKEFILE);
117print MAKEFILE "FOO = foo \\\r\n";
118close(MAKEFILE);
119
120my $m2 = get_tmpfile();
121open(MAKEFILE, "> $m2");
122print MAKEFILE "include $m1\ndefine BAR\nall: ; \@echo \$(FOO) bar\nendef\n\$(eval \$(BAR))\n";
123close(MAKEFILE);
124
125run_make_with_options($m2, '', get_logfile());
126compare_output("foo bar\n", get_logfile(1));
127
128# Test different types of whitespace, and bsnl inside functions
129
130sub xlate
131{
132 $_ = $_[0];
133 s/\\r/\r/g;
134 s/\\t/\t/g;
135 s/\\f/\f/g;
136 s/\\v/\v/g;
137 s/\\n/\n/g;
138 return $_;
139}
140
141run_make_test(xlate(q!
142$(foreach\r a \t , b\t c \r ,$(info $a \r ) )
143all:;@:
144!),
145 '', "b \r \nc \r \n");
146
147run_make_test(xlate(q!
148all:;@:$(foreach\r a \t , b\t c \r ,$(info $a \r ) )
149!),
150 '', "b \r \nc \r \n");
151
152run_make_test(xlate(q!
153$(foreach \
154\r a \t\
155 , b\t \
156 c \r ,$(info \
157 $a \r ) \
158 )
159all:;@:
160!),
161 '', "b \r \nc \r \n");
162
163run_make_test(xlate(q!
164all:;@:$(foreach \
165\r a \t\
166 , b\t \
167 c \r ,$(info \
168 $a \r ) \
169 )
170!),
171 '', "b \r \nc \r \n");
172
173run_make_test(xlate(q!
174define FOO
175$(foreach
176\r a \t
177 , b\t
178 c \r ,$(info
179 $a \r )
180 )
181endef
182$(FOO)
183all:;@:
184!),
185 '', "b \r \nc \r \n");
186
187run_make_test(xlate(q!
188define FOO
189$(foreach
190\r a \t
191 , b\t
192 c \r ,$(info
193 $a \r )
194 )
195endef
196all:;@:$(FOO)
197!),
198 '', "b \r \nc \r \n");
199
200# Test variables in recipes that expand to multiple lines
201
202run_make_test(q!
203define var
204
205echo foo
206
207
208echo bar
209endef
210all:;$(var)
211!,
212 '', "echo foo\nfoo\necho bar\nbar\n");
213
214run_make_test(q!
215define var
216
217echo foo
218
219@
220
221echo bar
222endef
223all:;$(var)
224!,
225 '', "echo foo\nfoo\necho bar\nbar\n");
226
2271;
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette