config/makefiles/test/check_XinY.mk

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

michael@0 1 # -*- makefile -*-
michael@0 2 #
michael@0 3 # This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 5 # You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 6
michael@0 7 # Verify dependencies are available
michael@0 8 $(call requiredfunction,getargv subargv is_XinY errorifneq)
michael@0 9
michael@0 10 ifdef VERBOSE
michael@0 11 $(warning loading test)
michael@0 12 endif
michael@0 13
michael@0 14 zero := 0
michael@0 15 one := 1
michael@0 16
michael@0 17 # Verify 'invalid' is not matched
michael@0 18 val := invalid
michael@0 19 $(call errorifneq,$(zero),$(words $(call is_XinY,foo,$(val))))
michael@0 20 $(call errorifneq,$(zero),$(words $(call is_XinY,clean,$(val))))
michael@0 21 $(call errorifneq,$(zero),$(words $(call is_XinY,clean%,$(val))))
michael@0 22
michael@0 23 # verify strcmp('clean')
michael@0 24 val := clean
michael@0 25 $(call errorifneq,$(zero),$(words $(call is_XinY,foo,$(val))))
michael@0 26 $(call errorifneq,$(one),$(words $(call is_XinY,clean,$(val))))
michael@0 27 $(call errorifneq,$(one),$(words $(call is_XinY,clean%,$(val))))
michael@0 28 $(call errorifneq,$(one),$(words $(call is_XinY,%clean,$(val))))
michael@0 29
michael@0 30 # List match for 'clean'
michael@0 31 val := blah clean distclean FcleanG clean-level-1
michael@0 32 wanted := clean distclean clean-level-1
michael@0 33 $(call errorifneq,$(zero),$(words $(call is_XinY_debug,foo,$(val))))
michael@0 34 $(call errorifneq,$(one),$(words $(call is_XinY,clean,$(val))))
michael@0 35 $(call errorifneq,$(one),$(words $(call is_XinY,distclean,$(val))))
michael@0 36
michael@0 37 # pattern match 'clean'
michael@0 38 # match: clean, distclean, clean-level-1
michael@0 39 # exclude: FcleanG
michael@0 40 TEST_MAKECMDGOALS := $(val)
michael@0 41 $(call errorifneq,3,$(words $(call isTargetStemClean)))
michael@0 42
michael@0 43 TEST_MAKECMDGOALS := invalid
michael@0 44 $(call errorifneq,$(zero),$(words $(call isTargetStemClean)))
michael@0 45
michael@0 46
michael@0 47 #############################
michael@0 48 ifdef VERBOSE
michael@0 49 $(call banner,Unit test: isTargetStem)
michael@0 50 endif
michael@0 51
michael@0 52 # Verify list argument processing
michael@0 53 TEST_MAKECMDGOALS := echo
michael@0 54 $(call errorifneq,$(one),$(words $(call isTargetStem,echo,show)))
michael@0 55
michael@0 56 TEST_MAKECMDGOALS := echo-123
michael@0 57 $(call errorifneq,$(one),$(words $(call isTargetStem,echo,show)))
michael@0 58
michael@0 59 TEST_MAKECMDGOALS := show
michael@0 60 $(call errorifneq,$(one),$(words $(call isTargetStem,echo,show)))
michael@0 61
michael@0 62 TEST_MAKECMDGOALS := show-123
michael@0 63 $(call errorifneq,$(one),$(words $(call isTargetStem,echo,show)))
michael@0 64
michael@0 65 TEST_MAKECMDGOALS := show-123-echo
michael@0 66 $(call errorifneq,$(one),$(words $(call isTargetStem,echo,show)))
michael@0 67
michael@0 68 TEST_MAKECMDGOALS := invalid
michael@0 69 $(call errorifneq,$(zero),$(words $(call isTargetStem,echo,show)))
michael@0 70

mercurial