Project

General

Profile

1
selfDir_uZPPqC := $(dir $(lastword $(MAKEFILE_LIST)))
2
root := $(selfDir_uZPPqC)..
3
include $(root)/lib/common.Makefile
4

    
5

    
6
##### Configuration
7

    
8
# Command line
9
full_import ?=
10
import_source ?= 1
11
log ?= $(if $(test),,1)
12
noclobber ?=
13
profile ?=
14
quiet ?=
15
reverify ?= 1
16
schema_only ?=
17
use_staged ?= $(by_col)
18

    
19
# Makefile
20
exts ?= csv tsv tab txt dat dmp xml
21
test_n ?= 2
22

    
23
##### Vars/functions
24

    
25
# Paths
26
datasrc := $(patsubst .%,%,$(notdir $(realpath .)))
27
bin := $(root)/bin
28
mappings := $(root)/mappings
29

    
30
# Make
31
SHELL := /bin/bash
32
selfMake = $(MAKE) --makefile=../input.Makefile
33
subMake = $(MAKE) $(@:$(root)/%=%) --directory=$(root)
34
+_ = $(+:_%=)
35
# used to filter the output of embedded $(shell make ...) invocations
36
filter_make := grep -vF -e lib -e ".Makefile'."
37
addBeforeExt = $(basename $(2))$(1)$(suffix $(2))
38

    
39
# Terminal
40
termCols := $(shell tput cols)
41

    
42
# Commands
43
MKDIR = mkdir -p
44
mkdir = $(MKDIR) $(@D)
45
diff = diff --unified=2
46
diffIgnoreSpace = $(diff) --ignore-space-change
47
diffVerbose = $(if $(verbose),diff --side-by-side --left-column\
48
--width=$(termCols),$(diff))
49

    
50
# BIEN commands
51
sortFilenames = $(shell $(bin)/sort_filenames $(1))
52
selfMap = $(bin)/cols 0 0
53
psqlAsBien := $(bin)/psql_verbose_vegbien
54
psqlNoSearchPath := env no_search_path=1 $(psqlAsBien)
55
# Usage: ($(inDatasrc); cat $(file))|$(psqlCmd)
56
inDatasrc := echo 'SET search_path TO "$(datasrc)";'
57

    
58
# SVN
59
setSvnIgnore = svn propset svn:ignore $(2) $(1)
60
define addDirWithIgnore
61
$(addDir)
62
$(setSvnIgnore)
63
endef
64

    
65
##### Environment
66

    
67
export PATH := $(bin):$(PATH)
68

    
69
##### General targets
70

    
71
all: _always maps ;
72

    
73
clean: _always
74
	$(RM) $(all)
75

    
76
remake: _always clean
77
	+$(selfMake)
78
# re-run make so that cache of existing files is reset
79

    
80
# Only remake if doesn't exist. This prevents unintentional remaking when the
81
# make script is newly checked out from svn (which sets the mod time to now) but
82
# the output is synced externally.
83
# Can't remove prereq to do this, because it determines when the rule applies.
84
make_script = $(if $(wildcard $@),,"time" ./$< >$@)
85

    
86
%/: %/map.csv _always ;
87

    
88
%/: % _always ;
89

    
90
%: %.make
91
	$(make_script)
92
.PRECIOUS: % # save partial outputs of aborted src make scripts
93

    
94
##### Tables discovery
95

    
96
sortFile := import_order.txt
97
noImportFile := _no_import
98

    
99
dontImport = $(wildcard $(noImportFile))$(wildcard $(1)/$(noImportFile))$(if\
100
$(import_source),,$(filter Source,$(1)))
101

    
102
ifeq ($(sort_file_updated),)# keep $(sortFile) up-to-date
103
$(shell sort_file_updated=1 $(selfMake) $(sortFile)|$(filter_make) >&2)
104
export sort_file_updated=1
105
endif
106

    
107
sort_file_tables := $(if $(wildcard $(sortFile)),$(shell cat $(sortFile)))
108
    # $(shell) replaces "\n" with " "
