#! /bin/sh
set -xe
origin="$PWD"

# Entry point for BMUv4 Feature Tests

# Clean out anything that might be lurking around...
git clean -fdx

# Do a bazel clean to prevent the cache from getting too large
bazel clean

# Environment variables are injected using pytest fixtures. See:
# https://confluence.zooxlabs.com/pages/viewpage.action?pageId=161154284

# Build Docker containers
cd firmware/validation/docker/net_man
./build.sh bmuv4_feature
cd $origin

# Set up virtualenv
if [ -d bmu_feature_env ]; then
    rm -rf bmu_feature_env
fi

virtualenv -p python3.6 bmu_feature_env
. bmu_feature_env/bin/activate
python -m pip install -r firmware/validation/bmuv4_feature/requirements.txt

# DBC files are generated by the make_dbcs fixture defined in the dbc_builder.py plugin.

# Run Smoke Test
python -m pytest firmware/validation/bmuv4_feature/test_deploy.py \
                 --exitfirst \
                 --verbose

# Run everything else
python -m pytest firmware/validation/bmuv4_feature/ \
                 --ignore=firmware/validation/bmuv4_feature/test_deploy.py \
                 --verbose
