Files
scylladb/test/lib/mutation_diff
Benny Halevy 0e79e0f215 test: mutation_diff: extend section markers
When the different mutations are printed via
BOOST_REQUIRE_EQUAL, we don't get the "expect {} but got {}"
section markers.  Instead, the parts we're interested in
are bracketed like "critical check X == Y has failed [{} != {}]"

Test: with both formats:
- https://github.com/scylladb/scylla/files/3890627/test_concurrent_reads_and_eviction.log
- https://github.com/scylladb/scylla/files/4303117/flat_mutation_reader_test.118.log
- https://github.com/scylladb/scylla/files/5687372/flat_mutation_reader_test.172.log.gz

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
Message-Id: <20201214100521.3814909-1-bhalevy@scylladb.com>
2020-12-14 12:11:34 +02:00

41 lines
878 B
Bash
Executable File

#!/usr/bin/env bash
#
# Converts assertion failure text involving two mutations to a diff.
#
cmd="colordiff -u"
sed_cmd="sed -E"
while getopts ":d:" opt; do
case $opt in
d)
cmd="$OPTARG";;
*)
echo "Usage: $0 [-d diff_command] [<path-to-test-output-file>]" 1>&2
exit 1;;
esac
done
shift $((OPTIND-1))
file="$1"
if [ -z "$file" -o "$file" = "-" ]; then
tmpfile=$(mktemp)
cat > "$tmpfile"
file="$tmpfile"
fi
function filter {
$sed_cmd 's/@0x[0-9a-f]*//g'
}
begin="(expected |critical check .+ == .+ has failed \[)"
middle="(got:|\!=)"
end="^$|\}\]|Leaving test case"
$cmd <($sed_cmd -n "/$begin/,/$middle/p" "$file" | head -n-1 | $sed_cmd "s/.*$begin/&\n/" | filter) \
<($sed_cmd -n "/$middle/,/$end/p" "$file" | $sed_cmd "s/.*$middle /&\n/" | filter) | less -R
if [ -n "$tmpfile" ]; then
rm -f "$tmpfile"
fi