forked from TrueCloudLab/s3-tests-parser
Compare commits
No commits in common. "bfb00633ee49378d875cbcb13d50b6bd4913fc5a" and "ca943e1dc8d87126f6d0189d6ffbce57439b8ab1" have entirely different histories.
bfb00633ee
...
ca943e1dc8
4 changed files with 706 additions and 353 deletions
|
@ -27,7 +27,6 @@ s3-tests-parser compatibility suite.json --format json --output-format md --outp
|
||||||
|
|
||||||
type (
|
type (
|
||||||
Results struct {
|
Results struct {
|
||||||
Verbose bool
|
|
||||||
Legend []Status
|
Legend []Status
|
||||||
TagGroups []TagGroup
|
TagGroups []TagGroup
|
||||||
}
|
}
|
||||||
|
@ -48,8 +47,6 @@ type (
|
||||||
Comment string
|
Comment string
|
||||||
Passed int
|
Passed int
|
||||||
Total int
|
Total int
|
||||||
FailedTests []string
|
|
||||||
PassedTests []string
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -57,14 +54,12 @@ const (
|
||||||
formatFlag = "format"
|
formatFlag = "format"
|
||||||
outputFlag = "output"
|
outputFlag = "output"
|
||||||
outputFormatFlag = "output-format"
|
outputFormatFlag = "output-format"
|
||||||
verboseFlag = "verbose"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func initCompatibilityCmd() {
|
func initCompatibilityCmd() {
|
||||||
compatibilityCmd.Flags().String(formatFlag, "csv", "format of input test suite file")
|
compatibilityCmd.Flags().String(formatFlag, "csv", "format of input test suite file")
|
||||||
compatibilityCmd.Flags().String(outputFlag, "", "file to write output, if missed the stdout is used")
|
compatibilityCmd.Flags().String(outputFlag, "", "file to write output, if missed the stdout is used")
|
||||||
compatibilityCmd.Flags().String(outputFormatFlag, "txt", "format of output")
|
compatibilityCmd.Flags().String(outputFormatFlag, "txt", "format of output")
|
||||||
compatibilityCmd.Flags().Bool(verboseFlag, false, "produce additional info")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func runCompatibilityCmd(cmd *cobra.Command, args []string) error {
|
func runCompatibilityCmd(cmd *cobra.Command, args []string) error {
|
||||||
|
@ -83,7 +78,6 @@ func runCompatibilityCmd(cmd *cobra.Command, args []string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
res := formResults(testStruct, testsMap)
|
res := formResults(testStruct, testsMap)
|
||||||
res.Verbose = viper.GetBool(verboseFlag)
|
|
||||||
return printResults(cmd, res)
|
return printResults(cmd, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +96,7 @@ var legend = []Status{
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Color: templates.BlueColor,
|
Color: templates.BlueColor,
|
||||||
Description: "Not supported",
|
Description: "Not supported yet, but will be in future",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Color: templates.BlackColor,
|
Color: templates.BlackColor,
|
||||||
|
@ -112,21 +106,12 @@ var legend = []Status{
|
||||||
|
|
||||||
func formResults(testStruct s3.TestsStructure, testsMap map[string]bool) Results {
|
func formResults(testStruct s3.TestsStructure, testsMap map[string]bool) Results {
|
||||||
tagGroups := make(map[string]TagGroup)
|
tagGroups := make(map[string]TagGroup)
|
||||||
groupTests := make(map[string][]string)
|
|
||||||
for _, group := range testStruct.Groups {
|
|
||||||
groupTests[group.Name] = group.Tests
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, group := range testStruct.Groups {
|
for _, group := range testStruct.Groups {
|
||||||
tagGroup, ok := tagGroups[group.Tag]
|
tagGroup, ok := tagGroups[group.Tag]
|
||||||
if !ok {
|
if !ok {
|
||||||
tagGroup.Name = group.Tag
|
tagGroup.Name = group.Tag
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, n := range group.Include {
|
|
||||||
group.Tests = append(group.Tests, groupTests[n]...)
|
|
||||||
}
|
|
||||||
|
|
||||||
tagGroup.Tests = append(tagGroup.Tests, formTestResult(group, testsMap))
|
tagGroup.Tests = append(tagGroup.Tests, formTestResult(group, testsMap))
|
||||||
tagGroups[group.Tag] = tagGroup
|
tagGroups[group.Tag] = tagGroup
|
||||||
}
|
}
|
||||||
|
@ -145,19 +130,16 @@ func formResults(testStruct s3.TestsStructure, testsMap map[string]bool) Results
|
||||||
|
|
||||||
func formTestResult(group s3.Group, testsMap map[string]bool) TestResult {
|
func formTestResult(group s3.Group, testsMap map[string]bool) TestResult {
|
||||||
ln := len(group.Tests)
|
ln := len(group.Tests)
|
||||||
|
pass := 0
|
||||||
|
|
||||||
var failed []string
|
|
||||||
var passed []string
|
|
||||||
for _, test := range group.Tests {
|
for _, test := range group.Tests {
|
||||||
if testsMap[test] {
|
if testsMap[test] {
|
||||||
passed = append(passed, test)
|
pass++
|
||||||
} else {
|
|
||||||
failed = append(failed, test)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var color string
|
var color string
|
||||||
if strings.Contains(group.Comment, "Not supported") {
|
if strings.Contains(group.Comment, "Not supported yet") {
|
||||||
color = templates.BlueColor
|
color = templates.BlueColor
|
||||||
} else if strings.Contains(group.Comment, "Not applicable") {
|
} else if strings.Contains(group.Comment, "Not applicable") {
|
||||||
color = templates.BlackColor
|
color = templates.BlackColor
|
||||||
|
@ -165,7 +147,7 @@ func formTestResult(group s3.Group, testsMap map[string]bool) TestResult {
|
||||||
|
|
||||||
if color == "" {
|
if color == "" {
|
||||||
color = templates.RedColor
|
color = templates.RedColor
|
||||||
rate := float64(len(passed)) / float64(ln)
|
rate := float64(pass) / float64(ln)
|
||||||
if rate > 0.9 {
|
if rate > 0.9 {
|
||||||
color = templates.GreenColor
|
color = templates.GreenColor
|
||||||
} else if rate > 0.5 {
|
} else if rate > 0.5 {
|
||||||
|
@ -177,10 +159,8 @@ func formTestResult(group s3.Group, testsMap map[string]bool) TestResult {
|
||||||
Color: color,
|
Color: color,
|
||||||
Name: group.Name,
|
Name: group.Name,
|
||||||
Comment: group.Comment,
|
Comment: group.Comment,
|
||||||
Passed: len(passed),
|
Passed: pass,
|
||||||
Total: ln,
|
Total: ln,
|
||||||
FailedTests: failed,
|
|
||||||
PassedTests: passed,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -19,7 +19,6 @@ type Group struct {
|
||||||
Skip bool `json:"skip"`
|
Skip bool `json:"skip"`
|
||||||
Comment string `json:"comment"`
|
Comment string `json:"comment"`
|
||||||
Tests []string `json:"tests"`
|
Tests []string `json:"tests"`
|
||||||
Include []string `json:"include"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseTestsStruct() (TestsStructure, error) {
|
func ParseTestsStruct() (TestsStructure, error) {
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
# S3 Protocol Compatibility
|
# S3 Protocol Compatibility
|
||||||
{{$verbose := .Verbose}}
|
|
||||||
{{range .TagGroups}}
|
{{range .TagGroups}}
|
||||||
## {{.Name}}
|
## {{.Name}}
|
||||||
{{range .Tests}}
|
{{range .Tests}}
|
||||||
{{colorToTerminal .Color}}{{.Name}}: {{.Passed}}/{{.Total}}; {{.Comment}} {{colorToTerminal "black"}}{{if $verbose}}
|
{{colorToTerminal .Color}}{{.Name}}: {{.Passed}}/{{.Total}}; {{.Comment}} {{colorToTerminal "black"}} {{end}}
|
||||||
failed: {{.FailedTests}}
|
|
||||||
passed: {{.PassedTests}}
|
|
||||||
{{end}}{{end}}
|
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
Loading…
Add table
Reference in a new issue