build/pymake/tests/define-directive.mk

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/build/pymake/tests/define-directive.mk	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,69 @@
     1.4 +define COMMANDS
     1.5 +shellvar=hello
     1.6 +test "$$shellvar" != "hello"
     1.7 +endef
     1.8 +
     1.9 +define COMMANDS2
    1.10 +shellvar=hello; \
    1.11 +  test "$$shellvar" = "hello"
    1.12 +endef
    1.13 +
    1.14 +define VARWITHCOMMENT # comment
    1.15 +value
    1.16 +endef
    1.17 +
    1.18 +define TEST3
    1.19 +  whitespace
    1.20 +endef
    1.21 +
    1.22 +define TEST4
    1.23 +define TEST5
    1.24 +random
    1.25 +endef
    1.26 +  endef
    1.27 +
    1.28 +ifdef TEST5
    1.29 +$(error TEST5 should not be set)
    1.30 +endif
    1.31 +
    1.32 +define TEST6
    1.33 +  define TEST7
    1.34 +random
    1.35 +endef
    1.36 +endef
    1.37 +
    1.38 +ifdef TEST7
    1.39 +$(error TEST7 should not be set)
    1.40 +endif
    1.41 +
    1.42 +define TEST8
    1.43 +is this # a comment?
    1.44 +endef
    1.45 +
    1.46 +ifneq ($(TEST8),is this \# a comment?)
    1.47 +$(error TEST8 value not expected: $(TEST8))
    1.48 +endif
    1.49 +
    1.50 +# A backslash continuation "hides" the endef
    1.51 +define TEST9
    1.52 +value \
    1.53 +endef
    1.54 +endef
    1.55 +
    1.56 +# Test ridiculous spacing
    1.57 + define TEST10
    1.58 +  	define TEST11
    1.59 +      baz
    1.60 +endef
    1.61 +define TEST12
    1.62 +  foo
    1.63 +  endef
    1.64 +    	endef
    1.65 +
    1.66 +all:
    1.67 +	$(COMMANDS)
    1.68 +	$(COMMANDS2)
    1.69 +	test '$(VARWITHCOMMENT)' = 'value'
    1.70 +	test '$(COMMANDS2)' = 'shellvar=hello; test "$$shellvar" = "hello"'
    1.71 +	test "$(TEST3)" = "  whitespace"
    1.72 +	@echo TEST-PASS

mercurial