unity-test-runner/dist/steps/run_tests.sh

114 lines
2.7 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
2020-01-29 22:42:41 +00:00
#
# Set and display project path
#
UNITY_PROJECT_PATH="$GITHUB_WORKSPACE/$PROJECT_PATH"
echo "Using project path \"$UNITY_PROJECT_PATH\"."
2020-01-29 22:42:41 +00:00
#
# Set and display the artifacts path
#
2020-01-30 23:35:41 +00:00
echo "Using artifacts path \"$ARTIFACTS_PATH\" to save test results."
FULL_ARTIFACTS_PATH=$GITHUB_WORKSPACE/$ARTIFACTS_PATH
#
# Set and display the coverage results path
#
echo "Using artifacts path \"$COVERAGE_RESULTS_PATH\" to save test coverage results."
FULL_COVERAGE_RESULTS_PATH=$GITHUB_WORKSPACE/$COVERAGE_RESULTS_PATH
2020-01-29 22:54:44 +00:00
#
# Display custom parameters
#
2022-04-17 20:05:17 +00:00
2020-02-11 19:33:00 +00:00
echo "Using custom parameters $CUSTOM_PARAMETERS."
2020-01-29 22:54:44 +00:00
# The following tests are 2019 mode (requires Unity 2019.2.11f1 or later)
# Reference: https://docs.unity3d.com/2019.3/Documentation/Manual/CommandLineArguments.html
#
# Display the unity version
#
echo "Using Unity version \"$UNITY_VERSION\" to test."
#
# Overall info
#
echo ""
echo "###########################"
echo "# Artifacts folder #"
echo "###########################"
echo ""
echo "Creating \"$FULL_ARTIFACTS_PATH\" if it does not exist."
mkdir -p $FULL_ARTIFACTS_PATH
echo ""
echo "###########################"
echo "# Project directory #"
echo "###########################"
echo ""
ls -alh $UNITY_PROJECT_PATH
#
# Testing for each platform
#
2022-04-19 01:44:49 +00:00
for $platform in ${TEST_PLATFORMS//,/ }; do
echo ""
echo "###########################"
echo "# Testing in $platform #"
echo "###########################"
echo ""
if [ $platform -ne "COMBINE_RESULTS" ]; then
$runTests = "-runTests -testPlatform $platform -testResults $FULL_ARTIFACTS_PATH/$platform-results.xml"
else
$runTests = "-quit"
fi
2020-11-26 17:19:17 +00:00
unity-editor \
-batchmode \
-logFile "$FULL_ARTIFACTS_PATH/$platform.log" \
2020-11-26 17:19:17 +00:00
-projectPath "$UNITY_PROJECT_PATH" \
2022-04-18 23:57:08 +00:00
-coverageResultsPath "$FULL_COVERAGE_RESULTS_PATH" \
$runTests \
"$COVERAGE_OPTIONS" \
2022-04-18 23:57:08 +00:00
$CUSTOM_PARAMETERS
2020-11-26 17:19:17 +00:00
2020-02-14 21:26:26 +00:00
# Catch exit code
TEST_EXIT_CODE=$?
# Print unity log output
cat "$FULL_ARTIFACTS_PATH/$platform.log"
# Display results
if [ $TEST_EXIT_CODE -eq 0 ]; then
echo "Run succeeded, no failures occurred";
elif [ $TEST_EXIT_CODE -eq 2 ]; then
echo "Run succeeded, some tests failed";
elif [ $TEST_EXIT_CODE -eq 3 ]; then
echo "Run failure (other failure)";
else
echo "Unexpected exit code $TEST_EXIT_CODE";
fi
if [ $TEST_EXIT_CODE -gt 0 ]; then
TEST_RUNNER_EXIT_CODE=$TEST_EXIT_CODE
fi
echo ""
echo "###########################"
echo "# $platform Results #"
echo "###########################"
echo ""
2022-04-19 01:49:03 +00:00
if [ $platform -ne "COMBINE_RESULTS" ]; then
cat "$FULL_ARTIFACTS_PATH/$platform-results.xml"
cat "$FULL_ARTIFACTS_PATH/$platform-results.xml" | grep test-run | grep Passed
fi
2022-04-19 01:49:03 +00:00
done