Project

General

Profile

« Previous | Next » 

Revision 640

input.Makefile: Use pipefail to cause a test to fail even when the output is filtered by grep. Print message for failing tests with command to run to accept the new test output.

View differences:

input.Makefile
1
selfDir_3d1bc249 := $(dir $(lastword $(MAKEFILE_LIST)))
1
selfDir_uZPPqC := $(dir $(lastword $(MAKEFILE_LIST)))
2 2

  
3 3
# Make
4
SHELL := /bin/bash
4 5
subMake = $(MAKE) $(@F) --directory=$(@D)
5 6
+_ = $(+:_%=)
6 7
addBeforeExt = $(basename $(2))$(1)$(suffix $(2))
7 8

  
9
# Terminal
10
esc := '['
11
reset := $(esc)'0m'
12
emph := $(esc)'7m '
13
endEmph := ' '$(reset)
14

  
8 15
# Commands
9 16
CP = cp -p
10 17
DIFF = diff --unified=2
......
18 25
+maps = $(filter maps/%,$(+_))
19 26
+in = $(filter-out maps/%,$(+_))
20 27

  
21
root := $(selfDir_3d1bc249)..
28
root := $(selfDir_uZPPqC)..
22 29
psqlAsBien := $(root)/bin/psql_vegbien
23 30

  
24 31
# Config
......
110 117
testRef = $(1:.2-step.xml=.xml).ref
111 118

  
112 119
define test
113
env test=1 n=$(test_n) $(1) $(if $(+in),<$(+in)) $(+maps) $(if $(2),,>$@) 2>&1 \
114
$(if $(2),| grep -v -E '^$(2)$$' >$@) || { e=$$?; cat $@; exit $$e;}
120
@(set -o pipefail -x; env test=1 n=$(test_n) $(1) $(if $(+in),<$(+in)) $(+maps)\
121
$(if $(2),,>$@) 2>&1 $(if $(2),| grep -v -E '^$(2)$$' >$@)) ||\
122
{ e=$$?; cat $@; echo $(emph)"To accept new test output:"$(endEmph);\
123
echo "$(MAKE) $@-ok --directory=$(realpath .) --makefile=../input.Makefile";\
124
exit $$e;}
115 125
$(DIFF) $(call testRef,$@) $@
116 126
endef
117 127

  

Also available in: Unified diff