Skip to content

Commit 264652d

Browse files
committed
Attempt to harden the upload code
Also add additional verbose output to improve debuggability print response from upload
1 parent 1747530 commit 264652d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tools/appveyor.psm1

+7-3
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,14 @@ function Invoke-AppveyorTest {
5050

5151
$modulePath = $env:PSModulePath.Split([System.IO.Path]::PathSeparator) | Where-Object { Test-Path $_} | Select-Object -First 1
5252
Copy-Item "${CheckoutPath}\out\PSScriptAnalyzer" "$modulePath\" -Recurse -Force
53-
$testResultsFile = ".\TestResults.xml"
53+
$testResultsPath = Join-Path ${CheckoutPath} TestResults.xml
5454
$testScripts = "${CheckoutPath}\Tests\Engine","${CheckoutPath}\Tests\Rules","${CheckoutPath}\Tests\Documentation"
55-
$testResults = Invoke-Pester -Script $testScripts -OutputFormat NUnitXml -OutputFile $testResultsFile -PassThru
56-
(New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/${env:APPVEYOR_JOB_ID}", (Resolve-Path $testResultsFile))
55+
$uploadUrl = "https://ci.appveyor.com/api/testresults/nunit/${env:APPVEYOR_JOB_ID}"
56+
$testResults = Invoke-Pester -Script $testScripts -OutputFormat NUnitXml -OutputFile $testResultsPath -PassThru
57+
Write-Verbose -Verbose "Uploading test results '$testResultsPath' to '${uploadUrl}'"
58+
$response = (New-Object 'System.Net.WebClient').UploadFile("$uploadUrl" , $testResultsPath)
59+
$responseString = [System.Text.Encoding]::ASCII.GetString($response)
60+
Write-Verbose -Verbose ("Response: ({0} bytes) ${responseString}" -f $response.Count)
5761
if ($testResults.FailedCount -gt 0) {
5862
throw "$($testResults.FailedCount) tests failed."
5963
}

0 commit comments

Comments
 (0)