config/makefiles/test/check_XinY.mk
author Joey Armstrong <joey@mozilla.com>
Fri, 04 May 2012 22:46:35 -0400
changeset 93225 2c8ae0c81d321594a7b91bc8ed0def4f2fe607d4
parent 92667 4f0b589036e4a6bdd79f1165a128031c151845ea
child 93242 e8d147cc71b0f1b7851b6490f41f2f312db91398
permissions -rw-r--r--
Bug 742391 - Split config/rules.mk - file batch #1. r=ted

# -*- makefile -*-
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.

# Verify dependencies are available
$(call requiredfunction,getargv subargv is_XinY errorifneq)

#############################
ifdef VERBOSE
  $(warning )
  $(call banner,Unit test: is_XinY)
endif

zero := 0
one  := 1

# Verify 'invalid' is not matched
val  := invalid
$(call errorifneq,$(zero),$(words $(call is_XinY,foo,$(val))))
$(call errorifneq,$(zero),$(words $(call is_XinY,clean,$(val))))
$(call errorifneq,$(zero),$(words $(call is_XinY,clean%,$(val))))

# verify strcmp('clean')
val  := clean
$(call errorifneq,$(zero),$(words $(call is_XinY,foo,$(val))))
$(call errorifneq,$(one),$(words $(call is_XinY,clean,$(val))))
$(call errorifneq,$(one,$(words $(call is_XinY,clean%,$(val)))))
$(call errorifneq,$(one),$(words $(call is_XinY,%clean,$(val))))

# List match for 'clean'
val     := blah clean distclean FcleanG clean-level-1
wanted  := clean distclean clean-level-1
$(call errorifneq,$(zero),$(words $(call is_XinY_debug,foo,$(val))))
$(call errorifneq,$(one),$(words $(call is_XinY,clean,$(val))))
$(call errorifneq,$(one),$(words $(call is_XinY,distclean,$(val))))

# pattern match 'clean'
#     match: clean, distclean, clean-level-1
#   exclude: FcleanG
TEST_MAKECMDGOALS := $(val)
$(call errorifneq,3,$(words $(call isTargetStemClean)))

TEST_MAKECMDGOALS := invalid
$(call errorifneq,$(zero),$(words $(call isTargetStemClean)))


#############################
ifdef VERBOSE
  $(call banner,Unit test: isTargetStem)
endif

# Verify list argument processing
TEST_MAKECMDGOALS := echo
$(call errorifneq,$(one),$(words $(call isTargetStem,echo,show)))

TEST_MAKECMDGOALS := echo-123
$(call errorifneq,$(one),$(words $(call isTargetStem,echo,show)))

TEST_MAKECMDGOALS := show
$(call errorifneq,$(one),$(words $(call isTargetStem,echo,show)))

TEST_MAKECMDGOALS := show-123
$(call errorifneq,$(one),$(words $(call isTargetStem,echo,show)))

TEST_MAKECMDGOALS := show-123-echo
$(call errorifneq,$(one),$(words $(call isTargetStem,echo,show)))

TEST_MAKECMDGOALS := invalid
$(call errorifneq,$(zero),$(words $(call isTargetStem,echo,show)))