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.

     1 # -*- makefile -*-
     2 #
     3 # This Source Code Form is subject to the terms of the Mozilla Public
     4 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
     5 # You can obtain one at http://mozilla.org/MPL/2.0/.
     7 ifdef VERBOSE
     8   $(warning loading test)
     9 endif
    12 $(call requiredfunction,getargv)
    13 $(call requiredfunction,subargv)
    14 $(call requiredfunction,istype isval isvar)
    16 # arg_scalar = [scalar|literal]
    17 arg_list = foo bar
    18 arg_ref  = arg_list
    20 ## Identify type of function argument(s)
    21 ########################################
    22 ifneq (scalar,$(call istype,arg_scalar))
    23   $(error istype(arg_scalar)=scalar, found [$(call istype,arg_scalar)])
    24 endif
    25 ifneq (list,$(call istype,arg_list))
    26   $(error istype(arg_list)=list, found [$(call istype,arg_list)])
    27 endif
    28 ifneq (list,$(call istype,arg_ref))
    29   $(error istype(arg_ref)=list, found [$(call istype,arg_ref)])
    30 endif
    32 ## Type == scalar or a list of values
    33 #####################################
    34 ifneq (true,$(call isval,scalar))
    35   $(error isval(scalar)=true, found [$(call isval,scalar)])
    36 endif
    37 ifneq ($(NULL),$(call isval,arg_list))
    38   $(error isval(arg_list)=null, found [$(call isval,arg_list)])
    39 endif
    41 ## type == reference: macro=>macro => $($(1))
    42 #############################################
    43 ifneq ($(NULL),$(call isvar,scalar))
    44   $(error isvar(scalar)=$(NULL), found [$(call isvar,scalar)])
    45 endif
    46 ifneq (true,$(call isvar,arg_list))
    47   $(error isvar(arg_list)=true, found [$(call isvar,arg_list)])
    48 endif
    49 ifneq (true,$(call isvar,arg_ref))
    50   $(error isvar(arg_ref)=true, found [$(call isvar,arg_ref)])
    51 endif
    53 # Verify getargv expansion
    54 ##########################
    55 ifneq (scalar,$(call getargv,scalar))
    56   $(error getargv(scalar)=scalar, found [$(call getargv,scalar)])
    57 endif
    58 ifneq ($(arg_list),$(call getargv,arg_list))
    59   $(error getargv(arg_list)=list, found [$(call getargv,arg_list)])
    60 endif
    61 ifneq (arg_list,$(call getargv,arg_ref))
    62   $(error getargv(arg_ref)=list, found [$(call getargv,arg_ref)])
    63 endif
    65 ###########################################################################
    66 ##
    67 ###########################################################################
    68 ifdef MANUAL_TEST #{
    69   # For automated testing a callback is needed that can set an external status
    70   # variable that can be tested.  Syntax is tricky to get correct functionality.
    71   ifdef VERBOSE
    72     $(info )
    73     $(info ===========================================================================)
    74     $(info Running test: checkIfEmpty)
    75     $(info ===========================================================================)
    76   endif
    78   #status =
    79   #setTRUE =status=true
    80   #setFALSE =status=$(NULL)
    81   #$(call checkIfEmpty,setFALSE NULL)
    82   #$(if $(status),$(error checkIfEmpty(xyz) failed))
    83   #$(call checkIfEmpty,setTRUE xyz)
    84   #$(if $(status),$(error checkIfEmpty(xyz) failed))
    85   xyz=abc
    86   $(info STATUS: warnIfEmpty - two vars)
    87   $(call warnIfEmpty,foo xyz bar)
    88   $(info STATUS: errorIfEmpty - on first var)
    89   $(call errorIfEmpty,foo xyz bar)
    90   $(error TEST FAILED: processing should not reach this point)
    91 endif #}
    93 # Verify subargv expansion
    94 ##########################
    95 subargs=foo bar tans fans
    96 subargs_exp=tans fans
    97 subargs_found=$(call subargv,4,$(subargs))
    98 ifneq ($(subargs_exp),$(subargs_found))
    99   $(error subargv(4,$(subargs)): expected [$(subargs_exp)] found [$(subargs_found)])
   100 endif

mercurial