109
tables := $(sort_file_tables)
110
allSubdirs := $(call wildcard/,*/)
111
allTables := $(call sortFilenames,$(filter-out _% verify logs,$(allSubdirs:%/=%)))
112
joinedTables := $(filter-out $(tables),$(allTables))
113
allTables := $(strip $(joinedTables) $(tables))# move joined tables to beginning
114
has_visible_files = $(call wildcard/,$(1)/*)
115
allTables := $(foreach table,$(allTables),$(if\
116
$(call has_visible_files,$(table)),$(table)))
117
ifeq ($(tables),)# none specified in sort file
118
tables := $(allTables)
119
endif
120
importTables := $(foreach table,$(tables),$(if\
121
$(call dontImport,$(table)),,$(table)))
122

    
123
list_tables: _always # use `make -s` to avoid echoing commands
124
	@for table in $(tables); do echo "$$table"; done
125

    
126
$(sortFile): _always
127
	# add any missing tables to $(sortFile)
128
	$(if $(filter-out $(sort_file_tables),$(tables)),$(selfMake) -s list_tables >$@)
129

    
130
##### SVN
131

    
132
svnFilesGlob:= */{,$(noImportFile),{,.}{map,VegBIEN}.csv{,.*},*header.*,*.sql,test.xml.ref}
133
svnFilesGlob := {map.csv,*{schema,~}*.sql,{,*/}{*.make,*terms.csv},$(svnFilesGlob)}
134
_svnFilesGlob := {_MySQL/{,*schema*.sql,*.make},{,*/}{*{run,Makefile},*.{md5,url,pdf},*README.TXT}}
135
svnFiles = $(filter-out _% logs/% %.data.sql,$(call wildcard/,$(svnFilesGlob)))\
136
$(call wildcard/,$(_svnFilesGlob))
137

    
138
# To update all inputs with these settings: make inputs/add
139
add: _always Source/add $(allTables:%=%/add)
140
	$(call setSvnIgnore,.,'*')
141
	$(call addDirWithIgnore,logs,$$'*.gz\n*.log.sql\n*.trace')
142
	$(call addDirWithIgnore,verify,$$'*.out\n*.csv\n*.xls\n*.xlsx')
143
	$(call addFile,import_order.txt)
144
	$(if $(wildcard _MySQL/),$(call addDirWithIgnore,_MySQL,'*'))
145
	$(if $(wildcard _src/),$(call addDirWithIgnore,_src,'*'))
146
	$(if $(wildcard _archive/),$(call addDirWithIgnore,_archive,'*'))
147
	$(call add*,$(svnFiles))
148

    
149
# Adds a new table subdir
150
%/add: _always
151
	$(call addDirWithIgnore,$*,'*')
152
	$(call addDirWithIgnore,$*/logs,$$'*.gz\n*.log.sql\n*.trace')
153

    
154
##### Existing maps discovery
155

    
156
anyMap := %/map.csv %/VegBIEN.csv %/unmapped_terms.csv %/new_terms.csv
157

    
158
exts := $(call ci,$(exts))
159
extsFilter := $(addprefix %.,$(exts))
160
dataOnly = $(filter $(extsFilter),$(1))
161

    
162
anyTest = $*/test.%
163
srcsOnly = $(filter-out $(anyMap) $(anyTest) %/logs,$(call dataOnly,$(1)))
164

    
165
srcDict := map.csv
166

    
167
vocab := $(mappings)/VegCore.vocab.csv
168
thesaurus := $(mappings)/VegCore.thesaurus.csv
169
coreMap := $(mappings)/VegCore-VegBIEN.csv
170

    
171
viaMaps := $(importTables:%=%/map.csv)
172

    
173
autogenMaps := $(subst map.,VegBIEN.,$(viaMaps))
174
directMaps := $(autogenMaps) $(filter-out $(autogenMaps),\
175
$(wildcard */VegBIEN.csv))
176

    
177
##### Sources
178

    
179
srcs = $(call sortFilenames,$(call srcsOnly,$(wildcard $*/*)))
180
nonHeaderSrcs = $(filter-out %/header.csv,$(srcs))
181
isRef = $(if $(nonHeaderSrcs),,1)
182
    # empty subdir, so references an already-installed staging table
183
isXml = $(filter %.xml,$(nonHeaderSrcs))
184
nonXml = $(if $(isXml),,1)
185
isCsv = $(if $(nonHeaderSrcs),$(if $(isXml),,1))
186
    # true if $(srcs) non-empty and contains no *.xml
187
catSrcs = $(bin)/cat$(if $(nonXml),_csv) $(nonHeaderSrcs)
188
withCatSrcs = $(catSrcs:$(bin)/%=$(bin)/with_%) --
189

    
190
# Run with `make -s` to avoid echoing make commands
191
cat: $(importTables:%=%/cat) _always ;
192

    
193
%/cat: _always
194
	$(catSrcs)
195

    
196
##### Input data retrieval
197

    
198
# Must come before `%.sql: _MySQL/%.sql` to override it
199
%.sql: %.sql.make
200
	$(make_script)
201

    
202
# The export must be created with:
203
# `--compatible=postgresql --add-locks=false --set-charset --no-create-info`
204
# Must come before `%.sql: _MySQL/%.sql` to override it
205
%.data.sql: _MySQL/%.data.sql
206
	$(if $(wildcard $@),,$(bin)/my2pg.data <$< >$@)
207

    
208
# The export must be created with:
209
# `--compatible=postgresql --add-locks=false --set-charset`
210
# Add `--no-data` to create a schema-only export.
211
%.sql: _MySQL/%.sql
212
	$(if $(wildcard $@),,$(bin)/my2pg <$< >$@)
213

    
214
##### Staging tables installation
215

    
216
srcTable := %.src
217

    
218
dbExportsWildcard = $(sort $(patsubst _MySQL/%.make,%,$(wildcard\
219
$(1) _MySQL/$(1).make)))
220

    
221
dbExports := $(call dbExportsWildcard,*schema*.sql)# schemas first
222
ifeq ($(schema_only),) # add rest of .sql files
223
dbExports += $(filter-out $(dbExports),$(call dbExportsWildcard,*.sql))
224
endif
225
dbExports := $(strip $(dbExports))# += adds extra whitespace
226
allInstalls := $(if $(dbExports),sql) $(filter-out Source,$(allTables))
227

    
228
install: _always schema $(allInstalls:%=%/install) ;
229

    
230
uninstall: _always confirm_rm_schema rm_schema ;
231
# rm_schema will also drop all staging tables
232

    
233
reinstall: _always uninstall install ;
234

    
235
confirm_rm_schema: _always
236
	$(if $(filter TNRS,$(datasrc)),$(call confirm,WARNING: This will delete the\
237
TNRS cache!,To save it: make backups/TNRS.backup-remake))
238

    
239
schema: _always
240
	-echo 'CREATE SCHEMA "$(datasrc)";'|$(psqlNoSearchPath)
241
# ignore errors if schema exists
242

    
243
rm_schema: _always
244
	echo 'DROP SCHEMA IF EXISTS "$(datasrc)" CASCADE;'|$(psqlNoSearchPath)
245

    
246
installLog := logs/install.log.sql
247

    
248
log_dir = $(1)logs
249
has_log_dir = $(call and,$(wildcard $(log_dir)),$(call not,$(noclobber)))
250
logInstall = $(if $(has_log_dir),$(if $(quiet),$(2)$(1)$(installLog)\
251
2>&1,2>&1|tee $(3) $(1)$(installLog)))
252
logInstallRoot = $(call logInstall,,>)
253
logInstall* = $(call logInstall,$*/,>)
254
logInstall*Add = $(call logInstall,$*/,>>,-a)# append to log
255

    
256
# Must come before %/install to override it
257
sql/install: $(dbExports)
258
	($(inDatasrc); cat $+|pg_dump_limit)|"time" env no_search_path=1 \
259
$(bin)/psql_script_vegbien --set=schema='"$(datasrc)"' $(logInstallRoot)
260

    
261
cleanup = $(if $(wildcard $*/cleanup.sql),($(inDatasrc); cat $*/cleanup.sql)\
262
|"time" $(psqlNoSearchPath) --echo-all --set=table='"$*"' $(logInstall*Add),\
263
(export schema=$(datasrc) table=$*; . $(bin)/vegbien_dest; unset schemas; \
264
$(bin)/csv2db) $(logInstall*Add))
265

    
266
%/header.csv:
267
	echo 'COPY (SELECT * FROM "$(datasrc)"."$*" LIMIT 0) TO STDOUT CSV HEADER;'|\
268
env no_search_path=1 $(bin)/psql_script_vegbien >$*/header.csv
269

    
270
exportHeader = $(selfMake) $*/header.csv
271

    
272
# Don't try to edit a view. Must come before %/install to override it.
273
%_view/install: _always ;
274

    
275
%.sql/run: _always
276
	$(if $(wildcard $(@D)),($(inDatasrc); cat $(@D))|(cd '$(*D)';\
277
"time" env no_search_path=1 ../$(bin)/psql_verbose_vegbien \
278
--set=table='"$(*D)"' --set=table_str=\''"$(*D)"'\'))
279

    
280
%/postprocess: _always
281
	$(if $(wildcard $*/run),,$(selfMake) $*/postprocess.sql/run)
282
	$(if $(wildcard $*/import),$*/import)
283

    
284
# For staging tables which are derived by joining together other staging tables.
285
%/install %/header.csv: %/create.sql _always
286
	($(inDatasrc); echo 'CREATE TABLE "$*" AS'; cat $<; echo ';')|"time" \
287
$(psqlNoSearchPath) --echo-all --set=schema='"$(datasrc)"' --set=table='"$*"' \
288
$(logInstall*)
289
	$(selfMake) $*/postprocess
290
	$(exportHeader)
291
	$(cleanup)
292
ifneq ($(noclobber),)
293
.PRECIOUS: %/header.csv
294
endif
295

    
296
%/install: _always
297
	$(if $(isCsv),$(import_install_))
298
	$(selfMake) $*/postprocess
299
	-$(exportHeader)
300
	-$(if $(isCsv),,$(cleanup))
301
# ignore errors if table does not exist (non-data dir)
302
define import_install_
303
(. $(bin)/vegbien_dest; unset schemas; "time" nice -n +5\
304
env schema=$(datasrc) table=$* $(bin)/csv2db $(catSrcs) $(logInstall*))
305
$(if $(filter $(srcTable),$*),($(inDatasrc);\
306
echo 'ALTER TABLE "$(datasrc)"."$*" RENAME row_num TO "$*.row_num";')|"time"\
307
$(psqlNoSearchPath) --echo-all --set=table='"$*"' $(logInstall*Add))
308
endef
309
# table-scope src table's row_num col to allow joining it with other tables
310

    
311
%/uninstall: _always
312
	echo 'DROP TABLE IF EXISTS "$(datasrc)"."$*" CASCADE;'|$(psqlNoSearchPath)
313

    
314
%/reinstall: _always %/uninstall %/install ;
315

    
316
postprocess: _always $(allTables:%=%/postprocess) ;
317

    
318
cleanup: _always $(tables:%=%/cleanup) ;
319

    
320
# WARNING: This removes any index comments, due to a PostgreSQL bug.
321
# This occurs because ALTER TABLE recreates the index but not its comment.
322
%/cleanup: _always
323
	$(cleanup)
324

    
325
##### Maps building
326

    
327
# Maps to (try to) build are added to this
328
maps :=
329

    
330
srcRoot = $(mappings)/root.sh
331
mkSrcMap = (. $(srcRoot); env datasrc=$(datasrc) $(bin)/src_map <$*/header.csv\
332
>$@)
333

    
334
translate = $(if $(wildcard $(1)),$(bin)/in_place $< $(bin)/translate_ci 1 $(1))
335

    
336
$(srcDict):# empty target in case it doesn't exist
337

    
338
# Via maps cleanup
339
ifneq ($(filter %/.map.csv.last_cleanup,$(MAKECMDGOALS)),)
340
%/.map.csv.last_cleanup: %/map.csv $(vocab) $(thesaurus) $(coreMap) $(srcDict)
341
	$(call translate,$(srcDict))
342
	$(bin)/in_place $< $(bin)/canon 1 $(vocab)
343
	$(call translate,$(thesaurus))
344
	$(bin)/in_place $< $(bin)/fix_line_endings
345
	touch $@
346
	+$(selfMake) $(<:%/map.csv=%/unmapped_terms.csv)
347
	+$(selfMake) $(<:%/map.csv=%/new_terms.csv)
348
.PRECIOUS: %/.map.csv.last_cleanup
349
else
350
%/map.csv: _always
351
	$(if $(wildcard $@),,$(mk_map_csv))
352
	+$(selfMake) $(@:%/map.csv=%/.map.csv.last_cleanup)
353
define mk_map_csv
354
+$(selfMake) $*/header.csv
355
$(if $(nonXml),$(mkSrcMap))
356
endef
357
endif
358

    
359
%/VegBIEN.csv: %/map.csv $(coreMap)
360
	<$< $(bin)/cat_cols 1 2$(if $(wildcard\
361
$*/run),|$(bin)/cols 1 1 3|(head -1 $<; tail -n +2)\
362
)|$(bin)/join $(coreMap)|$(bin)/sort_map >$@
363
maps += $(autogenMaps)
364

    
365
maps: $(maps) _always ;
366

    
367
all += $(maps)
368

    
369
##### Maps validation
370

    
371
# `tail -n +2`: Remove header before running filter_out_ci because filter_out_ci
372
# only removes the header if it matches the vocabulary's header.
373

    
374
%/unmapped_terms.csv: %/map.csv $(coreMap)
375
	tail -n +2 $<|$(bin)/cols 1|$(bin)/filter_out_ci 0 $(coreMap) >$@
376
	$(bin)/autoremove $@
377

    
378
%/new_terms.csv: %/map.csv $(vocab) $(thesaurus) %/unmapped_terms.csv
379
	$(newTerms)
380
	$(bin)/autoremove $@
381
newTerms = tail -n +2 $<|$(bin)/filter_out_ci 0 $(vocab)|$(bin)/filter_out_ci 0\
382
$(thesaurus) $(if $(wildcard $(word 4,$+)),|$(bin)/filter_out_ci 0 $(word 4,$+))\
383
|grep -vE -e '^"?:' -e 'UNUSED' >$@; exit 0 # grep exits nonzero if no match
384

    
385
termsSubdirs := $(importTables)
386

    
387
include $(root)/lib/mappings.Makefile
388

    
389
##### External dependencies
390

    
391
$(root)/%: _always
392
	+$(subMake)
393
.PRECIOUS: $(root)/% # let ext. dir's Makefile decide whether to delete on error
394

    
395
##### Mapping
396

    
397
+maps = $(filter %/map.csv %/VegBIEN.csv $(mappings)/%,$(+_))
398
map2db = env in_database=vegbien in_schema=$(datasrc) in_table=$*\
399
out_database=vegbien $(root)/map $(+maps)
400

    
401
##### Import to VegBIEN
402

    
403
import: $(importTables:%=%/import) _always ;
404

    
405
rm: _always
406
	echo "DELETE FROM source WHERE shortname = '$(datasrc)';"\
407
|"time" $(psqlAsBien)
408

    
409
reimport: _always rm import ;
410

    
411
profileTest = $(if $(profile),$(if $(test),1))
412
profileOnly = -env profile_to=/dev/fd/3 $(map2db) 3>&1 1>&2|\
413
$(bin)/profile_stats /dev/fd/0
414

    
415
log_ = $*/logs/$(if $(n),n=$(n).,)$(version).log.sql
416

    
417
# Displays the import log file path
418
# Run with `make -s` to avoid echoing make commands
419
%/log_file: _always
420
	echo $$(pwd)/$(log_)
421

    
422
trace = $(log_:.log.sql=.trace)
423
import = -$(if $(profileTest),$(profileOnly),(set -x; date; "time" env commit=1\
424
$(if $(profile),profile_to=$(trace)) $(map2db))$(if $(log), >>$(log_) 2>&1))
425
# don't abort on import errors, which often relate to invalid input data
426

    
427
import? = $(if $(call and,$(full_import),$(call dontImport,.)),,$(import))
428

    
429
%/import: %/VegBIEN.csv _always
430
	$(import?)
431
# default:
432
%/import: _always ;
433

    
434
#### Taxonomic scrubbing
435

    
436
scrub: _always
437
	$(selfMake) $(root)/scrub & echo $$!
438

    
439
# Removes TNRS taxondeterminations
440
unscrub: _always
441
	echo "SELECT delete_scrubbed_taxondeterminations('$(datasrc)');"|\
442
"time" env no_query_results=1 $(psqlAsBien)
443

    
444
rescrub: _always unscrub scrub ;
445

    
446
import_scrub: _always import scrub ;
447

    
448
reimport_scrub: _always reimport scrub ;
449

    
450
##### Log files from import
451

    
452
logs := $(wildcard */logs/*.log.sql */logs/*.trace)
453

    
454
rm_logs: _always
455
	$(RM) $(logs)
456

    
457
##### Verification of import
458

    
459
verifyTables := $(patsubst verify/%.ref,%,$(wildcard verify/*.ref))
460

    
461
verify: $(verifyTables:%=%/verify) _always ;
462

    
463
%/verify: verify/%.ref verify/%.out _always
464
	-$(diffVerbose) $(+_)
465
# don't abort on verification errors, which are expected during development
466
# default:
467
%/verify: verify/%.out _always
468
	$(if $(shell test -e $< && echo t),cat $<)
469
# don't run if verify/%.out's default do-nothing action was used
470
# can't use $(wildcard) because it won't recheck file after verify/%.out is run
471

    
472
psqlExport := "time" $(psqlNoSearchPath) --no-align --field-separator=$$'\t'\
473
--pset=footer=off --pset=null=NULL
474
# Note that using $(inDatasrc) will not work with datasources whose tables are
475
# the same name as VegBIEN tables (likely only VegBank), because the datasource
476
# is first in the search_path.
477
verify = $(if $(reverify),($(inDatasrc); cat $<)|$(psqlExport)\
478
--set=datasource="'$(datasrc)'" >$@)
479

    
480
verify/%.out: $(mappings)/verify.%.sql _always
481
	$(verify)
482
.PRECIOUS: verify/%.out # save partial output in case of error to help debugging
483
# default:
484
verify/%.out: _always ;
485

    
486
all += $(wildcard verify/*.out)
487

    
488
%.ref: %.ref.sql
489
	($(inDatasrc); cat $<)|$(psqlExport) >$@
490
.PRECIOUS: %.ref # there must always be a .ref for the make rules to work
491

    
492
##### Editing import
493

    
494
rename/%: _always
495
	echo "UPDATE source SET shortname = '$*' WHERE shortname = '$(datasrc)';"\
496
|$(psqlAsBien)
497

    
498
##### Testing
499

    
500
testRefOutput = $(subst .by_col,,$(1))
501
testRef = $(testRefOutput).ref
502
hasOwnRef = $(filter $@,$(call testRefOutput,$@))
503
# filter returns non-empty if they are equal
504

    
505
# `rm $@`: Remove outputs of successful tests to reduce clutter
506
# `$(foreach use_staged...)`: Run with use_staged=1
507
define runTest
508
@echo "Testing $(abspath $@)..."
509
>$@ env test=1 n=$(test_n) $(1) $(foreach use_staged,1,$(map2db))
510
$(if $(hasOwnRef),,-)@(set -x; $(diffIgnoreSpace) $(call testRef,$@) $@) 2>&1\
511
&& rm $@ || { e=$$?; $(if $(wildcard $(call testRef,$@)),,cat $@;)\
512
$(if $(hasOwnRef),\
513
{\
514
read -p $(emph)'Accept new test output? (y/n)'$(endEmph) REPLY;\
515
if test "$$REPLY" = y; then\
516
(set -x; $(MAKE) $@-ok --directory=$(realpath .) --makefile=../input.Makefile);\
517
exit 0;\
518
fi;\
519
};,\
520
echo $(emph)"Note: The preceding failed test is compared to another test's\
521
output"$(endEmph);\
522
echo $(emph)"When it fails, this always indicates a bug"$(endEmph);\
523
)\
524
exit $$e;}
525
endef
526

    
527
tests :=
528

    
529
%/test: %/test.xml _always ;
530

    
531
# Requires staging tables. To create them, run `make inputs/<datasrc>/install`.
532
# Non-flat-file inputs fall back to mimicking a successful test
533
%/test.xml: %/VegBIEN.csv _always
534
	$(if $(nonXml),$(call runTest,by_col=))
535
tests += %/test.xml
536

    
537
%/test.by_col.xml: %/VegBIEN.csv _always
538
	$(if $(nonXml),$(call runTest,by_col=1))
539

    
540
# Only run column-based tests if column-based mode enabled, because these tests
541
# are much slower than the row-based tests for small numbers of rows
542
ifneq ($(by_col),)
543
tests += %/test.by_col.xml
544
endif
545

    
546
testOutputs := $(foreach test,$(tests),$(importTables:%=$(test)))
547

    
548
.PRECIOUS: $(testOutputs) # save outputs of failed tests so they can be accepted
549

    
550
test: _always $(testOutputs) ;
551

    
552
all += $(wildcard %/test*.xml)
553

    
554
# Accepts a test output: make <test_output_path>-ok
555
%-ok: _always
556
	mv $* $(call testRef,$*)
557

    
558
accept-all: _always
559
	+yes|$(selfMake) test
560

    
561
##### Documentation
562

    
563
steps = $(selfMake) -s $*/import test=1 by_col=1 verbosity=2 n=100\
564
2>&1|$(bin)/debug2redmine >$@
565

    
566
%/logs/steps.by_col.log.sql: _always
567
	+$(steps)
(9-9/9)