1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/config/makefiles/test/check_XinY.mk Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,70 @@ 1.4 +# -*- makefile -*- 1.5 +# 1.6 +# This Source Code Form is subject to the terms of the Mozilla Public 1.7 +# License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.8 +# You can obtain one at http://mozilla.org/MPL/2.0/. 1.9 + 1.10 +# Verify dependencies are available 1.11 +$(call requiredfunction,getargv subargv is_XinY errorifneq) 1.12 + 1.13 +ifdef VERBOSE 1.14 + $(warning loading test) 1.15 +endif 1.16 + 1.17 +zero := 0 1.18 +one := 1 1.19 + 1.20 +# Verify 'invalid' is not matched 1.21 +val := invalid 1.22 +$(call errorifneq,$(zero),$(words $(call is_XinY,foo,$(val)))) 1.23 +$(call errorifneq,$(zero),$(words $(call is_XinY,clean,$(val)))) 1.24 +$(call errorifneq,$(zero),$(words $(call is_XinY,clean%,$(val)))) 1.25 + 1.26 +# verify strcmp('clean') 1.27 +val := clean 1.28 +$(call errorifneq,$(zero),$(words $(call is_XinY,foo,$(val)))) 1.29 +$(call errorifneq,$(one),$(words $(call is_XinY,clean,$(val)))) 1.30 +$(call errorifneq,$(one),$(words $(call is_XinY,clean%,$(val)))) 1.31 +$(call errorifneq,$(one),$(words $(call is_XinY,%clean,$(val)))) 1.32 + 1.33 +# List match for 'clean' 1.34 +val := blah clean distclean FcleanG clean-level-1 1.35 +wanted := clean distclean clean-level-1 1.36 +$(call errorifneq,$(zero),$(words $(call is_XinY_debug,foo,$(val)))) 1.37 +$(call errorifneq,$(one),$(words $(call is_XinY,clean,$(val)))) 1.38 +$(call errorifneq,$(one),$(words $(call is_XinY,distclean,$(val)))) 1.39 + 1.40 +# pattern match 'clean' 1.41 +# match: clean, distclean, clean-level-1 1.42 +# exclude: FcleanG 1.43 +TEST_MAKECMDGOALS := $(val) 1.44 +$(call errorifneq,3,$(words $(call isTargetStemClean))) 1.45 + 1.46 +TEST_MAKECMDGOALS := invalid 1.47 +$(call errorifneq,$(zero),$(words $(call isTargetStemClean))) 1.48 + 1.49 + 1.50 +############################# 1.51 +ifdef VERBOSE 1.52 + $(call banner,Unit test: isTargetStem) 1.53 +endif 1.54 + 1.55 +# Verify list argument processing 1.56 +TEST_MAKECMDGOALS := echo 1.57 +$(call errorifneq,$(one),$(words $(call isTargetStem,echo,show))) 1.58 + 1.59 +TEST_MAKECMDGOALS := echo-123 1.60 +$(call errorifneq,$(one),$(words $(call isTargetStem,echo,show))) 1.61 + 1.62 +TEST_MAKECMDGOALS := show 1.63 +$(call errorifneq,$(one),$(words $(call isTargetStem,echo,show))) 1.64 + 1.65 +TEST_MAKECMDGOALS := show-123 1.66 +$(call errorifneq,$(one),$(words $(call isTargetStem,echo,show))) 1.67 + 1.68 +TEST_MAKECMDGOALS := show-123-echo 1.69 +$(call errorifneq,$(one),$(words $(call isTargetStem,echo,show))) 1.70 + 1.71 +TEST_MAKECMDGOALS := invalid 1.72 +$(call errorifneq,$(zero),$(words $(call isTargetStem,echo,show))) 1.73 +