From 86842acd1b2a99bc2842fa838136b526f567a9d7 Mon Sep 17 00:00:00 2001 From: Lumir Balhar Date: Jul 30 2020 05:50:39 +0000 Subject: 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. --- diff --git a/marshalparser/test_marshalparser_compatibility.sh b/marshalparser/test_marshalparser_compatibility.sh new file mode 100755 index 0000000..2c8d254 --- /dev/null +++ b/marshalparser/test_marshalparser_compatibility.sh @@ -0,0 +1,22 @@ +#!/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 diff --git a/tests.yml b/tests.yml index ee2bd4c..9d49567 100644 --- a/tests.yml +++ b/tests.yml @@ -58,6 +58,9 @@ - debugflags: dir: flags run: python3-debug ./assertflags.py -Og + - marshalparser_compatibility: + dir: marshalparser + run: SAMPLE=10 test_marshalparser_compatibility.sh required_packages: - dnf - gcc @@ -79,3 +82,4 @@ - python3-test - python3-debug - python3-rpm-macros + - marshalparser