#!/bin/bash
set -e

export FORCE_COLOR=1
export GCC_COLORS=yes
export COLORTERM=truecolor
export TERM=screen-256color
export CLICOLOR=1
export CLICOLOR_FORCE=1

BUILD_ROOT=/tmp/LIEF

export LIEF_SAMPLES_DIR=$BUILD_ROOT/samples
BUILD_DIR=$BUILD_ROOT/build
VENV_DIR=$BUILD_ROOT/venv

export LIEF_BUILD_DIR=$BUILD_ROOT/build
export PYLIEF_CONF=/src/scripts/docker/config/pylinux-test-x64.toml

mkdir -p $LIEF_BUILD_DIR

$PYTHON_BINARY -m venv $VENV_DIR

$VENV_DIR/bin/python -m pip install \
  -r /src/api/python/build-requirements.txt \
  -r /src/tests/requirements.txt

$VENV_DIR/bin/python -m pip -vvv \
  --disable-pip-version-check install \
  --no-build-isolation                     \
  --no-cache-dir                           \
  --editable /src/api/python

$VENV_DIR/bin/python /src/tests/dl_samples.py ${LIEF_SAMPLES_DIR}
$VENV_DIR/bin/python /src/tests/run_pytest.py
ctest --output-on-failure --test-dir ${LIEF_BUILD_DIR}/
