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

Appveyor tests #1138

Merged
merged 3 commits into from
Feb 29, 2016
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
31 changes: 19 additions & 12 deletions src/app/FakeLib/AppVeyor.fs
Original file line number Diff line number Diff line change
Expand Up @@ -152,21 +152,28 @@ let FinishTestCase testSuiteName testCaseName (duration : System.TimeSpan) =
/// Union type representing the available test result formats accepted by AppVeyor.
type TestResultsType =
| MsTest
| NUnit
| Xunit
| NUnit
| NUnit3
| JUnit

/// Uploads all the test results ".xml" files in a directory to make them visible in Test tab of the build console.
let UploadTestResultsXml (testResultsType : TestResultsType) outputDir =
/// Uploads a test result file to make them visible in Test tab of the build console.
let UploadTestResultsFile (testResultsType : TestResultsType) file =
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
)
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

/// Uploads all the test results ".xml" files in a directory to make them visible in Test tab of the build console.
let UploadTestResultsXml (testResultsType : TestResultsType) outputDir =
if buildServer = BuildServer.AppVeyor then
System.IO.Directory.EnumerateFiles(path = outputDir, searchPattern = "*.xml")
|> Seq.map(fun file -> async { UploadTestResultsFile testResultsType file })
|> Async.Parallel
|> Async.RunSynchronously
|> ignore