File: ONESHELL

package info (click to toggle)
make-dfsg 4.4.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,948 kB
  • sloc: ansic: 31,304; sh: 5,222; perl: 1,716; makefile: 162; lisp: 26; sed: 16
file content (143 lines) | stat: -rw-r--r-- 2,926 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#                                                                    -*-perl-*-

$description = "Test the behaviour of the .ONESHELL target.";

$details = "";

my $multi_ok = 0;

if ($port_type ne 'W32') {
    # Some shells (*shakes fist at Solaris*) cannot handle multiple flags in
    # separate arguments.
    my $t = `$sh_name -e -c true 2>/dev/null`;
    $multi_ok = $? == 0;
}

# Simple

run_make_test(q!
.ONESHELL:
all:
	a=$$$$
	[ 0"$$a" -eq "$$$$" ] || echo fail
!,
              '', 'a=$$
[ 0"$a" -eq "$$" ] || echo fail
');

# Simple but use multi-word SHELLFLAGS

if ($multi_ok) {
    run_make_test(q!
.ONESHELL:
.SHELLFLAGS = -e -c
all:
	a=$$$$
	[ 0"$$a" -eq "$$$$" ] || echo fail
!,
              '', 'a=$$
[ 0"$a" -eq "$$" ] || echo fail
');
}

# Again, but this time with inner prefix chars

run_make_test(q!
.ONESHELL:
all:
	a=$$$$
	@-+    [ 0"$$a" -eq "$$$$" ] || echo fail
!,
              '', 'a=$$
[ 0"$a" -eq "$$" ] || echo fail
');

# This time with outer prefix chars

run_make_test(q!
.ONESHELL:
all:
	   @a=$$$$
	    [ 0"$$a" -eq "$$$$" ] || echo fail
!,
              '', '');


# This time with outer and inner prefix chars

run_make_test(q!
.ONESHELL:
all:
	   @a=$$$$
	    -@     +[ 0"$$a" -eq "$$$$" ] || echo fail
!,
              '', '');


# Now try using a different interpreter
# This doesn't work on Windows right now
if ($port_type ne 'W32') {
    run_make_test(q!
.RECIPEPREFIX = >
.ONESHELL:
SHELL = #PERL#
.SHELLFLAGS = -e
all:
>	   @$$a=5
>	    +7;
>	@y=qw(a b c);
>print "a = $$a, y = (@y)\n";
!,
                  '', "a = 12, y = (a b c)\n");

    # Simple .SHELLFLAGS, no quotes.
    # sv 61805.
    run_make_test(q!
.ONESHELL:
SHELL = #PERL#
.SHELLFLAGS = -e
all:; @print "it works\n"
!, '', 'it works');

    # Pass a quoted string with spaces to oneshell.
    # sv 61805.
    run_make_test(q!
.ONESHELL:
SHELL = #PERL#
.SHELLFLAGS = -w -E 'use warnings FATAL => "all";' -E
all:; @print "it works\n"
!, '', 'it works');

    # Empty .SHELLFLAGS.
    # sv 61805.
    run_make_test(q!
.ONESHELL:
SHELL = #PERL#
.SHELLFLAGS =
all:; @print "it works"
!, '', "Can't open perl script \"print \"it works\"\": $ERR_no_such_file\n#MAKE#: *** [#MAKEFILE#:5: all] Error $ERR_no_such_file_code", 512);

    # No .SHELLFLAGS.
    # sv 61805.
    run_make_test(q!
.ONESHELL:
SHELL = #PERL#
all:; @print "it works"
!, '', "Can't open perl script \"print \"it works\"\": $ERR_no_such_file\n#MAKE#: *** [#MAKEFILE#:4: all] Error $ERR_no_such_file_code", 512);

    # Pass a quoted string with spaces to oneshell.
    # sv 61805.
    run_make_test(q!
.ONESHELL:
SHELL = #PERL#
.SHELLFLAGS = -w -E 'use warnings FATAL => "all";' -E 'my $$foo = "bar";' -E
all:; @print "it works: $$foo\n"
!, '', 'it works: bar');
}

# This tells the test driver that the perl test script executed properly.
1;

### Local Variables:
### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
### End: