<commit_before>#!/bin/sh

set -e

APK="apk -q"
BUILDDEPS="gcc python3-dev musl-dev"
TESTDEPS="bitstring pytest setuptools wheel virtualenv"
PIP3="pip3 -q --no-cache-dir install --upgrade"
FROOT=/faucet-src

dir=`dirname $0`

# Clean up
rm -r "$FROOT/docs"

$APK add -U git yaml-dev $BUILDDEPS && \
  $dir/retrycmd.sh "$PIP3 pip" && \
  $dir/retrycmd.sh "$PIP3 $TESTDEPS" && \
  $dir/retrycmd.sh "$PIP3 -r $FROOT/requirements.txt" && \
  $PIP3 $FROOT

if [ "$ARCH" == "armhf" ]; then
  echo "Skipping tests on $ARCH platform"
else
  python3 -m pytest $FROOT/tests/unit/faucet/test_*.py
  python3 -m pytest $FROOT/tests/unit/gauge/test_*.py
fi

for i in $BUILDDEPS ; do
  $APK del $i
done

find / -name \*pyc -delete<commit_msg>Smoke test faucet to make sure installation was successful at build time. Speed up installation with parallel unit tests.<commit_after>#!/bin/sh

set -e

APK="apk -q"
BUILDDEPS="gcc python3-dev musl-dev parallel yaml-dev"
TESTDEPS="bitstring pytest wheel virtualenv"
PIP3="pip3 -q --no-cache-dir install --upgrade"
FROOT=/faucet-src

dir=`dirname $0`

# Clean up
rm -r "$FROOT/docs"

$APK add -U git $BUILDDEPS && \
  $dir/retrycmd.sh "$PIP3 pip" && \
  $dir/retrycmd.sh "$PIP3 setuptools $TESTDEPS" && \
  $dir/retrycmd.sh "$PIP3 -r $FROOT/requirements.txt" && \
  $PIP3 $FROOT

if [ "$ARCH" == "armhf" ]; then
  echo "Skipping tests on $ARCH platform"
else
  echo $FROOT/tests/unit/faucet/test_*.py $FROOT/tests/unit/gauge/test_*.py | xargs realpath | shuf | parallel --delay 1 --bar --halt now,fail=1 -j 2 python3 -m pytest
fi

pip3 uninstall -y $TESTDEPS || exit 1
for i in $BUILDDEPS ; do
  $APK del $i || exit 1
done

# Smoke test
faucet -V || exit 1

find / -name \*pyc -delete || exit 1
{'fraction_non_alphanumeric': 0.1563953488372093, 'fraction_numerical': 0.015697674418604653, 'mean_word_length': 3.4585492227979273, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6403653', 'n_tokens_mistral': 718, 'n_tokens_neox': 715, 'n_words': 197}