Revision 775
Added by Aaron Marcuse-Kubitza almost 13 years ago
input.Makefile | ||
---|---|---|
17 | 17 |
DIFF = diff --unified=2 |
18 | 18 |
|
19 | 19 |
# Config |
20 |
exts ?= csv xml |
|
20 | 21 |
test_n ?= 2 |
21 | 22 |
tablesSort ?= plots organisms stems |
22 |
coreMapTry ?= organisms specimens
|
|
23 |
mainCoreMapTry ?= organisms specimens
|
|
23 | 24 |
|
24 | 25 |
root := $(selfDir_uZPPqC).. |
26 |
mappings := $(root)/mappings |
|
25 | 27 |
psqlAsBien := $(root)/bin/psql_vegbien |
26 | 28 |
|
27 | 29 |
##### |
... | ... | |
59 | 61 |
|
60 | 62 |
allViaMaps := $(filter-out maps/VegBIEN.%.csv,$(wildcard maps/*.csv)) |
61 | 63 |
via := $(firstword $(sort $(basename $(basename $(notdir $(allViaMaps)))))) |
62 |
coreMap := $(firstword $(wildcard\
|
|
63 |
$(coreMapTry:%=$(root)/mappings/$(via)-VegBIEN.%.csv)))
|
|
64 |
coreMap := $(mappings)/$(via)-VegBIEN.%.csv
|
|
65 |
mainCoreMap := $(firstword $(wildcard $(mainCoreMapTry:%=$(coreMap))))
|
|
64 | 66 |
viaMaps := $(wildcard $(tablesSort:%=maps/$(via).%.csv)) |
65 | 67 |
viaMaps += $(filter-out $(viaMaps),$(wildcard maps/$(via).*.csv)) |
66 | 68 |
autogenMaps := $(subst $(via).,VegBIEN.,$(viaMaps)) |
... | ... | |
74 | 76 |
|
75 | 77 |
all += $(autogenMaps) |
76 | 78 |
|
77 |
maps/VegBIEN.%.csv: maps/$(via).%.csv $(root)/mappings/$(via)-VegBIEN.%.csv
|
|
79 |
maps/VegBIEN.%.csv: maps/$(via).%.csv $(coreMap)
|
|
78 | 80 |
$(root)/bin/join_sort <$+ >$@ |
79 |
.PRECIOUS: maps/VegBIEN.%.csv $(root)/mappings/$(via)-VegBIEN.%.csv
|
|
81 |
.PRECIOUS: maps/VegBIEN.%.csv $(coreMap)
|
|
80 | 82 |
|
81 | 83 |
##### |
82 | 84 |
|
83 | 85 |
dbFile := $(firstword $(wildcard src/db.*.sql)) |
84 | 86 |
inputFiles := $(wildcard src/*.csv src/*.xml) |
85 | 87 |
|
86 |
+maps = $(filter maps/%,$(+_)) |
|
87 |
<in = $(firstword $(wildcard $(patsubst %,src/*.$*.%,csv xml)) \ |
|
88 |
$(filter-out $(+maps),$(+_))) |
|
89 |
map = $(if $(mapEnv),env $(mapEnv) ,)$(root)/map $(if $(<in),<$(<in)) $(+maps) |
|
88 |
+maps = $(filter maps/% $(mappings)/%,$(+_)) |
|
89 |
<in = $(firstword $(filter-out $(+maps),$(+_)) $(wildcard $(exts:%=src/*.$*.%))) |
|
90 |
map = $(if $(<in),<$(<in) ,$(if $(mapEnv),env $(mapEnv) ))$(root)/map $(+maps) |
|
90 | 91 |
map2db = env out_database=vegbien $(map) |
91 | 92 |
|
92 | 93 |
##### |
... | ... | |
150 | 151 |
testRef = $(1:.2-step.xml=.xml).ref |
151 | 152 |
|
152 | 153 |
define test |
153 |
env test=1 verbose=1 n=$(test_n) $(1) >$@
|
|
154 |
>$@ env test=1 verbose=1 n=$(test_n) $(1)
|
|
154 | 155 |
@(set -x; $(DIFF) $(call testRef,$@) $@) 2>&1 || { e=$$?;\ |
155 | 156 |
$(if $(hasOwnRef),echo $(emph)"To accept new test output:"$(endEmph);\ |
156 |
echo "$(MAKE) $@-ok --directory=$(realpath .) --makefile=../input.Makefile";)\ |
|
157 |
echo "$(MAKE) $@-ok --directory=$(realpath .) --makefile=../input.Makefile";,\ |
|
158 |
echo $(emph)"Note: This test is compared to another test's output"$(endEmph);)\ |
|
157 | 159 |
exit $$e;} |
158 | 160 |
endef |
159 | 161 |
|
162 |
test2File = $(call test,$(map)) |
|
163 |
|
|
160 | 164 |
test/$(via).xml: $(viaMaps) _always |
161 |
$(call test,$(map))
|
|
165 |
$(test2File)
|
|
162 | 166 |
tests += test/$(via).xml |
163 | 167 |
|
164 | 168 |
test/VegBIEN.xml: $(directMaps) _always |
165 |
$(call test,$(map))
|
|
169 |
$(test2File)
|
|
166 | 170 |
tests += test/VegBIEN.xml |
167 | 171 |
|
168 |
test/VegBIEN.2-step.xml: test/$(via).xml $(coreMap) _always
|
|
169 |
-$(call test,$(root)/map)
|
|
172 |
test/VegBIEN.2-step.xml: test/$(via).xml $(mainCoreMap) _always
|
|
173 |
-$(test2File)
|
|
170 | 174 |
# Don't abort tester if only 2-step test fails, as it's often finicky |
171 | 175 |
tests += test/VegBIEN.2-step.xml |
172 | 176 |
|
Also available in: Unified diff
input.Makefile: Fixed 2-step tests, which were still using $(root)/map when all bin/map calls were supposed to be routed through $(map)