-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Workaround critical bug in JUnit file parsing
- Loading branch information
Showing
2 changed files
with
83 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ | |
open Xunit | ||
open Fake.Core | ||
|
||
open System.Xml | ||
|
||
|
||
let runTool (tool: string) (args: string []) (dir:string) = | ||
CreateProcess.fromRawCommand tool args | ||
|
@@ -14,4 +16,78 @@ let runTool (tool: string) (args: string []) (dir:string) = | |
|
||
|
||
//let result = runTool "dotnet" [|"fsi"; @"C:\Repos\nfdi4plants\arc-validation-packages\validation_packages\invenio\[email protected]"|] @"C:\Repos\nfdi4plants\arc-validation-packages\tests\fixtures\testARC_empty\" | ||
let result = runTool "dotnet" [|"fsi"; @"C:\Repos\nfdi4plants\arc-validation-packages\validation_packages\invenio\[email protected]"|] @"C:\Repos\nfdi4plants\arc-validation-packages\tests\fixtures\testARC_emptyContactsColumn\" | ||
let result = runTool "dotnet" [|"fsi"; @"C:\Repos\nfdi4plants\arc-validation-packages\validation_packages\invenio\[email protected]"|] @"C:\Repos\nfdi4plants\arc-validation-packages\tests\fixtures\testARC_emptyContactsColumn\" | ||
|
||
|
||
type JUnitResults = { | ||
PassedTests: string list | ||
FailedTests: string list | ||
ErroredTests: string list | ||
} with | ||
static member fromJUnitFile (path:string) = | ||
let doc = new XmlDocument() | ||
doc.Load(path) | ||
let suite = doc.SelectNodes("/testsuites/testsuite[@name='arc-validate']").Item(0); | ||
let testCases = suite.SelectNodes("testcase") |> Seq.cast<XmlNode> | ||
{ | ||
PassedTests = | ||
testCases | ||
|> Seq.filter (fun tc -> tc.SelectNodes("failure").Count = 0) | ||
|> Seq.map (fun tc -> tc.Attributes.["name"].Value) | ||
|> Seq.toList | ||
|> List.sort | ||
|
||
FailedTests = | ||
testCases | ||
|> Seq.filter (fun tc -> tc.SelectNodes("failure").Count > 0) | ||
|> Seq.map (fun tc -> tc.Attributes.["name"].Value) | ||
|> Seq.toList | ||
|> List.sort | ||
|
||
ErroredTests = | ||
testCases | ||
|> Seq.filter (fun tc -> tc.SelectNodes("error").Count > 0) | ||
|> Seq.map (fun tc -> tc.Attributes.["name"].Value) | ||
|> Seq.toList | ||
|> List.sort | ||
} | ||
|
||
static member getTotalTestCount (res : JUnitResults) = | ||
res.ErroredTests.Length + res.FailedTests.Length + res.PassedTests.Length | ||
|
||
|
||
let jUnitRes = JUnitResults.fromJUnitFile @"C:\Repos\nfdi4plants\arc-validation-packages\tests\fixtures\ArcPrototype\.arc-validate-results\[email protected]\validation_report.xml" | ||
|
||
null = null | ||
|
||
let doc = new XmlDocument() | ||
doc.Load(@"C:\Repos\nfdi4plants\arc-validation-packages\tests\fixtures\ArcPrototype\.arc-validate-results\[email protected]\validation_report.xml") | ||
let suite = | ||
doc.SelectNodes("/testsuites/testsuite[@name='arc-validate']").Item(0) | ||
|> fun r -> | ||
if isNull r then | ||
doc.SelectNodes("/testsuites/testsuite[@name='fsi']").Item(0) | ||
else r | ||
let testCases = suite.SelectNodes("testcase") |> Seq.cast<XmlNode> | ||
{ | ||
PassedTests = | ||
testCases | ||
|> Seq.filter (fun tc -> tc.SelectNodes("failure").Count = 0) | ||
|> Seq.map (fun tc -> tc.Attributes.["name"].Value) | ||
|> Seq.toList | ||
|> List.sort | ||
|
||
FailedTests = | ||
testCases | ||
|> Seq.filter (fun tc -> tc.SelectNodes("failure").Count > 0) | ||
|> Seq.map (fun tc -> tc.Attributes.["name"].Value) | ||
|> Seq.toList | ||
|> List.sort | ||
|
||
ErroredTests = | ||
testCases | ||
|> Seq.filter (fun tc -> tc.SelectNodes("error").Count > 0) | ||
|> Seq.map (fun tc -> tc.Attributes.["name"].Value) | ||
|> Seq.toList | ||
|> List.sort | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters