~ubuntu-branches/debian/sid/make-doc-non-dfsg/sid

« back to all changes in this revision

Viewing changes to tests/scripts/features/shell_assignment

  • Committer: Package Import Robot
  • Author(s): Manoj Srivastava
  • Date: 2014-05-04 18:48:47 UTC
  • mfrom: (4.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20140504184847-50zxi1b08m22ehle
Tags: 4.0-2
Move to usntable, since the make binary package has been uploaded
there. No changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#                                                                    -*-perl-*-
 
2
 
 
3
$description = "Test BSD-style shell assignments (VAR != VAL) for variables.";
 
4
 
 
5
$details = "";
 
6
 
 
7
# TEST 0: Basic shell assignment (!=).
 
8
 
 
9
run_make_test('
 
10
.POSIX:
 
11
 
 
12
demo1!=printf \'  1   2 3\n4\n\n5 \n \n 6\n\n\n\n\'
 
13
demo2 != printf \'7 8\n \'
 
14
demo3 != printf \'$$(demo2)\'
 
15
demo4 != printf \' 2 3 \n\'
 
16
demo5 != printf \' 2 3 \n\n\'
 
17
all: ; @echo "<$(demo1)> <$(demo2)> <$(demo3)> <$(demo4)> <${demo5}>"
 
18
',
 
19
              '', "<  1   2 3 4  5     6   > <7 8  > <7 8  > < 2 3 > < 2 3  >\n");
 
20
 
 
21
# TEST 1: Handle '#' the same way as BSD make
 
22
 
 
23
run_make_test('
 
24
foo1!=echo bar#baz
 
25
hash != printf \'\043\'
 
26
foo2!= echo "bar$(hash)baz"
 
27
 
 
28
all: ; @echo "<$(foo1)> <$(hash)> <$(foo2)>"
 
29
',
 
30
              '', "<bar> <#> <bar#baz>\n");
 
31
 
 
32
# TEST 2: shell assignment variables (from !=) should be recursive.
 
33
# Note that variables are re-evaluated later, so the shell can output
 
34
# a value like $(XYZZY) as part of !=.  The $(XYZZY) will be EVALUATED
 
35
# when the value containing it is evaluated.  On the negative side, this
 
36
# means if you don't want this, you need to escape dollar signs as $$.
 
37
# On the positive side, it means that shell programs can output macros
 
38
# that are then evaluated as they are traditionally evaluated.. and that
 
39
# you can use traditional macro evaluation semantics to implement !=.
 
40
 
 
41
run_make_test('
 
42
XYZZY = fiddle-dee-dee
 
43
dollar = $$
 
44
VAR3 != printf \'%s\' \'$(dollar)(XYZZY)\'
 
45
 
 
46
all: ; @echo "<$(VAR3)>"
 
47
',
 
48
              '', "<fiddle-dee-dee>\n");
 
49
 
 
50
 
 
51
# TEST 3: Overrides invoke shell anyway; they just don't store the result
 
52
# in a way that is visible.
 
53
 
 
54
run_make_test('
 
55
 
 
56
override != echo abc > ,abc ; cat ,abc
 
57
 
 
58
all: ; @echo "<$(override)>" ; cat ,abc
 
59
',
 
60
              'override=xyz', "<xyz>\nabc\n");
 
61
 
 
62
unlink(',abc');
 
63
 
 
64
 
 
65
1;