summaryrefslogtreecommitdiffstats
path: root/config/makefiles/test/check-autotargets.mk
blob: c103f1d02dbec0a0e65606498cfc42c9ce26b17f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# -*- 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/.

ifdef VERBOSE
  $(warning loading test)
endif

space=$(null) $(null)
GENERATED_DIRS = bogus # test data

undefine USE_AUTOTARGETS_MK
undefine INCLUDED_AUTOTARGETS_MK
include $(topsrcdir)/config/makefiles/autotargets.mk

ifndef INCLUDED_AUTOTARGETS_MK
  $(error autotargets.mk was not included
endif

$(call requiredfunction,mkdir_deps)


# Verify test data populated makefile vars correctly
vars = AUTO_DEPS GARBAGE_DIRS GENERATED_DIRS_DEPS
$(foreach var,$(vars),$(call errorIfEmpty,$(var)))

# Data should also be valid
ifneq (bogus,$(findstring bogus,$(AUTO_DEPS)))
  $(error AUTO_DEPS=[$(AUTO_DEPS)] is not set correctly)
endif


# relpath
path  := foo/bar.c
exp   := foo/.mkdir.done
found := $(call mkdir_deps,$(dir $(path)))
ifneq ($(exp),$(found))
  $(error mkdir_deps($(path))=$(exp) not set correctly [$(found)])
endif

# abspath
path  := /foo//bar/
exp   := /foo/bar/.mkdir.done
found := $(call mkdir_deps,$(path))
ifneq ($(exp),$(found))
  $(error mkdir_deps($(path))=$(exp) not set correctly [$(found)])
endif


## verify strip_slash
#####################

path  := a/b//c///d////e/////
exp   := a/b/c/d/e/.mkdir.done
found := $(call mkdir_deps,$(path))
ifneq ($(exp),$(found))
  $(error mkdir_deps($(path))=$(exp) not set correctly [$(found)])
endif


## verify mkdir_stem()
######################
path  := verify/mkdir_stem
pathD = $(call mkdir_deps,$(path))
pathS = $(call mkdir_stem,$(pathD))
exp   := $(path)

ifeq ($(pathD),$(pathS))
  $(error mkdir_deps and mkdir_stem should not match [$(pathD)])
endif
ifneq ($(pathS),$(exp))
  $(error mkdir_stem=[$(pathS)] != exp=[$(exp)])
endif


## Verify embedded whitespace has been protected
path  := a/b$(space)c//d
exp   := a/b$(space)c/d
found := $(call slash_strip,$(path))
ifneq ($(exp),$(found))
  $(error slash_strip($(path))=$(exp) not set correctly [$(found)])
endif