Skip to content

Commit

Permalink
skipgen: sort output
Browse files Browse the repository at this point in the history
Return the list of skips in alphabetical order.

Signed-off-by: Dan Rue <[email protected]>
  • Loading branch information
danrue authored and mwasilew committed Jan 16, 2018
1 parent 2de4271 commit a29be19
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,19 @@ binary.
Show all skips available:

$ skipgen examples/skipfile.yaml
test_verifier
test_tag
test_maps
test_lru_map
test_lpm_map
test_progs
test_align
breakpoint_test_arm64
ftracetest
fw_filesystem.sh
pstore_tests
run.sh
run_fuse_test.sh
run_vmtests
seccomp_bpf
...

Show skips that apply to the x15 board in the production environment and branch 4.4:

./skipgen --board=x15 --environment=staging --branch=4.4 examples/skipfile.yaml
$ skipgen --board=x15 --environment=staging --branch=4.4 examples/skipfile.yaml
run_vmtests
seccomp_bpf

Expand Down
15 changes: 10 additions & 5 deletions skipgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
package main

import (
"flag"
"fmt"
"io/ioutil"
"gopkg.in/yaml.v2"
"flag"
"io/ioutil"
"os"
"sort"
)

// This variable is overwritten during build by goreleaser
Expand Down Expand Up @@ -80,17 +81,21 @@ func parseSkipfile(buf []byte) (Skipfile, error){
// getSkipfileContents returns a string containing a skipfile
// given a board, environment, branch, and Skipfile struct.
func getSkipfileContents(board string, branch string, environment string, skips Skipfile) (string){
var buf string
buf = ""
var skiplist []string
for _, skip := range skips.Skiplist {
if stringInSlice(board, skip.Boards) &&
stringInSlice(branch, skip.Branches) &&
stringInSlice(environment, skip.Environments) {
for _, test := range skip.Tests {
buf = buf + fmt.Sprintf("%s\n", test)
skiplist = append(skiplist, test)
}
}
}
sort.Strings(skiplist)
var buf string
for _, test := range skiplist {
buf = buf + fmt.Sprintf("%s\n", test)
}
return buf
}

Expand Down
6 changes: 3 additions & 3 deletions skipgen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ skiplist:

t.Run("getSkipfileContents", func(t *testing.T) {
if getSkipfileContents("x15", "4.4", "production", skips) !=
`test_maps
test_lru_map
`run_vmtests
test_lpm_map
test_lru_map
test_maps
test_progs
run_vmtests
`{
t.Errorf("Incorrect Skipfile Contents")
}
Expand Down

0 comments on commit a29be19

Please sign in to comment.