#!/bin/bash
#==============================================================================
# Copyright and license info is available in the LICENSE file included with
# the Component Based Development (CBD) project, and also available online:
# https://swarm.workshop.perforce.com/projects/perforce-software-cbd/view/main/LICENSE
#------------------------------------------------------------------------------
# This wrapper to test_cbd.sh defines recommended flags for use with continuous
# integration testing.  Use '-L off' (disable logging) since CI builds do their
# own log handling; there's no need to use the built-in self-logging feature.

set -u
set -e

export CBD_HOME=${CBD_HOME:-Undefined}
export BUILD_TAG=${BUILD_TAG:-Undefined}
declare Version=1.0.4

echo "Starting ${0##*/} v$Version at $(date)."

if [[ "${CBD_HOME}" == Undefined ]]; then
   if [[ -d /p4/common/bin/cbd ]]; then
      export CBD_HOME=/p4/common/bin/cbd
   else
      echo -e "\nError: CBD_HOME not defined. Aborting.\n"
      exit 1
   fi
fi

export P4U_HOME=${P4U_HOME:-/p4/common/lib}
export P4U_LIB=$P4U_HOME

echo "Setting path to include python3+p4python."
export PATH="$(dirname $CBD_HOME)/p4/common/python/bin:$PATH"

echo "Build Tag: $BUILD_TAG"

$CBD_HOME/test/test_cbd.sh -a -L off -I

exit $?
