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

List available tests if test is not found #4692

Merged
merged 2 commits into from
Feb 28, 2019
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
20 changes: 15 additions & 5 deletions test.go
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ firstPass:
if ct.Tags == nil {
ct.Tags = []string{}
}
log.Printf("% 32v:\t%v\n", t.name, t.PassTime)
log.Printf("%v:\t%v\n", t.name, t.PassTime)
}
log.Printf("Shard %v total: %v\n", i, time.Duration(sums[i]))
}
Expand All @@ -808,13 +808,13 @@ func getTestsSorted(names []string, testMap map[string]*Test) []*Test {

func selectedTests(args []string, config *Config) []*Test {
var tests []*Test
excluded_tests := strings.Split(*exclude, ",")
excludedTests := strings.Split(*exclude, ",")
if *shard >= 0 {
// Run the tests in a given shard.
// This can be combined with positional args.
var names []string
for name, t := range config.Tests {
if t.Shard == *shard && !t.Manual && (*exclude == "" || !t.hasAnyTag(excluded_tests)) {
if t.Shard == *shard && !t.Manual && (*exclude == "" || !t.hasAnyTag(excludedTests)) {
t.name = name
names = append(names, name)
}
Expand All @@ -826,7 +826,17 @@ func selectedTests(args []string, config *Config) []*Test {
for _, name := range args {
t, ok := config.Tests[name]
if !ok {
log.Fatalf("Unknown test: %v", name)
tests := make([]string, len(config.Tests))

i := 0
for k := range config.Tests {
tests[i] = k
i++
}

sort.Strings(tests)

log.Fatalf("Unknown test: %v\nAvailable tests are: %v", name, strings.Join(tests, ", "))
}
t.name = name
tests = append(tests, t)
Expand All @@ -836,7 +846,7 @@ func selectedTests(args []string, config *Config) []*Test {
// Run all tests.
var names []string
for name, t := range config.Tests {
if !t.Manual && (*tag == "" || t.hasTag(*tag)) && (*exclude == "" || !t.hasAnyTag(excluded_tests)) {
if !t.Manual && (*tag == "" || t.hasTag(*tag)) && (*exclude == "" || !t.hasAnyTag(excludedTests)) {
names = append(names, name)
}
}
Expand Down