config/makefiles/test/check-autotargets.mk

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/config/makefiles/test/check-autotargets.mk	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,84 @@
     1.4 +# -*- makefile -*-
     1.5 +#
     1.6 +# This Source Code Form is subject to the terms of the Mozilla Public
     1.7 +# License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.8 +# You can obtain one at http://mozilla.org/MPL/2.0/.
     1.9 +
    1.10 +ifdef VERBOSE
    1.11 +  $(warning loading test)
    1.12 +endif
    1.13 +
    1.14 +space=$(null) $(null)
    1.15 +GENERATED_DIRS = bogus # test data
    1.16 +
    1.17 +undefine USE_AUTOTARGETS_MK
    1.18 +undefine INCLUDED_AUTOTARGETS_MK
    1.19 +include $(topsrcdir)/config/makefiles/autotargets.mk
    1.20 +
    1.21 +ifndef INCLUDED_AUTOTARGETS_MK
    1.22 +  $(error autotargets.mk was not included
    1.23 +endif
    1.24 +
    1.25 +$(call requiredfunction,mkdir_deps)
    1.26 +
    1.27 +
    1.28 +# Verify test data populated makefile vars correctly
    1.29 +vars = AUTO_DEPS GARBAGE_DIRS GENERATED_DIRS_DEPS
    1.30 +$(foreach var,$(vars),$(call errorIfEmpty,$(var)))
    1.31 +
    1.32 +# Data should also be valid
    1.33 +ifneq (bogus,$(findstring bogus,$(AUTO_DEPS)))
    1.34 +  $(error AUTO_DEPS=[$(AUTO_DEPS)] is not set correctly)
    1.35 +endif
    1.36 +
    1.37 +
    1.38 +# relpath
    1.39 +path  := foo/bar.c
    1.40 +exp   := foo/.mkdir.done
    1.41 +found := $(call mkdir_deps,$(dir $(path)))
    1.42 +ifneq ($(exp),$(found))
    1.43 +  $(error mkdir_deps($(path))=$(exp) not set correctly [$(found)])
    1.44 +endif
    1.45 +
    1.46 +# abspath
    1.47 +path  := /foo//bar/
    1.48 +exp   := /foo/bar/.mkdir.done
    1.49 +found := $(call mkdir_deps,$(path))
    1.50 +ifneq ($(exp),$(found))
    1.51 +  $(error mkdir_deps($(path))=$(exp) not set correctly [$(found)])
    1.52 +endif
    1.53 +
    1.54 +
    1.55 +## verify strip_slash
    1.56 +#####################
    1.57 +
    1.58 +path  := a/b//c///d////e/////
    1.59 +exp   := a/b/c/d/e/.mkdir.done
    1.60 +found := $(call mkdir_deps,$(path))
    1.61 +ifneq ($(exp),$(found))
    1.62 +  $(error mkdir_deps($(path))=$(exp) not set correctly [$(found)])
    1.63 +endif
    1.64 +
    1.65 +
    1.66 +## verify mkdir_stem()
    1.67 +######################
    1.68 +path  := verify/mkdir_stem
    1.69 +pathD = $(call mkdir_deps,$(path))
    1.70 +pathS = $(call mkdir_stem,$(pathD))
    1.71 +exp   := $(path)
    1.72 +
    1.73 +ifeq ($(pathD),$(pathS))
    1.74 +  $(error mkdir_deps and mkdir_stem should not match [$(pathD)])
    1.75 +endif
    1.76 +ifneq ($(pathS),$(exp))
    1.77 +  $(error mkdir_stem=[$(pathS)] != exp=[$(exp)])
    1.78 +endif
    1.79 +
    1.80 +
    1.81 +## Verify embedded whitespace has been protected
    1.82 +path  := a/b$(space)c//d
    1.83 +exp   := a/b$(space)c/d
    1.84 +found := $(call slash_strip,$(path))
    1.85 +ifneq ($(exp),$(found))
    1.86 +  $(error slash_strip($(path))=$(exp) not set correctly [$(found)])
    1.87 +endif

mercurial