aboutsummaryrefslogtreecommitdiffstats
path: root/selftest
blob: 87ebb3a70fcc2e3dacc69f71533ddd8f980c8a6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
# selftest — build twice and assert the wheels tarballs are byte-identical, for
# both modes. The smallest check that fails if the reproducible-tar
# normalization (or either mode's resolution) breaks.
set -eu

here=$(cd "$(dirname "$0")" && pwd)
tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT

# Fixed epoch so both runs use the same mtime (we test tar determinism, not
# epoch derivation).
epoch=1620000000
fail=0

check() {
    local label=$1 file=$2; shift 2
    OUTPUT="$tmp/a" "$here/mkwheels" "$@" --epoch "$epoch" >/dev/null
    OUTPUT="$tmp/b" "$here/mkwheels" "$@" --epoch "$epoch" >/dev/null
    local a b
    a=$(md5sum "$tmp/a/$file" | cut -d' ' -f1)
    b=$(md5sum "$tmp/b/$file" | cut -d' ' -f1)
    if [ "$a" = "$b" ]; then
        echo "PASS: $label reproducible ($a)"
    else
        echo "FAIL: $label tarballs differ ($a != $b)" >&2
        fail=1
    fi
}

# pypi mode: six from PyPI.
check pypi six-wheels-1.16.0.tar.gz pypi --name six --ver 1.16.0

# gh mode: pyparsing from its GitHub source release (pure-python, no runtime
# deps -> fast). Its tags have no 'v' prefix, exercising the bare-tag path.
check gh pyparsing-wheels-3.3.2.tar.gz gh --repo pyparsing/pyparsing --ver 3.3.2

exit "$fail"