Bug 1597903 - Improve error reporting on diffoscope tasks. r=froydnj

Somehow parse the diff output to print out slightly more unique error messages.

With this change, the error for bug 1597901 becomes:
TEST-UNEXPECTED-FAIL | firefox/libmozavutil.so differs. See the diff.html or diff.txt artifact

And the error for bug 1601150 becomes:
TEST-UNEXPECTED-FAIL | firefox/libxul.so differs. See the diff.html or diff.txt artifact

Which is not great, but better than the status quo.

Differential Revision: https://phabricator.services.mozilla.com/D55770

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mike Hommey 2019-12-04 22:27:33 +00:00
Родитель a9695045db
Коммит f9693bded5
1 изменённых файлов: 44 добавлений и 4 удалений

Просмотреть файл

@ -51,8 +51,6 @@ esac
POST=true
fail() {
set +x
echo "TEST-UNEXPECTED-FAIL | Builds differ. See the diff.html or diff.txt artifact"
exit 1
}
@ -79,9 +77,51 @@ if [ -n "$PRE_DIFF" ]; then
eval $PRE_DIFF
fi
diffoscope \
if diffoscope \
--html diff.html \
--text diff.txt \
--progress \
$DIFFOSCOPE_ARGS \
a b || $POST
a b
then
# Ok
:
else
# The builds differ, let's try to output a useful error.
# We "parse" the diff output, so we look at the lines that contain a "tee", like:
# ├── firefox
# │ ├── libxul.so
# │ │ ├── readelf --wide --notes {}
# We ignore lines like the last one, to only report file names. And we ignore
# lines for directories such as the first one, but still look at them to report
# full paths.
python3 <<-EOF
TEE = '├──'
paths = set()
path = []
with open("diff.txt") as fh:
for l in fh:
if TEE not in l:
continue
fields = l.split()
# We rely on the number of │ to figure out at what level the file
# name applies.
if fields[-2:-1] == [TEE]:
path[len(fields) - 2:] = [fields[-1]]
else:
# Align path length to match the number of │
path.append(None)
path_ = [p for p in path if p]
full_path = '/'.join(path_)
parent_path = '/'.join(path_[:1])
if parent_path in paths:
paths.remove(parent_path)
if full_path:
paths.add(full_path)
for p in sorted(paths):
print('TEST-UNEXPECTED-FAIL | {} differs. See the diff.html or diff.txt artifact'.format(p))
EOF
$POST
fi