scripted_test_4.sh #1

  • //
  • cbd/
  • main/
  • test/
  • shared/
  • scripted_test_4.sh
  • View
  • Commits
  • Open Download .zip Download (3 KB)
#!/bin/bash
set -u

function msg () { echo -e "$*"; }
function cmd () { echo -e "Executing: $*"; $*; return $?; }
function bail () { echo -e "\nError: ${1:-Unkown Error}\n"; exit ${2:-1}; }

export TestID=${1:-1}
export P4BIN=${2:-p4}
export P4PORT=${3:-1666}
export P4USER=${4:-bruno}
export P4CLIENT=TestWS.$TestID
export P4CONFIG=/tmp/.p4config.$TestID
declare -i ExitCode=0
declare TmpFile=/tmp/tmpFile.$TestID.$$.$RANDOM
declare RootDir=/tmp/$P4CLIENT
declare SSTFile=DeepThought-Components.cbdsst

# The DevStream comes into play in the next test, scripted_test_5.sh.
declare MainlineStream=//DeepThought/Components/main
declare DevStream=//DeepThought/Components/dev

echo -e "Running Test $TestID\n$0 $*\n"

/bin/rm -f "$P4CONFIG"
echo -e "P4PORT=$P4PORT\nP4USER=$P4USER\nP4CLIENT=$P4CLIENT\nP4IGNORE=.p4ignore\nP4TICKETS=$PWD/.p4tickets\nP4ENVIRO=$PWD/.p4enviro\nP4TRUST=$PWD/.p4trust" > $P4CONFIG
echo -e "Wrote this P4CONFIG file $P4CONFIG:\n$(cat $P4CONFIG)"

if [[ -n "$($P4BIN -ztag -F %change% changes -m 1 //DeepThought/...)" ]]; then
   msg "Cleanup from earlier runs with 'p4 obliterate'"
   cmd $P4BIN -s obliterate -y //DeepThought/...

   cmd $P4BIN -s stream -d $MainlineStream
   cmd $P4BIN -s stream -d $DevStream
   cmd $P4BIN depot -d DeepThought
fi

echo -e "Depot: DeepThought\n
Owner: bruno\n
Description:\n\tDeep depot with StreamDepth > 1.\n
Type: stream\n
StreamDepth: //DeepThought/1/2\n
Map: DeepThought/...\n" > $TmpFile

$P4BIN -s depot -i < $TmpFile || bail "Failed to load depot DeepThought with this spec:\n$(cat $TmpFile)\n";

msg "Creating mainline stream $MainlineStream."
$P4BIN stream -t mainline -o $MainlineStream | grep -v '^#' > $TmpFile

msg "Loading this stream spec:\n$(cat $TmpFile)\n"

$P4BIN -s stream -i < $TmpFile || bail "Failed to create stream $MainlineStream."

echo -e "Client: $P4CLIENT\n\nOwner: bruno\n\nRoot: $RootDir\n\nStream: $MainlineStream\n\n" > $TmpFile
$P4BIN -s client -i < $TmpFile || bail "Failed to create workspace [$P4CLIENT]."

echo -e "Branch: InitDeepThought\n\nDescription:\n\tCreated by Deep Thought.\n\nView:\n\t//depot/Jam/MAIN/... $MainlineStream/...\n\n" | $P4BIN branch -i

$P4BIN -s populate -b InitDeepThought

cmd $P4BIN -c $P4CLIENT sync -q

cd $RootDir || bail "Could not cd to workspace $P4CLIENT root dir $RootDir."

echo -e "Stream: __EDITME_STREAM__\n\nOwner: bruno\n\nType: __EDITME_STREAM_TYPE__\n\nDescription:\n\tStream spec for __EDITME_STREAM__.\n\nPaths:\n\tshare ...\n\n" > $SSTFile

cmd $P4BIN add $SSTFile

msg Executing: $P4BIN -s submit -d \"Added CBDSST file.\"
$P4BIN -s submit -d "Added CBDSST file."
ExitCode=$?

# The exit code is for the 'p4 submit' command; that's what matters for this test.
exit $ExitCode
# Change User Description Committed
#1 21633 C. Thomas Tyler Populate -o //guest/perforce_software/cbd/main/...
//cbd/main/....
//guest/perforce_software/cbd/main/test/shared/scripted_test_4.sh
#1 19351 C. Thomas Tyler Released CBD/MultiArch/2016.2/19348 (2016/05/10).
Copy Up using 'p4 copy -r -b perforce_software-cbd-dev'.
//guest/perforce_software/cbd/dev/test/shared/scripted_test_4.sh
#4 19348 C. Thomas Tyler Added test for sync in depot with StreamDepth > 1.
#3 19336 C. Thomas Tyler Enhanced StreamDepth > 1 tests.
#2 19334 C. Thomas Tyler Updated test for StreamDepth > 1.
#1 19332 C. Thomas Tyler Added test case for adding CBD file with StreamDepth > 1.