<commit_before>#
# Run a build and set of regression tests on the given remote machine, and pull back the built logs.
#
### @todo - make MACHINE a required parameter - no good default!!!
: ${LOGIN:=lewis}
: ${ECHO_DOCKER_COMMANDS:=0}
: ${RUN_IN_DOCKER:=0}
: ${SSH_TARGET:=$LOGIN@$MACHINE}
: ${BUILD_DIR:=Sandbox/Stroika-Build-Dir-$USE_TEST_BASENAME}
: ${BRANCH:=V2.1-Dev}
: ${BUILD_CONFIGURATIONS_MAKEFILE_TARGET:=default-configurations}
: ${PRIVATE_COMPILER_BUILDS_DIR:-/private-compiler-builds}

if [ "$USE_TEST_BASENAME" == "" ] ; then 
	echo "ERROR: Required setting USE_TEST_BASENAME as argument to RunRemoteRegressionTest."
	exit 1;
fi
if [ "$MACHINE" == "" ] ; then 
	echo "ERROR: Required setting MACHINE as argument to RunRemoteRegressionTest."
	exit 1;
fi

echo ssh $SSH_TARGET rm -rf $BUILD_DIR
ssh $SSH_TARGET rm -rf $BUILD_DIR

echo ssh $SSH_TARGET "mkdir -p $BUILD_DIR"
ssh $SSH_TARGET "mkdir -p $BUILD_DIR"

echo ssh $SSH_TARGET "git clone <EMAIL>:SophistSolutions/Stroika.git $BUILD_DIR --branch $BRANCH"
ssh $SSH_TARGET "git clone <EMAIL>:SophistSolutions/Stroika.git $BUILD_DIR --branch $BRANCH"

VER=`ssh $SSH_TARGET cd $BUILD_DIR && ScriptsLib/ExtractVersionInformation.sh STROIKA_VERSION FullVersionString`
#see RegressionTests.sh for this name, and why we require $USE_TEST_BASENAME set
TEST_OUT_FILE=Tests/HistoricalRegressionTestResults/REGRESSION-TESTS-$USE_TEST_BASENAME-$VER-OUT.txt

echo "Invoking remote RegressionTests.sh"
CMD2Exec=''
if [ $RUN_IN_DOCKER -eq 0 ]; then
	CMD2Exec+='export PATH=$PATH:/usr/local/bin/;'
	CMD2Exec+="export BUILD_CONFIGURATIONS_MAKEFILE_TARGET=$BUILD_CONFIGURATIONS_MAKEFILE_TARGET;"
	CMD2Exec+="export PRIVATE_COMPILER_BUILDS_DIR=$PRIVATE_COMPILER_BUILDS_DIR;"
	CMD2Exec+="export USE_TEST_BASENAME=$USE_TEST_BASENAME;"
	CMD2Exec+="cd $BUILD_DIR && ScriptsLib/RegressionTests.sh"
else
	CMD2Exec+="cd $BUILD_DIR && CONTAINER_NAME=\"$USE_TEST_BASENAME-regtest\" EXTRA_DOCKER_ARGS=\"-e USE_TEST_BASENAME=$USE_TEST_BASENAME -e BUILD_CONFIGURATIONS_MAKEFILE_TARGET=$BUILD_CONFIGURATIONS_MAKEFILE_TARGET -e PRIVATE_COMPILER_BUILDS_DIR=$PRIVATE_COMPILER_BUILDS_DIR -e ECHO_DOCKER_COMMANDS=$ECHO_DOCKER_COMMANDS\" CMD2RUN=ScriptsLib/RegressionTests.sh ScriptsLib/RunInDockerEnvironment"
fi
EXTRA_DOCKER_ARGS="${EXTRA_DOCKER_ARGS:-}"

echo ssh $SSH_TARGET -t $CMD2Exec
ssh $SSH_TARGET -t "$CMD2Exec"

CMD2Exec=''
CMD2Exec+="export USE_TEST_BASENAME=$USE_TEST_BASENAME;"
#if [ $DO_ONLY_DEFAULT_CONFIGURATIONS -eq 1 ] ; then
#	CMD2Exec+="export EXE=Builds/Release/Test50;"
#fi
CMD2Exec+="cd $BUILD_DIR && ScriptsLib/RunPerformanceRegressionTests.sh"
echo ssh $SSH_TARGET $CMD2Exec
ssh $SSH_TARGET "$CMD2Exec"


echo "Fetching results:"
echo scp $SSH_TARGET:$BUILD_DIR/$TEST_OUT_FILE Tests/HistoricalRegressionTestResults/
scp $SSH_TARGET:$BUILD_DIR/$TEST_OUT_FILE Tests/HistoricalRegressionTestResults/

echo scp $SSH_TARGET:$BUILD_DIR/Tests/HistoricalPerformanceRegressionTestResults/PerformanceDump-$USE_TEST_BASENAME-$VER.txt Tests/HistoricalPerformanceRegressionTestResults/
scp $SSH_TARGET:$BUILD_DIR/Tests/HistoricalPerformanceRegressionTestResults/PerformanceDump-$USE_TEST_BASENAME-$VER.txt Tests/HistoricalPerformanceRegressionTestResults/
<commit_msg>ECHO_DOCKER_COMMANDS support in ScriptsLib/RunRemoteRegressionTests.sh<commit_after>#
# Run a build and set of regression tests on the given remote machine, and pull back the built logs.
#
### @todo - make MACHINE a required parameter - no good default!!!
: ${LOGIN:=lewis}
: ${ECHO_DOCKER_COMMANDS:=0}
: ${RUN_IN_DOCKER:=0}
: ${SSH_TARGET:=$LOGIN@$MACHINE}
: ${BUILD_DIR:=Sandbox/Stroika-Build-Dir-$USE_TEST_BASENAME}
: ${BRANCH:=V2.1-Dev}
: ${BUILD_CONFIGURATIONS_MAKEFILE_TARGET:=default-configurations}
: ${PRIVATE_COMPILER_BUILDS_DIR:-/private-compiler-builds}

