coverage_helper: refactor matching commands
License: MIT Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Christian Couder committed
Oct 17, 2015 at 13:06 UTC
292ef427d0be1cf675c9202542e4799c97a2ebff
1 file changed
+17
-16
test/sharness_test_coverage_helper.sh
+17
-16
@@ -111,28 +111,29 @@ log "Match the test line commands with the commands they use"
111
GLOBAL_REV="$TMPDIR/global_results_reversed.txt"
112
reverse "$CMD_CMDS" | while read -r ipfs cmd sub1 sub2
113
do
114
- if test -n "$sub2"
114
+ if test -n "$cmd"
115
then
116
- CMD_OUT="$TMPDIR/res_${ipfs}_${cmd}_${sub1}_${sub2}.txt"
117
- egrep "$ipfs(\W.*)*\W$cmd(\W.*)*\W$sub1(\W.*)*\W$sub2" "$CMD_RES" >"$CMD_OUT"
118
- reverse "$CMD_OUT" | sed -e 's/^sharness\///' | cut -d- -f1 | uniq -c >>"$GLOBAL_REV"
119
- echo "$ipfs $cmd $sub1 $sub2" >>"$GLOBAL_REV"
120
- else
116
+ CMD_OUT="$TMPDIR/res_${ipfs}_${cmd}"
117
+ PATTERN="$ipfs(\W.*)*\W$cmd"
118
+ NAME="$ipfs $cmd"
119
+
120
if test -n "$sub1"
121
then
123
- CMD_OUT="$TMPDIR/res_${ipfs}_${cmd}_${sub1}.txt"
124
- egrep "$ipfs(\W.*)*\W$cmd(\W.*)*\W$sub1" "$CMD_RES" >"$CMD_OUT"
125
- reverse "$CMD_OUT" | sed -e 's/^sharness\///' | cut -d- -f1 | uniq -c >>"$GLOBAL_REV"
126
- echo "$ipfs $cmd $sub1" >>"$GLOBAL_REV"
127
- else
128
- if test -n "$cmd"
122
+ CMD_OUT="${CMD_OUT}_${sub1}"
123
+ PATTERN="$PATTERN(\W.*)*\W$sub1"
124
+ NAME="$NAME $sub1"
125
+
126
+ if test -n "$sub2"
127
then
130
- CMD_OUT="$TMPDIR/res_${ipfs}_${cmd}.txt"
131
- egrep "$ipfs(\W.*)*\W$cmd" "$CMD_RES" >"$CMD_OUT"
132
- reverse "$CMD_OUT" | sed -e 's/^sharness\///' | cut -d- -f1 | uniq -c >>"$GLOBAL_REV"
133
- echo "$ipfs $cmd" >>"$GLOBAL_REV"
128
+ CMD_OUT="${CMD_OUT}_${sub2}"
129
+ PATTERN="$PATTERN(\W.*)*\W$sub2"
130
+ NAME="$NAME $sub2"
131
fi
132
fi
133
+
134
+ egrep "$PATTERN" "$CMD_RES" >"$CMD_OUT"
135
+ reverse "$CMD_OUT" | sed -e 's/^sharness\///' | cut -d- -f1 | uniq -c >>"$GLOBAL_REV"
136
+ echo "$NAME" >>"$GLOBAL_REV"
137
fi
138
done
139