2000-02-10 03:57:15 +08:00
|
|
|
# -*-perl-*-
|
1999-09-14 10:03:19 +08:00
|
|
|
$description = "Test various types of escaping in makefiles.";
|
|
|
|
|
2000-02-10 03:57:15 +08:00
|
|
|
$details = "\
|
2012-03-04 08:24:20 +08:00
|
|
|
Make sure that escaping of ':' works in target names.
|
2002-09-24 06:16:40 +08:00
|
|
|
Make sure escaping of whitespace works in target names.
|
2012-09-10 06:37:13 +08:00
|
|
|
Make sure that escaping of '#' works.
|
|
|
|
Make sure that backslash before non-special characters are kept.";
|
1999-09-14 10:03:19 +08:00
|
|
|
|
|
|
|
|
|
|
|
# TEST 1
|
|
|
|
|
2017-04-18 03:37:57 +08:00
|
|
|
run_make_test(q!
|
|
|
|
ifdef NOESC
|
|
|
|
path = pre:
|
|
|
|
endif
|
|
|
|
ifdef ONEESC
|
|
|
|
path = pre\:
|
|
|
|
endif
|
|
|
|
ifdef TWOESC
|
|
|
|
path = pre\\\\:
|
|
|
|
endif
|
|
|
|
|
2006-03-10 10:20:45 +08:00
|
|
|
$(path)foo : ; @echo "touch ($@)"
|
|
|
|
|
|
|
|
foo\ bar: ; @echo "touch ($@)"
|
|
|
|
|
|
|
|
sharp: foo\#bar.ext
|
2017-04-18 03:37:57 +08:00
|
|
|
foo\#bar.ext: ; @echo "foo#bar.ext = ($@)"
|
|
|
|
!,
|
|
|
|
'',
|
|
|
|
'touch (foo)');
|
1999-09-14 10:03:19 +08:00
|
|
|
|
|
|
|
# TEST 2: This one should fail, since the ":" is unquoted.
|
|
|
|
|
2006-03-10 10:20:45 +08:00
|
|
|
run_make_test(undef,
|
2017-04-18 03:37:57 +08:00
|
|
|
'NOESC=1',
|
|
|
|
"#MAKEFILE#:12: *** target pattern contains no '%'. Stop.",
|
|
|
|
512);
|
1999-09-14 10:03:19 +08:00
|
|
|
|
|
|
|
# TEST 3: This one should work, since we escape the ":".
|
|
|
|
|
2006-03-10 10:20:45 +08:00
|
|
|
run_make_test(undef,
|
2017-04-18 03:37:57 +08:00
|
|
|
'ONEESC=1',
|
|
|
|
'touch (pre:foo)');
|
1999-09-14 10:03:19 +08:00
|
|
|
|
|
|
|
# TEST 4: This one should fail, since the escape char is escaped.
|
|
|
|
|
2006-03-10 10:20:45 +08:00
|
|
|
run_make_test(undef,
|
2017-04-18 03:37:57 +08:00
|
|
|
'TWOESC=1',
|
|
|
|
"#MAKEFILE#:12: *** target pattern contains no '%'. Stop.",
|
|
|
|
512);
|
1999-09-14 10:03:19 +08:00
|
|
|
|
2000-02-10 03:57:15 +08:00
|
|
|
# TEST 5: This one should work
|
|
|
|
|
2006-03-10 10:20:45 +08:00
|
|
|
run_make_test(undef,
|
2017-04-18 03:37:57 +08:00
|
|
|
['foo bar'],
|
|
|
|
'touch (foo bar)');
|
2000-02-10 03:57:15 +08:00
|
|
|
|
2002-09-24 06:16:40 +08:00
|
|
|
# TEST 6: Test escaped comments
|
|
|
|
|
2006-03-10 10:20:45 +08:00
|
|
|
run_make_test(undef,
|
2017-04-18 03:37:57 +08:00
|
|
|
'sharp',
|
|
|
|
'foo#bar.ext = (foo#bar.ext)');
|
2002-09-24 06:16:40 +08:00
|
|
|
|
2012-03-05 00:53:50 +08:00
|
|
|
# Test escaped colons in prerequisites
|
|
|
|
# Quoting of backslashes in q!! is kind of messy.
|
2013-09-22 23:28:46 +08:00
|
|
|
# Solaris sh does not properly handle backslashes even in '' so just
|
|
|
|
# check the output make prints, not what the shell interprets.
|
2012-03-05 00:53:50 +08:00
|
|
|
run_make_test(q!
|
|
|
|
foo: foo\\:bar foo\\\\\\:bar foo\\\\\\\\\\:bar
|
2013-09-22 23:28:46 +08:00
|
|
|
foo foo\\:bar foo\\\\\\:bar foo\\\\\\\\\\:bar: ; : '$@'
|
2012-03-05 00:53:50 +08:00
|
|
|
!,
|
2013-09-22 23:28:46 +08:00
|
|
|
'', ": 'foo:bar'\n: 'foo\\:bar'\n: 'foo\\\\:bar'\n: 'foo'\n");
|
2012-03-05 00:53:50 +08:00
|
|
|
|
2012-09-10 06:37:13 +08:00
|
|
|
# Test backslash before non-special chars: should be kept as-is
|
|
|
|
|
|
|
|
run_make_test(q!
|
|
|
|
all: ..\foo
|
2013-09-22 23:28:46 +08:00
|
|
|
.DEFAULT: ; : '$@'
|
2012-09-10 06:37:13 +08:00
|
|
|
!,
|
2013-09-22 23:28:46 +08:00
|
|
|
'', ": '..\\foo'\n");
|
2012-09-10 06:37:13 +08:00
|
|
|
|
2016-12-23 07:47:26 +08:00
|
|
|
# Test escaped comments in variable assignments
|
|
|
|
run_make_test(q!
|
|
|
|
self = $1
|
|
|
|
foo := $(call self,#foo#)#foo
|
|
|
|
bar := $(call self,\#bar\#)#bar
|
|
|
|
all:;@echo '$(foo) $(bar)'
|
|
|
|
!,
|
|
|
|
'',"#foo# \\#bar\\#");
|
|
|
|
|
|
|
|
# Test escaped comments in variable assignments in a variable
|
|
|
|
run_make_test(q!
|
|
|
|
C = \#
|
|
|
|
self = $1
|
|
|
|
foo := $(call self,$Cfoo$C)#foo
|
|
|
|
all:;@echo '$(foo)'
|
|
|
|
!,
|
|
|
|
'',"#foo#");
|
|
|
|
|
1999-09-14 10:03:19 +08:00
|
|
|
# This tells the test driver that the perl test script executed properly.
|
|
|
|
1;
|