michael@0: # -*- makefile -*- michael@0: # michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: # You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: # Verify dependencies are available michael@0: $(call requiredfunction,getargv subargv is_XinY errorifneq) michael@0: michael@0: ifdef VERBOSE michael@0: $(warning loading test) michael@0: endif michael@0: michael@0: zero := 0 michael@0: one := 1 michael@0: michael@0: # Verify 'invalid' is not matched michael@0: val := invalid michael@0: $(call errorifneq,$(zero),$(words $(call is_XinY,foo,$(val)))) michael@0: $(call errorifneq,$(zero),$(words $(call is_XinY,clean,$(val)))) michael@0: $(call errorifneq,$(zero),$(words $(call is_XinY,clean%,$(val)))) michael@0: michael@0: # verify strcmp('clean') michael@0: val := clean michael@0: $(call errorifneq,$(zero),$(words $(call is_XinY,foo,$(val)))) michael@0: $(call errorifneq,$(one),$(words $(call is_XinY,clean,$(val)))) michael@0: $(call errorifneq,$(one),$(words $(call is_XinY,clean%,$(val)))) michael@0: $(call errorifneq,$(one),$(words $(call is_XinY,%clean,$(val)))) michael@0: michael@0: # List match for 'clean' michael@0: val := blah clean distclean FcleanG clean-level-1 michael@0: wanted := clean distclean clean-level-1 michael@0: $(call errorifneq,$(zero),$(words $(call is_XinY_debug,foo,$(val)))) michael@0: $(call errorifneq,$(one),$(words $(call is_XinY,clean,$(val)))) michael@0: $(call errorifneq,$(one),$(words $(call is_XinY,distclean,$(val)))) michael@0: michael@0: # pattern match 'clean' michael@0: # match: clean, distclean, clean-level-1 michael@0: # exclude: FcleanG michael@0: TEST_MAKECMDGOALS := $(val) michael@0: $(call errorifneq,3,$(words $(call isTargetStemClean))) michael@0: michael@0: TEST_MAKECMDGOALS := invalid michael@0: $(call errorifneq,$(zero),$(words $(call isTargetStemClean))) michael@0: michael@0: michael@0: ############################# michael@0: ifdef VERBOSE michael@0: $(call banner,Unit test: isTargetStem) michael@0: endif michael@0: michael@0: # Verify list argument processing michael@0: TEST_MAKECMDGOALS := echo michael@0: $(call errorifneq,$(one),$(words $(call isTargetStem,echo,show))) michael@0: michael@0: TEST_MAKECMDGOALS := echo-123 michael@0: $(call errorifneq,$(one),$(words $(call isTargetStem,echo,show))) michael@0: michael@0: TEST_MAKECMDGOALS := show michael@0: $(call errorifneq,$(one),$(words $(call isTargetStem,echo,show))) michael@0: michael@0: TEST_MAKECMDGOALS := show-123 michael@0: $(call errorifneq,$(one),$(words $(call isTargetStem,echo,show))) michael@0: michael@0: TEST_MAKECMDGOALS := show-123-echo michael@0: $(call errorifneq,$(one),$(words $(call isTargetStem,echo,show))) michael@0: michael@0: TEST_MAKECMDGOALS := invalid michael@0: $(call errorifneq,$(zero),$(words $(call isTargetStem,echo,show))) michael@0: