Blame marshalparser/test_marshalparser_compatibility.sh

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