#!/bin/bash
set -efu

arch=$(dpkg-architecture -qDEB_HOST_ARCH)

# xdist may have trouble getting network access for vasp test_help
# if all 48 cores on the test machine are used. Restrict to no more than 4 processes.
NPROC=`nproc`
if [[ NPROC > 4 ]]; then
  export PYTEST_XDIST_AUTO_NUM_WORKERS=4
fi

cp -r /usr/share/doc/pymatgen-core-test-files/examples/test-files $AUTOPKGTEST_TMP

for py in `py3versions -s`; do
  PMG_TEST_FILES_DIR=$AUTOPKGTEST_TMP/test-files \
    $py -m pytest -vv --durations=30 --color=no  -k "test_from_id or (vasp and test_help)" tests
done
