2019-09-02 23:03:41 +02:00
|
|
|
#! /bin/bash
|
2016-04-02 04:19:32 +02:00
|
|
|
PLATFORM=$1
|
|
|
|
TYPE=$2
|
2019-09-02 23:03:41 +02:00
|
|
|
COVERAGE=$3
|
2019-10-14 23:42:30 +02:00
|
|
|
WHERE="Category!=ManualTest"
|
2016-04-02 04:19:32 +02:00
|
|
|
TEST_PATTERN="*Test.dll"
|
|
|
|
ASSEMBLIES=""
|
2019-09-02 23:03:41 +02:00
|
|
|
TEST_LOG_FILE="TestLog.txt"
|
|
|
|
|
|
|
|
echo "test dir: $TEST_DIR"
|
|
|
|
if [ -z "$TEST_DIR" ]; then
|
|
|
|
TEST_DIR="."
|
|
|
|
fi
|
2016-04-02 04:19:32 +02:00
|
|
|
|
|
|
|
if [ -d "$TEST_DIR/_tests" ]; then
|
|
|
|
TEST_DIR="$TEST_DIR/_tests"
|
|
|
|
fi
|
|
|
|
|
2019-09-02 23:03:41 +02:00
|
|
|
rm -f "$TEST_LOG_FILE"
|
|
|
|
|
|
|
|
# Uncomment to log test output to a file instead of the console
|
|
|
|
export RADARR_TESTS_LOG_OUTPUT="File"
|
|
|
|
|
2019-12-07 08:37:11 +01:00
|
|
|
VSTEST_PARAMS="--Platform:x64 --logger:nunit;LogFilePath=TestResult.xml"
|
2019-09-02 23:03:41 +02:00
|
|
|
|
|
|
|
if [ "$PLATFORM" = "Mac" ]; then
|
|
|
|
|
2019-10-14 22:21:00 +02:00
|
|
|
export DYLD_FALLBACK_LIBRARY_PATH="$TEST_DIR:$MONOPREFIX/lib:/usr/local/lib:/lib:/usr/lib"
|
2019-09-02 23:03:41 +02:00
|
|
|
echo $DYLD_FALLBACK_LIBRARY_PATH
|
2019-10-14 22:21:00 +02:00
|
|
|
mono --version
|
2019-09-02 23:03:41 +02:00
|
|
|
|
|
|
|
# To debug which libraries are being loaded:
|
|
|
|
# export DYLD_PRINT_LIBRARIES=YES
|
|
|
|
fi
|
2016-04-02 04:19:32 +02:00
|
|
|
|
|
|
|
if [ "$PLATFORM" = "Windows" ]; then
|
2019-09-02 23:03:41 +02:00
|
|
|
mkdir -p "$ProgramData/Radarr"
|
2019-10-14 23:42:30 +02:00
|
|
|
WHERE="$WHERE&Category!=LINUX"
|
2019-09-02 23:03:41 +02:00
|
|
|
elif [ "$PLATFORM" = "Linux" ] || [ "$PLATFORM" = "Mac" ] ; then
|
|
|
|
mkdir -p ~/.config/Radarr
|
2019-10-14 23:42:30 +02:00
|
|
|
WHERE="$WHERE&Category!=WINDOWS"
|
2016-04-02 04:19:32 +02:00
|
|
|
else
|
|
|
|
echo "Platform must be provided as first arguement: Windows, Linux or Mac"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$TYPE" = "Unit" ]; then
|
2019-10-14 23:42:30 +02:00
|
|
|
WHERE="$WHERE&Category!=IntegrationTest&Category!=AutomationTest"
|
2016-04-02 04:19:32 +02:00
|
|
|
elif [ "$TYPE" = "Integration" ] || [ "$TYPE" = "int" ] ; then
|
2019-10-14 23:42:30 +02:00
|
|
|
WHERE="$WHERE&Category=IntegrationTest"
|
2016-04-02 04:19:32 +02:00
|
|
|
elif [ "$TYPE" = "Automation" ] ; then
|
2019-10-14 23:42:30 +02:00
|
|
|
WHERE="$WHERE&Category=AutomationTest"
|
2016-04-02 04:19:32 +02:00
|
|
|
else
|
|
|
|
echo "Type must be provided as second argument: Unit, Integration or Automation"
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
|
|
|
for i in `find $TEST_DIR -name "$TEST_PATTERN"`;
|
|
|
|
do ASSEMBLIES="$ASSEMBLIES $i"
|
|
|
|
done
|
|
|
|
|
2019-12-07 08:37:11 +01:00
|
|
|
DOTNET_PARAMS="$ASSEMBLIES --TestCaseFilter:$WHERE $VSTEST_PARAMS"
|
|
|
|
|
2019-09-02 23:03:41 +02:00
|
|
|
if [ "$COVERAGE" = "Coverage" ]; then
|
2019-12-07 08:37:11 +01:00
|
|
|
dotnet vstest $DOTNET_PARAMS --settings:"src/coverlet.runsettings" --ResultsDirectory:./CoverageResults
|
|
|
|
EXIT_CODE=$?
|
2019-09-02 23:03:41 +02:00
|
|
|
elif [ "$COVERAGE" = "Test" ] ; then
|
2019-12-07 08:37:11 +01:00
|
|
|
dotnet vstest $DOTNET_PARAMS
|
2019-09-02 23:03:41 +02:00
|
|
|
EXIT_CODE=$?
|
|
|
|
else
|
|
|
|
echo "Run Type must be provided as third argument: Coverage or Test"
|
|
|
|
exit 3
|
|
|
|
fi
|
2016-10-25 23:00:27 +02:00
|
|
|
|
|
|
|
if [ "$EXIT_CODE" -ge 0 ]; then
|
|
|
|
echo "Failed tests: $EXIT_CODE"
|
2019-09-02 23:03:41 +02:00
|
|
|
exit 0
|
2016-10-25 23:00:27 +02:00
|
|
|
else
|
|
|
|
exit $EXIT_CODE
|
|
|
|
fi
|