Skip to content

Commit

Permalink
Add script for running E2E tests on Windows (#778)
Browse files Browse the repository at this point in the history
  • Loading branch information
premun authored Nov 26, 2021
1 parent 2863beb commit 7aeebc6
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tools/install-xharness.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ chmod u+x "$dotnet_install"
dotnet_dir="$here/.dotnet"

printf "Installing .NET SDK locally to \033[0;33m%s\033[0m..\n" "$dotnet_dir"
$dotnet_install --install-dir "$dotnet_dir" --version "6.0.100-rc.1.21430.12"
$dotnet_install --install-dir "$dotnet_dir" --version "6.0.100"
echo 'dotnet installed'

export DOTNET_ROOT="$here/.dotnet"
Expand Down
64 changes: 64 additions & 0 deletions tools/run-e2e-test.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<#
.SYNOPSIS
This script is a quick way to run the XHarness E2E tests.
These test are located in tests/integration-tests and require the Arcade and Helix SDK.
To run them, you need to invoke these through MSBuild which makes the process a bit cumbersome.
This script should make things easier.
.EXAMPLE
.\run-e2e-test.ps1 -TestProject Apple/SimulatorInstaller.Tests.proj [-SkipBuild]
#>

param (
<# Path to the test project. Can be also relative to tests/integration-tests, e.g. Apple/Device.iOS.Tests.proj #>
[Parameter(Mandatory = $true)]
[string]
$TestProject,

<# Skip re-building the local package #>
[switch]
$SkipBuild = $false
)

$repoRoot = Resolve-Path "$PSScriptRoot\.."

function Write-Projects {
$testRoot = "$repoRoot\tests\integration-tests\"
$files = Get-ChildItem -Recurse -Include *Tests.proj -Path $testRoot | ForEach-Object { $_.FullName.Substring($testRoot.Length) }

Write-Output "Possible options:"
foreach ($item in $files) {
" - $item"
}
}

if (-not(Test-Path -Path $TestProject -PathType Leaf)) {
$TestProject = "$repoRoot\tests\integration-tests\$TestProject"

if (-not(Test-Path -Path $TestProject -PathType Leaf)) {
Write-Error "The file $TestProject not found"
Write-Projects
Exit 1
}
}

if ($SkipBuild) {
Write-Host -ForegroundColor Cyan "> Skipping build"
} else {
Write-Host -ForegroundColor Cyan "> Building Microsoft.DotNet.XHarness.CLI.1.0.0-dev.nupkg"

Remove-Item -Recurse -ErrorAction SilentlyContinue "$repoRoot\artifacts\tmp\Debug\Microsoft.DotNet.XHarness.CLI"
Remove-Item -Recurse -ErrorAction SilentlyContinue "$repoRoot\artifacts\artifacts\packages"

& "$repoRoot\Build.cmd" -pack -projects "$repoRoot\src\Microsoft.DotNet.XHarness.CLI\Microsoft.DotNet.XHarness.CLI.csproj"
}

$Env:BUILD_REASON = "pr"
$Env:BUILD_REPOSITORY_NAME = "arcade"
$Env:BUILD_SOURCEBRANCH = "test"
$Env:SYSTEM_TEAMPROJECT = "dnceng"
$Env:SYSTEM_ACCESSTOKEN = ""

Write-Host -ForegroundColor Cyan "> Starting tests (logging to XHarness.binlog)"

& "$repoRoot\Build.cmd" -configuration Debug -test -projects "$TestProject" /p:RestoreUsingNugetTargets=false /bl:.\XHarness.binlog
6 changes: 4 additions & 2 deletions tools/run-e2e-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ done
here="$( cd -P "$( dirname "$source" )" && pwd )"
repo_root="$( cd -P "$( dirname "$here" )" && pwd )"

if [ -z $test_project ] || [ "-h" == "$test_project" ] || [ "--help" == "$test_project" ]; then
if [ -z "$test_project" ] || [ "-h" == "$test_project" ] || [ "--help" == "$test_project" ]; then
fail "Usage: ./run-e2e-test.sh Apple/SimulatorInstaller.Tests.proj [--skip-build]"
print_projects
exit 2
Expand Down Expand Up @@ -82,6 +82,8 @@ if [ "true" != "$skip_build" ]; then
highlight "> Building Microsoft.DotNet.XHarness.CLI.1.0.0-dev.nupkg"
rm -rf "$repo_root/artifacts/tmp/Debug/Microsoft.DotNet.XHarness.CLI" "$repo_root/artifacts/packages"
"$repo_root/build.sh" -build -pack --projects "$repo_root/src/Microsoft.DotNet.XHarness.CLI/Microsoft.DotNet.XHarness.CLI.csproj"
else
highlight "> Skipping build"
fi

export BUILD_REASON="dev"
Expand All @@ -90,5 +92,5 @@ export BUILD_SOURCEBRANCH="master"
export SYSTEM_TEAMPROJECT="dnceng"
export SYSTEM_ACCESSTOKEN=""

highlight "> Starting tests (logging to ./XHarness.binlog)"
highlight "> Starting tests (logging to XHarness.binlog)"
"$repo_root/build.sh" -configuration Debug -restore -test -projects "$test_project" /p:RestoreUsingNugetTargets=false /bl:./XHarness.binlog

0 comments on commit 7aeebc6

Please sign in to comment.