From 68b12189784bf3f9e4bc482e207cc096390e92b7 Mon Sep 17 00:00:00 2001 From: Christian Klutz Date: Mon, 21 Oct 2024 11:10:47 +0200 Subject: [PATCH] improve test experience (#28) --- test/test-docker-linux.ps1 | 10 +--------- test/test-linux.sh | 15 +++++++++++++++ test/test-windows.ps1 | 23 ++++++++++++----------- 3 files changed, 28 insertions(+), 20 deletions(-) create mode 100644 test/test-linux.sh diff --git a/test/test-docker-linux.ps1 b/test/test-docker-linux.ps1 index 5082cb6..2acc2a9 100644 --- a/test/test-docker-linux.ps1 +++ b/test/test-docker-linux.ps1 @@ -1,9 +1 @@ -# -e VSTEST_HOST_DEBUG=1 ` -$mydir = $PSScriptRoot -$project = './test/LockCheck.Tests/LockCheck.Tests.csproj' -$dotnet = '/usr/share/dotnet/dotnet' - -$script = "$dotnet test -c Release -f net8.0 && $dotnet test -c Debug -f net8.0" -$script = $script.Replace("`r", "") - -docker run --rm --name LockCheck.Tests -v ${mydir}/..:/mnt/lc -w /mnt/lc mcr.microsoft.com/dotnet/sdk:8.0 bash -c $script +docker run --rm --name LockCheck.Tests -v ${PSScriptRoot}/..:/mnt/lc -w /mnt/lc mcr.microsoft.com/dotnet/sdk:8.0 bash /mnt/lc/test/test-linux.sh diff --git a/test/test-linux.sh b/test/test-linux.sh new file mode 100644 index 0000000..38e20bf --- /dev/null +++ b/test/test-linux.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +frameworks=('net8.0') +configurations=('Release' 'Debug') +platforms=('x64') +project="$(dirname $0)/LockCheck.Tests/LockCheck.Tests.csproj" + +for framework in "${frameworks[@]}"; do + for configuration in "${configurations[@]}"; do + for platform in "${platforms[@]}"; do + echo -e "\n\033[34m[$framework - $configuration - $platform]\033[0m" + /usr/share/dotnet/dotnet test --logger console -c $configuration -f $framework -a $platform $project || exit 1 + done + done +done diff --git a/test/test-windows.ps1 b/test/test-windows.ps1 index fe10167..6c0e681 100644 --- a/test/test-windows.ps1 +++ b/test/test-windows.ps1 @@ -1,16 +1,17 @@ -# Simply run all test assemblies that are found in the tree. -# If we have builds for debug and release, they are both run. -# Requires that vstest.console.exe is in the PATH. - +$frameworks = ('net481', 'net8.0') +$configurations = ('Debug', 'Release') $platforms = ('x86', 'x64') -$assemblies = Get-ChildItem LockCheck.Tests.dll -Recurse | where { $_.FullName -like "*\bin\*" } +$project = "$PSScriptRoot\LockCheck.Tests\LockCheck.Tests.csproj" -foreach ($assembly in $assemblies) { +foreach ($framework in $frameworks) { foreach ($platform in $platforms) { - echo "vstest.console.exe $assembly /Platform:$platform" - & vstest.console.exe $assembly /Platform:$platform - if ($LASTEXITCODE -ne 0) { - exit 1 + foreach ($configuration in $configurations) { + Write-Host -Foreground DarkBlue "`n[$framework - $configuration - $platform]" + + & dotnet test -c $configuration -f $framework -a $platform $project + if ($LASTEXITCODE -ne 0) { + exit 1 + } } } -} \ No newline at end of file +}