summaryrefslogtreecommitdiffstats
path: root/src/kmk/tests/scripts/functions/shell
blob: 809c77fa6afdd4290a43106945397f40b7e99f4c (plain)
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
#                                                                    -*-perl-*-

$description = 'Test the $(shell ...) function.';

$details = '';

# Test standard shell
run_make_test('.PHONY: all
OUT := $(shell echo hi)
all: ; @echo $(OUT)
              ','','hi');

# Test shells inside rules.
run_make_test('.PHONY: all
all: ; @echo $(shell echo hi)
              ','','hi');

# Verify .SHELLSTATUS
run_make_test('.PHONY: all
PRE := $(.SHELLSTATUS)
$(shell exit 0)
OK := $(.SHELLSTATUS)
$(shell exit 1)
BAD := $(.SHELLSTATUS)
all: ; @echo PRE=$(PRE) OK=$(OK) BAD=$(BAD)
              ','','PRE= OK=0 BAD=1');


# Test unescaped comment characters in shells.  Savannah bug #20513
if ($all_tests) {
    run_make_test(q!
FOO := $(shell echo '#')
foo: ; echo '$(FOO)'
!,
              '', "#\n");
}

# Test shells inside exported environment variables.
# This is the test that fails if we try to put make exported variables into
# the environment for a $(shell ...) call.
run_make_test('
export HI = $(shell echo hi)
.PHONY: all
all: ; @echo $$HI
    ','','hi');

# Test shell errors in recipes including offset
run_make_test('
all:
	@echo hi
	$(shell ./basdfdfsed there)
	@echo there
',
              '', "#MAKE#: ./basdfdfsed: Command not found\nhi\nthere\n");

1;

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