forked from TrueCloudLab/s3-tests-parser
Compare commits
2 commits
Author | SHA1 | Date | |
---|---|---|---|
8e325c79e5 | |||
b08b08d6a0 |
7 changed files with 634 additions and 516 deletions
13
README.md
13
README.md
|
@ -21,3 +21,16 @@ You can also use json
|
|||
```shell
|
||||
$ ./bin/s3-tests-parser compatibility tests/fixture/suite.json --format json --output-format md --output result.md
|
||||
```
|
||||
|
||||
## Tests to check
|
||||
|
||||
You can see all tests that will be checked during `compatibility` command by using:
|
||||
```shell
|
||||
$ ./bin/s3-tests-parser tests --output tests.txt
|
||||
```
|
||||
|
||||
Output file now contains tests and can be provided as parameter for running [s3-tests](https://git.frostfs.info/TrueCloudLab/s3-tests):
|
||||
|
||||
```shell
|
||||
S3TEST_CONF=your.conf tox -- @tests.txt
|
||||
```
|
||||
|
|
|
@ -21,7 +21,8 @@ var compatibilityCmd = &cobra.Command{
|
|||
Example: `s3-tests-parser compatibility suite.csv
|
||||
s3-tests-parser compatibility suite.json --format json
|
||||
s3-tests-parser compatibility suite.json --format json --output-format md
|
||||
s3-tests-parser compatibility suite.json --format json --output-format md --output result.md`,
|
||||
s3-tests-parser compatibility suite.json --format json --output-format md --output result.md
|
||||
s3-tests-parser compatibility suite.json --format json --output-format txt --output result.txt --verbose`,
|
||||
RunE: runCompatibilityCmd,
|
||||
}
|
||||
|
||||
|
@ -149,10 +150,15 @@ func formTestResult(group s3.Group, testsMap map[string]bool) TestResult {
|
|||
var failed []string
|
||||
var passed []string
|
||||
for _, test := range group.Tests {
|
||||
if testsMap[test] {
|
||||
passed = append(passed, test)
|
||||
split := strings.Split(test, "::") // to trim test path
|
||||
if len(split) != 2 {
|
||||
continue
|
||||
}
|
||||
testName := split[1]
|
||||
if testsMap[testName] {
|
||||
passed = append(passed, testName)
|
||||
} else {
|
||||
failed = append(failed, test)
|
||||
failed = append(failed, testName)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -161,6 +167,8 @@ func formTestResult(group s3.Group, testsMap map[string]bool) TestResult {
|
|||
color = templates.BlueColor
|
||||
} else if strings.Contains(group.Comment, "Not applicable") {
|
||||
color = templates.BlackColor
|
||||
} else if ln == 0 && !group.Skip {
|
||||
color = templates.GreenColor
|
||||
}
|
||||
|
||||
if color == "" {
|
||||
|
|
|
@ -45,4 +45,7 @@ GoVersion: {{ runtimeVersion }}
|
|||
|
||||
rootCmd.AddCommand(compatibilityCmd)
|
||||
initCompatibilityCmd()
|
||||
|
||||
rootCmd.AddCommand(testsCmd)
|
||||
initTestsCmd()
|
||||
}
|
||||
|
|
75
cmd/parser/modules/tests.go
Normal file
75
cmd/parser/modules/tests.go
Normal file
|
@ -0,0 +1,75 @@
|
|||
package modules
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"slices"
|
||||
"sort"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/s3-tests-parser/internal/s3"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
var testsCmd = &cobra.Command{
|
||||
Use: "tests",
|
||||
Short: "Print tests to check",
|
||||
Long: "Print all tests that will be checked by 'compatibility' command",
|
||||
Example: `s3-tests-parser tests
|
||||
s3-tests-parser tests --output tests.txt`,
|
||||
RunE: runTestsCmd,
|
||||
}
|
||||
|
||||
func initTestsCmd() {
|
||||
testsCmd.Flags().String(outputFlag, "", "file to write output, if missed the stdout is used")
|
||||
}
|
||||
|
||||
func runTestsCmd(cmd *cobra.Command, _ []string) error {
|
||||
testStruct, err := s3.ParseTestsStruct()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var tests []string
|
||||
|
||||
groupTests := make(map[string][]string)
|
||||
for _, group := range testStruct.Groups {
|
||||
groupTests[group.Name] = group.Tests
|
||||
}
|
||||
|
||||
for _, group := range testStruct.Groups {
|
||||
if group.Skip {
|
||||
continue
|
||||
}
|
||||
|
||||
tests = append(tests, group.Tests...)
|
||||
for _, include := range group.Include {
|
||||
tests = append(tests, groupTests[include]...)
|
||||
}
|
||||
}
|
||||
|
||||
sort.Strings(tests)
|
||||
tests = slices.Compact(tests)
|
||||
|
||||
return printTests(cmd, tests)
|
||||
}
|
||||
|
||||
func printTests(cmd *cobra.Command, res []string) error {
|
||||
w := cmd.OutOrStdout()
|
||||
if outFile := viper.GetString(outputFlag); outFile != "" {
|
||||
f, err := os.Create(outFile)
|
||||
if err != nil {
|
||||
return fmt.Errorf("create out file: %w", err)
|
||||
}
|
||||
w = f
|
||||
defer f.Close()
|
||||
}
|
||||
|
||||
for i := range res {
|
||||
if _, err := fmt.Fprintln(w, res[i]); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
5
go.mod
5
go.mod
|
@ -1,19 +1,22 @@
|
|||
module git.frostfs.info/TrueCloudLab/s3-tests-parser
|
||||
|
||||
go 1.20
|
||||
go 1.22
|
||||
|
||||
require (
|
||||
github.com/spf13/cobra v1.7.0
|
||||
github.com/spf13/viper v1.16.0
|
||||
github.com/stretchr/testify v1.8.3
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/fsnotify/fsnotify v1.6.0 // indirect
|
||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/magiconair/properties v1.8.7 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/spf13/afero v1.9.5 // indirect
|
||||
github.com/spf13/cast v1.5.1 // indirect
|
||||
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
||||
|
|
File diff suppressed because it is too large
Load diff
17
internal/s3/structure_test.go
Normal file
17
internal/s3/structure_test.go
Normal file
|
@ -0,0 +1,17 @@
|
|||
package s3
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestStructParsing(t *testing.T) {
|
||||
structure, err := ParseTestsStruct()
|
||||
require.NoError(t, err)
|
||||
|
||||
for _, group := range structure.Groups {
|
||||
require.NotEmptyf(t, group.Tag, "group tag must not be empty: %v", group)
|
||||
require.NotEmptyf(t, group.Name, "group name must not be empty: %v", group)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue