coverage_helper: match commands from both sources
License: MIT Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Christian Couder committed
Oct 16, 2015 at 18:57 UTC
06c3a21c946c990ab3e9e290fc583b98dcaaaad6
1 file changed
+29
test/sharness_test_coverage_helper.sh
+29
@@ -96,4 +96,33 @@ log "Get all the ipfs commands from 'ipfs commands'"
96
CMD_CMDS="$TMPDIR/commands.txt"
97
ipfs commands >"$CMD_CMDS" || die "'ipfs commands' failed"
98
99
+# Portable function to reverse lines in a file
100
+reverse() {
101
+ if type tac >/dev/null
102
+ then
103
+ tac "$@"
104
+ else
105
+ tail -r "$@"
106
+ fi
107
+}
108
+
109
+log "Math the test line commands with the commands they use"
110
+reverse "$CMD_CMDS" | while read -r ipfs cmd sub1 sub2
111
+do
112
+ if test -n "$sub2"
113
+ then
114
+ egrep "$ipfs(\W.*)*\W$cmd(\W.*)*\W$sub1(\W.*)*\W$sub2" "$CMD_RES" >"$TMPDIR/res_${ipfs}_${cmd}_${sub1}_${sub2}.txt"
115
+ else
116
+ if test -n "$sub1"
117
+ then
118
+ egrep "$ipfs(\W.*)*\W$cmd(\W.*)*\W$sub1" "$CMD_RES" >"$TMPDIR/res_${ipfs}_${cmd}_${sub1}.txt"
119
+ else
120
+ if test -n "$cmd"
121
+ then
122
+ egrep "$ipfs(\W.*)*\W$cmd" "$CMD_RES" >"$TMPDIR/res_${ipfs}_${cmd}.txt"
123
+ fi
124
+ fi
125
+ fi
126
+done
127
+
128
# Remove temp directory...