Files
firefox/taskcluster/docker/diffoscope/get_and_diffoscope
T
Mike Hommey b84a960641 Bug 1597903 - When a build differs, check if the generated-files differ. r=froydnj
With this change, the error for bug 1601150 becomes:
TEST-UNEXPECTED-FAIL | i686-unknown-linux-gnu/release/build/cranelift-codegen-37dab135a3db8b7a/out/inst_builder.rs differs. See the generated-files.diff.html or generated-files.diff.txt artifact
TEST-UNEXPECTED-FAIL | i686-unknown-linux-gnu/release/build/cranelift-codegen-37dab135a3db8b7a/out/opcodes.rs differs. See the generated-files.diff.html or generated-files.diff.txt artifact
TEST-UNEXPECTED-FAIL | i686-unknown-linux-gnu/release/build/cranelift-codegen-e483dcad1bdf8c4a/out/inst_builder.rs differs. See the generated-files.diff.html or generated-files.diff.txt artifact
TEST-UNEXPECTED-FAIL | i686-unknown-linux-gnu/release/build/cranelift-codegen-e483dcad1bdf8c4a/out/opcodes.rs differs. See the generated-files.diff.html or generated-files.diff.txt artifact

Differential Revision: https://phabricator.services.mozilla.com/D55771
2019-12-04 22:27:35 +00:00

150 lines
3.4 KiB
Bash

#!/bin/bash
set -e
set -x
cd /builds/worker
mkdir a b
# Until https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=879010 is
# implemented, it's better to first manually extract the data.
# Plus dmg files are not supported yet.
case "$ORIG_URL" in
*/target.zip|*/target.apk)
curl -L "$ORIG_URL" > a.zip
curl -L "$NEW_URL" > b.zip
unzip -d a a.zip
unzip -d b b.zip
;;
*/target.tar.bz2)
curl -L "$ORIG_URL" | tar -C a -jxf -
curl -L "$NEW_URL" | tar -C b -jxf -
;;
*/target.dmg)
for tool in lipo otool; do
ln -s $MOZ_FETCHES_DIR/cctools/bin/x86_64-apple-darwin*-$tool bin/$tool
done
export PATH=$PATH:/builds/worker/bin
curl -L "$ORIG_URL" > a.dmg
curl -L "$NEW_URL" > b.dmg
for i in a b; do
$MOZ_FETCHES_DIR/dmg/dmg extract $i.dmg $i.hfs
$MOZ_FETCHES_DIR/dmg/hfsplus $i.hfs extractall / $i
done
;;
esac
case "$ORIG_URL" in
*/target.apk)
OMNIJAR=assets/omni.ja
;;
*)
OMNIJAR=omni.ja
;;
esac
report_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("$1.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 $1.html or $1.txt artifact'.format(p))
EOF
}
# Builds are 99% of the time differing in some small ways, so it's not
# really useful to report a failure (at least not until we actually
# care about the builds being 100% identical).
POST=true
fail() {
exit 1
}
for option; do
case "$option" in
--unpack)
CURDIR=$PWD
for dir in a b; do
# Need to run mach python from inside the gecko source.
# See bug #1533642.
(cd $GECKO_PATH && ./mach python toolkit/mozapps/installer/unpack.py --omnijar $OMNIJAR $CURDIR/$dir)
done
;;
--fail)
POST="fail"
;;
*)
echo "Unsupported option: $option" >&2
exit 1
esac
done
if [ -n "$PRE_DIFF" ]; then
eval $PRE_DIFF
fi
if diffoscope \
--html diff.html \
--text diff.txt \
--progress \
$DIFFOSCOPE_ARGS \
a b
then
# Ok
:
else
# The builds differ, let's check the generated files.
if curl -L -f "${ORIG_URL%/*}/target.generated-files.tar.gz" > a.generated-files.tar.gz && \
curl -L -f "${NEW_URL%/*}/target.generated-files.tar.gz" > b.generated-files.tar.gz
then
HAVE_GENERATED_FILES=1
else
HAVE_GENERATED_FILES=
fi
if test -n "$HAVE_GENERATED_FILES" && diffoscope \
--html generated-files.diff.html \
--text generated-files.diff.txt \
--progress \
--output-empty \
a.generated-files.tar.gz b.generated-files.tar.gz
then
report_error diff
else
report_error generated-files.diff
fi
$POST
fi