config/makefiles/test/check-arglist.mk

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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 ifdef VERBOSE
michael@0 8 $(warning loading test)
michael@0 9 endif
michael@0 10
michael@0 11
michael@0 12 $(call requiredfunction,getargv)
michael@0 13 $(call requiredfunction,subargv)
michael@0 14 $(call requiredfunction,istype isval isvar)
michael@0 15
michael@0 16 # arg_scalar = [scalar|literal]
michael@0 17 arg_list = foo bar
michael@0 18 arg_ref = arg_list
michael@0 19
michael@0 20 ## Identify type of function argument(s)
michael@0 21 ########################################
michael@0 22 ifneq (scalar,$(call istype,arg_scalar))
michael@0 23 $(error istype(arg_scalar)=scalar, found [$(call istype,arg_scalar)])
michael@0 24 endif
michael@0 25 ifneq (list,$(call istype,arg_list))
michael@0 26 $(error istype(arg_list)=list, found [$(call istype,arg_list)])
michael@0 27 endif
michael@0 28 ifneq (list,$(call istype,arg_ref))
michael@0 29 $(error istype(arg_ref)=list, found [$(call istype,arg_ref)])
michael@0 30 endif
michael@0 31
michael@0 32 ## Type == scalar or a list of values
michael@0 33 #####################################
michael@0 34 ifneq (true,$(call isval,scalar))
michael@0 35 $(error isval(scalar)=true, found [$(call isval,scalar)])
michael@0 36 endif
michael@0 37 ifneq ($(NULL),$(call isval,arg_list))
michael@0 38 $(error isval(arg_list)=null, found [$(call isval,arg_list)])
michael@0 39 endif
michael@0 40
michael@0 41 ## type == reference: macro=>macro => $($(1))
michael@0 42 #############################################
michael@0 43 ifneq ($(NULL),$(call isvar,scalar))
michael@0 44 $(error isvar(scalar)=$(NULL), found [$(call isvar,scalar)])
michael@0 45 endif
michael@0 46 ifneq (true,$(call isvar,arg_list))
michael@0 47 $(error isvar(arg_list)=true, found [$(call isvar,arg_list)])
michael@0 48 endif
michael@0 49 ifneq (true,$(call isvar,arg_ref))
michael@0 50 $(error isvar(arg_ref)=true, found [$(call isvar,arg_ref)])
michael@0 51 endif
michael@0 52
michael@0 53 # Verify getargv expansion
michael@0 54 ##########################
michael@0 55 ifneq (scalar,$(call getargv,scalar))
michael@0 56 $(error getargv(scalar)=scalar, found [$(call getargv,scalar)])
michael@0 57 endif
michael@0 58 ifneq ($(arg_list),$(call getargv,arg_list))
michael@0 59 $(error getargv(arg_list)=list, found [$(call getargv,arg_list)])
michael@0 60 endif
michael@0 61 ifneq (arg_list,$(call getargv,arg_ref))
michael@0 62 $(error getargv(arg_ref)=list, found [$(call getargv,arg_ref)])
michael@0 63 endif
michael@0 64
michael@0 65 ###########################################################################
michael@0 66 ##
michael@0 67 ###########################################################################
michael@0 68 ifdef MANUAL_TEST #{
michael@0 69 # For automated testing a callback is needed that can set an external status
michael@0 70 # variable that can be tested. Syntax is tricky to get correct functionality.
michael@0 71 ifdef VERBOSE
michael@0 72 $(info )
michael@0 73 $(info ===========================================================================)
michael@0 74 $(info Running test: checkIfEmpty)
michael@0 75 $(info ===========================================================================)
michael@0 76 endif
michael@0 77
michael@0 78 #status =
michael@0 79 #setTRUE =status=true
michael@0 80 #setFALSE =status=$(NULL)
michael@0 81 #$(call checkIfEmpty,setFALSE NULL)
michael@0 82 #$(if $(status),$(error checkIfEmpty(xyz) failed))
michael@0 83 #$(call checkIfEmpty,setTRUE xyz)
michael@0 84 #$(if $(status),$(error checkIfEmpty(xyz) failed))
michael@0 85 xyz=abc
michael@0 86 $(info STATUS: warnIfEmpty - two vars)
michael@0 87 $(call warnIfEmpty,foo xyz bar)
michael@0 88 $(info STATUS: errorIfEmpty - on first var)
michael@0 89 $(call errorIfEmpty,foo xyz bar)
michael@0 90 $(error TEST FAILED: processing should not reach this point)
michael@0 91 endif #}
michael@0 92
michael@0 93 # Verify subargv expansion
michael@0 94 ##########################
michael@0 95 subargs=foo bar tans fans
michael@0 96 subargs_exp=tans fans
michael@0 97 subargs_found=$(call subargv,4,$(subargs))
michael@0 98 ifneq ($(subargs_exp),$(subargs_found))
michael@0 99 $(error subargv(4,$(subargs)): expected [$(subargs_exp)] found [$(subargs_found)])
michael@0 100 endif

mercurial