You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
2.3 KiB
85 lines
2.3 KiB
4 years ago
|
#! /bin/bash
|
||
9 years ago
|
PLATFORM=$1
|
||
|
TYPE=$2
|
||
4 years ago
|
COVERAGE=$3
|
||
|
WHERE="Category!=ManualTest"
|
||
9 years ago
|
TEST_PATTERN="*Test.dll"
|
||
4 years ago
|
FILES=( "Sonarr.Api.Test.dll" "Sonarr.Automation.Test.dll" "Sonarr.Common.Test.dll" "Sonarr.Core.Test.dll" "Sonarr.Host.Test.dll" "Sonarr.Integration.Test.dll" "Sonarr.Libraries.Test.dll" "Sonarr.Mono.Test.dll" "Sonarr.Update.Test.dll" "Sonarr.Windows.Test.dll" )
|
||
|
ASSMEBLIES=""
|
||
8 years ago
|
TEST_LOG_FILE="TestLog.txt"
|
||
9 years ago
|
|
||
4 years ago
|
echo "test dir: $TEST_DIR"
|
||
|
if [ -z "$TEST_DIR" ]; then
|
||
|
TEST_DIR="."
|
||
|
fi
|
||
|
|
||
9 years ago
|
if [ -d "$TEST_DIR/_tests" ]; then
|
||
|
TEST_DIR="$TEST_DIR/_tests"
|
||
|
fi
|
||
|
|
||
8 years ago
|
rm -f "$TEST_LOG_FILE"
|
||
|
|
||
|
# Uncomment to log test output to a file instead of the console
|
||
4 years ago
|
export SONARR_TESTS_LOG_OUTPUT="File"
|
||
|
|
||
|
VSTEST_PARAMS="--logger:nunit;LogFilePath=TestResult.xml"
|
||
8 years ago
|
|
||
4 years ago
|
if [ "$PLATFORM" = "Mac" ]; then
|
||
|
|
||
|
export DYLD_FALLBACK_LIBRARY_PATH="$TEST_DIR:$MONOPREFIX/lib:/usr/local/lib:/lib:/usr/lib"
|
||
|
echo $DYLD_FALLBACK_LIBRARY_PATH
|
||
|
mono --version
|
||
|
|
||
|
# To debug which libraries are being loaded:
|
||
|
# export DYLD_PRINT_LIBRARIES=YES
|
||
|
fi
|
||
9 years ago
|
|
||
|
if [ "$PLATFORM" = "Windows" ]; then
|
||
4 years ago
|
mkdir -p "$ProgramData/Sonarr"
|
||
|
WHERE="$WHERE&Category!=LINUX"
|
||
12 months ago
|
elif [ "$PLATFORM" = "Linux" ]; then
|
||
4 years ago
|
mkdir -p ~/.config/Sonarr
|
||
|
WHERE="$WHERE&Category!=WINDOWS"
|
||
12 months ago
|
elif [ "$PLATFORM" = "Mac" ]; then
|
||
|
mkdir -p ~/Library/Application\ Support/Sonarr
|
||
|
WHERE="$WHERE&Category!=WINDOWS"
|
||
9 years ago
|
else
|
||
12 months ago
|
echo "Platform must be provided as first argument: Windows, Linux or Mac"
|
||
9 years ago
|
exit 1
|
||
|
fi
|
||
|
|
||
|
if [ "$TYPE" = "Unit" ]; then
|
||
4 years ago
|
WHERE="$WHERE&Category!=IntegrationTest&Category!=AutomationTest"
|
||
9 years ago
|
elif [ "$TYPE" = "Integration" ] || [ "$TYPE" = "int" ] ; then
|
||
4 years ago
|
WHERE="$WHERE&Category=IntegrationTest"
|
||
9 years ago
|
elif [ "$TYPE" = "Automation" ] ; then
|
||
4 years ago
|
WHERE="$WHERE&Category=AutomationTest"
|
||
9 years ago
|
else
|
||
|
echo "Type must be provided as second argument: Unit, Integration or Automation"
|
||
|
exit 2
|
||
|
fi
|
||
|
|
||
4 years ago
|
for i in "${FILES[@]}";
|
||
|
do ASSEMBLIES="$ASSEMBLIES $TEST_DIR/$i"
|
||
9 years ago
|
done
|
||
|
|
||
4 years ago
|
DOTNET_PARAMS="$ASSEMBLIES --filter:$WHERE $VSTEST_PARAMS"
|
||
|
|
||
|
if [ "$COVERAGE" = "Coverage" ]; then
|
||
|
dotnet test $DOTNET_PARAMS --settings:"src/coverlet.runsettings" --results-directory:./CoverageResults
|
||
|
EXIT_CODE=$?
|
||
|
elif [ "$COVERAGE" = "Test" ] ; then
|
||
|
dotnet test $DOTNET_PARAMS
|
||
|
EXIT_CODE=$?
|
||
|
else
|
||
|
echo "Run Type must be provided as third argument: Coverage or Test"
|
||
|
exit 3
|
||
|
fi
|
||
9 years ago
|
|
||
|
if [ "$EXIT_CODE" -ge 0 ]; then
|
||
|
echo "Failed tests: $EXIT_CODE"
|
||
|
exit 0
|
||
|
else
|
||
|
exit $EXIT_CODE
|
||
|
fi
|