Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 1597903 - Improve error reporting on diffoscope tasks. r=froydnj
Browse files Browse the repository at this point in the history
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
  • Loading branch information
glandium committed Dec 4, 2019
1 parent ecb4d05 commit 9d16ec5
Showing 1 changed file with 44 additions and 4 deletions.
48 changes: 44 additions & 4 deletions taskcluster/docker/diffoscope/get_and_diffoscope
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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

0 comments on commit 9d16ec5

Please sign in to comment.