| 1 |
# -*-perl-*- |
| 2 |
|
| 3 |
$description = 'Test the $(shell ...) function.'; |
| 4 |
|
| 5 |
$details = ''; |
| 6 |
|
| 7 |
# Test standard shell |
| 8 |
run_make_test('.PHONY: all |
| 9 |
OUT := $(shell echo hi) |
| 10 |
all: ; @echo $(OUT) |
| 11 |
','','hi'); |
| 12 |
|
| 13 |
# Test shells inside rules. |
| 14 |
run_make_test('.PHONY: all |
| 15 |
all: ; @echo $(shell echo hi) |
| 16 |
','','hi'); |
| 17 |
|
| 18 |
# Verify .SHELLSTATUS |
| 19 |
run_make_test('.PHONY: all |
| 20 |
PRE := $(.SHELLSTATUS) |
| 21 |
$(shell exit 0) |
| 22 |
OK := $(.SHELLSTATUS) |
| 23 |
$(shell exit 1) |
| 24 |
BAD := $(.SHELLSTATUS) |
| 25 |
$(shell kill -2 $$$$) |
| 26 |
SIG := $(.SHELLSTATUS) |
| 27 |
all: ; @echo PRE=$(PRE) OK=$(OK) BAD=$(BAD) |
| 28 |
','','PRE= OK=0 BAD=1'); |
| 29 |
|
| 30 |
run_make_test('.PHONY: all |
| 31 |
$(shell kill -2 $$$$) |
| 32 |
SIG := $(.SHELLSTATUS) |
| 33 |
all: ; @echo SIG=$(SIG) |
| 34 |
','','SIG=130'); |
| 35 |
|
| 36 |
# Test unescaped comment characters in shells. Savannah bug #20513 |
| 37 |
run_make_test(q! |
| 38 |
FOO := $(shell echo '#') |
| 39 |
foo: ; echo '$(FOO)' |
| 40 |
!, |
| 41 |
'', "echo '#'\n#\n"); |
| 42 |
|
| 43 |
# Test shells inside exported environment variables. |
| 44 |
# This is the test that fails if we try to put make exported variables into |
| 45 |
# the environment for a $(shell ...) call. |
| 46 |
run_make_test(' |
| 47 |
export HI = $(shell echo hi) |
| 48 |
.PHONY: all |
| 49 |
all: ; @echo $$HI |
| 50 |
','','hi'); |
| 51 |
|
| 52 |
# Test shell errors in recipes including offset |
| 53 |
# This needs to be ported to Windows, or else Windows error messages |
| 54 |
# need to converted to look like more normal make errors. |
| 55 |
if ($port_type ne 'W32') { |
| 56 |
run_make_test(' |
| 57 |
all: |
| 58 |
@echo hi |
| 59 |
$(shell ./basdfdfsed there) |
| 60 |
@echo there |
| 61 |
', |
| 62 |
'', "#MAKE#: ./basdfdfsed: No such file or directory\nhi\nthere\n"); |
| 63 |
} |
| 64 |
|
| 65 |
1; |
| 66 |
|
| 67 |
### Local Variables: |
| 68 |
### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action)) |
| 69 |
### End: |