lbalhar / tests / python

Forked from tests/python 3 years ago
Clone

Blame marshalparser/test_marshalparser_compatibility.sh

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