Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UploadTestResultsXml function to the AppVeyor module #636

Merged
merged 3 commits into from
Jan 24, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/app/FakeLib/AppVeyor.fs
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,25 @@ let FinishTestCase testSuiteName testCaseName (duration : System.TimeSpan) =
|> string

sendToAppVeyor <| sprintf "UpdateTest \"%s\" -Duration %s" (testSuiteName + " - " + testCaseName) duration

/// Union type representing the available test result formats accepted by AppVeyor.
type TestResultsType =
| MsTest
| NUnit
| Xunit

/// Uploads the test results .xml file to the Test tab of the build console.
let UploadTestResultsXml testResultsType outputDir =
if buildServer = BuildServer.AppVeyor then
let resultsType = (sprintf "%A" testResultsType).ToLower()
let url = sprintf "https://ci.appveyor.com/api/testresults/%s/%s" resultsType AppVeyorEnvironment.JobId
let files = System.IO.Directory.GetFiles(path = outputDir, searchPattern = "*.xml")
use wc = new System.Net.WebClient()
files
|> Seq.iter (fun file ->
try
wc.UploadFile(url, file) |> ignore
printfn "Successfully uploaded test results %s" file
with
| ex -> printfn "An error occurred while uploading %s:\r\n%O" file ex
)