#------------------------------------------------------------------------------
# Convenience aliases for testing.
#------------------------------------------------------------------------------

#------------------------------------------------------------------------------
# Usage:
# cd /pub/sdp/dev/test
# . ./env.sh
#------------------------------------------------------------------------------

declare _SDP_TEST_HOME=$PWD

# Sync Latest SDP Workspace
# This assumes the SDP workspace has a .p4config file containig a setting like:
# P4CLIENT=tom_tyler.P4MBPro3.test_sdp_dev
# It also assumes P4PORT and P4USER context settings are already defined
# appropriately for accessing the Public Depot.
function sl () {
   declare p4configFile="$_SDP_TEST_HOME/sdp/.p4config"
   user=$(p4 set -q P4USER)
   if [[ -r "$p4configFile" ]]; then
      ws=$(grep P4CLIENT= sdp/.p4config)
      ws=${ws#*=}
      if [[ -n "$ws" ]]; then
         syncCmd="p4 -c $ws -s sync -q --parallel=threads=8"
         echo "Running: $syncCmd"
         $syncCmd
         return $?
      else
         echo -e "\\nError: Could not determine P4CLIENT value from $p4configFile. Not syncing."
         return 1
      fi
   else
      echo -e "\\nError: Missing $p4configFile.  To use the 'sl' (sync latest)\\nfunction, create a file $p4configFile containing:\\n\\nP4CLIENT=<your_sdp_test_workspace>\\n\\nSee: $p4configFile/$README.md\\n"
      return 1
   fi
}

# Run Docker Tests for CentOS 6
alias dr6='docker run --rm -v $PWD/sdp:/sdp perforce/centos6-sdp /p4/docker_entry.sh'

# Docker Interative Session for CentOS 6
alias di6='docker run --rm -v $PWD/sdp:/sdp -it perforce/centos6-sdp /bin/bash'

# Run Docker Tests for CentOS 7
alias dr7='docker run --rm -v $PWD/sdp:/sdp perforce/centos7-sdp /p4/docker_entry.sh'

# Docker Interative Session for CentOS 7
alias di7='docker run --rm -v $PWD/sdp:/sdp -it perforce/centos7-sdp /bin/bash'
