python/marshalparser/test_marshalparser_compatibility.sh
Lumir Balhar 86842acd1b Add marshalparser to Python tests
Marshalparser helps us to uniform byte-compiled Python files
so it has to be able to also parse pyc files from
the main python packages.
Moreover, it has its own database of magic numbers so this test
checks that the parser is compatible with the latest python before
we ship it.
2020-07-30 07:50:39 +02:00

22 lines
687 B
Bash
Executable file

#!/bin/sh -eux
# Marshalparser helps us to uniform byte-compiled Python files
# so it has to be able to also parse pyc files from
# the main python packages.
# Moreover, it has its own database of magic numbers so this test
# checks that the parser is compatible with the latest python before
# we ship it.
# Test the latest version by default because that's the place
# where magic number incompatibility might happen with
# the largest probability
VERSION=${VERSION:-3.9}
# How many randomly-selected pyc files to check?
SAMPLE=${SAMPLE:-50}
path="/usr/lib*/python$VERSION/"
for file in `find $path -name "*.pyc" | shuf | head -n $SAMPLE`; do
marshalparser $file || exit 1
done