-
Notifications
You must be signed in to change notification settings - Fork 450
/
Copy pathtestVsArtifacts.ps1
45 lines (37 loc) · 1.96 KB
/
testVsArtifacts.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
param (
[string]$StagingDirectory
)
# Set the path to test project (.csproj) and runtime settings
$testProjectPath = "..\..\test\Azure.Functions.Cli.Tests\Azure.Functions.Cli.Tests.csproj"
$runtimeSettings = "..\..\test\Azure.Functions.Cli.Tests\E2E\StartTests_artifact_consolidation_visualstudio.runsettings"
[System.Environment]::SetEnvironmentVariable("FUNCTIONS_WORKER_RUNTIME", "dotnet", "Process")
dotnet build $testProjectPath
# Loop through each subdirectory within the parent directory
Get-ChildItem -Path $StagingDirectory -Directory | ForEach-Object {
$subDir = $_.FullName
Write-Host "name of current file: $subDir"
if ($subDir -like "*win-x*") {
Write-Host "Current directory: $subDir"
# Find func.exe in the subdirectory
$funcExePath = Get-ChildItem -Path $subDir -Filter "func.exe" -ErrorAction SilentlyContinue
if ($funcExePath) {
$funcExePathFullName = $funcExePath.FullName
Write-Host "Setting FUNC_PATH to: $funcExePathFullName"
# Set the environment variable FUNC_PATH to the func.exe or func path
[System.Environment]::SetEnvironmentVariable("FUNC_PATH", $funcExePath.FullName, "Process")
# Run dotnet test with the environment variable set
Write-Host "Running 'dotnet test' on test project: $testProjectPath"
dotnet test $testProjectPath --no-build --settings $runtimeSettings --logger "console;verbosity=detailed"
if ($LASTEXITCODE -ne 0) {
# If the exit code is non-zero, throw an error
Write-Host "Tests failed with exit code $LASTEXITCODE"
throw "dotnet test failed within $subDir. Exiting with error."
} else {
# If the exit code is zero, tests passed
Write-Host "All tests passed successfully within $subDir"
}
} else {
Write-Host "No func.exe or func found in: $subDir"
}
}
}