if [ "$USE_TEST_BASENAME" == "" ] ; then 
	echo "ERROR: Required setting USE_TEST_BASENAME as argument to RunRemoteRegressionTest."
	exit 1;
fi
if [ "$MACHINE" == "" ] ; then 
	echo "ERROR: Required setting MACHINE as argument to RunRemoteRegressionTest."
	exit 1;
fi

echo ssh $SSH_TARGET rm -rf $BUILD_DIR
ssh $SSH_TARGET rm -rf $BUILD_DIR

echo ssh $SSH_TARGET "mkdir -p $BUILD_DIR"
ssh $SSH_TARGET "mkdir -p $BUILD_DIR"

echo ssh $SSH_TARGET "git clone git@github.com:SophistSolutions/Stroika.git $BUILD_DIR --branch $BRANCH"
ssh $SSH_TARGET "git clone git@github.com:SophistSolutions/Stroika.git $BUILD_DIR --branch $BRANCH"

VER=`ssh $SSH_TARGET cd $BUILD_DIR && ScriptsLib/ExtractVersionInformation.sh STROIKA_VERSION FullVersionString`
#see RegressionTests.sh for this name, and why we require $USE_TEST_BASENAME set
TEST_OUT_FILE=Tests/HistoricalRegressionTestResults/REGRESSION-TESTS-$USE_TEST_BASENAME-$VER-OUT.txt

echo "Invoking remote RegressionTests.sh"
CMD2Exec=''
if [ $RUN_IN_DOCKER -eq 0 ]; then
	CMD2Exec+='export PATH=$PATH:/usr/local/bin/;'
	CMD2Exec+="export BUILD_CONFIGURATIONS_MAKEFILE_TARGET=$BUILD_CONFIGURATIONS_MAKEFILE_TARGET;"
	CMD2Exec+="export PRIVATE_COMPILER_BUILDS_DIR=$PRIVATE_COMPILER_BUILDS_DIR;"
	CMD2Exec+="export PRIVATE_COMPILER_BUILDS_DIR=$PRIVATE_COMPILER_BUILDS_DIR;"
	CMD2Exec+="export USE_TEST_BASENAME=$USE_TEST_BASENAME;"
	CMD2Exec+="export ECHO_DOCKER_COMMANDS=$ECHO_DOCKER_COMMANDS;"
	CMD2Exec+="cd $BUILD_DIR && ScriptsLib/RegressionTests.sh"
else
	CMD2Exec+="cd $BUILD_DIR && CONTAINER_NAME=\"$USE_TEST_BASENAME-regtest\" EXTRA_DOCKER_ARGS=\"-e USE_TEST_BASENAME=$USE_TEST_BASENAME -e BUILD_CONFIGURATIONS_MAKEFILE_TARGET=$BUILD_CONFIGURATIONS_MAKEFILE_TARGET -e PRIVATE_COMPILER_BUILDS_DIR=$PRIVATE_COMPILER_BUILDS_DIR\" CMD2RUN=ScriptsLib/RegressionTests.sh ScriptsLib/RunInDockerEnvironment"
fi
EXTRA_DOCKER_ARGS="${EXTRA_DOCKER_ARGS:-}"

echo ssh $SSH_TARGET -t $CMD2Exec
ssh $SSH_TARGET -t "$CMD2Exec"

CMD2Exec=''
CMD2Exec+="export USE_TEST_BASENAME=$USE_TEST_BASENAME;"
#if [ $DO_ONLY_DEFAULT_CONFIGURATIONS -eq 1 ] ; then
#	CMD2Exec+="export EXE=Builds/Release/Test50;"
#fi
CMD2Exec+="cd $BUILD_DIR && ScriptsLib/RunPerformanceRegressionTests.sh"
echo ssh $SSH_TARGET $CMD2Exec
ssh $SSH_TARGET "$CMD2Exec"


echo "Fetching results:"
echo scp $SSH_TARGET:$BUILD_DIR/$TEST_OUT_FILE Tests/HistoricalRegressionTestResults/
scp $SSH_TARGET:$BUILD_DIR/$TEST_OUT_FILE Tests/HistoricalRegressionTestResults/

echo scp $SSH_TARGET:$BUILD_DIR/Tests/HistoricalPerformanceRegressionTestResults/PerformanceDump-$USE_TEST_BASENAME-$VER.txt Tests/HistoricalPerformanceRegressionTestResults/
scp $SSH_TARGET:$BUILD_DIR/Tests/HistoricalPerformanceRegressionTestResults/PerformanceDump-$USE_TEST_BASENAME-$VER.txt Tests/HistoricalPerformanceRegressionTestResults/

{'fraction_non_alphanumeric': 0.11131359149582384, 'fraction_numerical': 0.008200455580865604, 'mean_word_length': 8.185495118549511, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7233654', 'n_tokens_mistral': 2573, 'n_tokens_neox': 2385, 'n_words': 423}