scripted_test_2.sh #1

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

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 ExitCode=

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)"

RootDir=/tmp/$P4CLIENT
Stream="//jam/rel2.1"
TmpFile=/tmp/tmpFile.$TestID.$$.$RANDOM

/bin/rm -rf $RootDir

Cmd="$P4BIN client -df -Fs $P4CLIENT"
echo "Running: $Cmd"
$Cmd > /dev/null 2>&1 ||:

echo "Creating Workspace $P4CLIENT"
echo -e "Client: $P4CLIENT\n\nOwner: $P4USER\n\nDescription:\n\tCreated by $P4USER.\n\nRoot: $RootDir\n\nOptions: allwrite noclobber compress locked modtime normdir\n\nSubmitOptions: leaveunchanged\n\nLineEnd: local\n\nStream: $Stream\n\n" > $TmpFile

$P4BIN -s client -i < $TmpFile

if [[ $? -ne 0 ]]; then
   echo -e "Failed to create workspace with this spec:\n$(cat $TmpFile)\n"
   cat $TmpFile
   exit 2
fi

mkdir -p $RootDir || exit 2
echo "Operating in: $PWD"

cd $RootDir || exit 2

Cmd="$P4BIN -s sync -f jam.cbdsst"
echo "Running: $Cmd"
$Cmd || exit 2

Cmd="$P4BIN -s edit jam.cbdsst"
echo "Running: $Cmd"
$Cmd || exit 2

# Note extra space in the 'share' entry.
echo -e "Stream: __EDITME_STREAM__\n\nDescription:\n\tUpdated by $P4USER on $(date).\n
Paths:
        share  ...
        import pb/... //pb/1.5.1-p/...@8906
        import gwt/... //gwt-streams/release1.5/...@12050\n" > jam.cbdsst

Cmd="$P4BIN -s submit -d BOOM jam.cbdsst"
echo -e "Attempting to submit *.cbdsst with extranneous whitespace.  A little extra whitespace never hurt anybody, right?\nRunning: $Cmd"
$Cmd
ExitCode=$?

Cmd="$P4BIN -s revert jam.cbdsst"
echo -e "Silently reverting jam.cbdsst so a lock won't break the next test.\nRunning: $Cmd"
$Cmd > /dev/null 2>&1 ||:

Cmd="$P4BIN keys -e cbd_stream*"
echo -e "Showing keys after test $TestID\nRunning: $Cmd"
$Cmd ||:

# 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_2.sh
#1 15273 C. Thomas Tyler Copy Up using 'p4 copy -r -b perforce_software-cbd-ntx64'.
Stabilization changes.
Test suite enhancements.
//guest/perforce_software/cbd/ntx64/test/shared/scripted_test_2.sh
#3 15271 C. Thomas Tyler Scripted tests 1-3 now works correctly.
#2 15258 C. Thomas Tyler Added support for executing scripted mini-tests, and added some tests
and a test config file for managing scripted tests.

Modified Triggers table to run trigger as both change-content and
change-commit trigger.

Added 'Stream:' field with macro to generated *.cbdsst files.
#1 15171 C. Thomas Tyler Prep to add new scripted tests to test submits.