Commit dbb94f1c by Ben Clayton

Regres: Scan commit message for additional test lists.

Change-Id: Ib0beec96a6efafa0ee6fb8a43e15142206d3cd4d Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/26558Tested-by: 's avatarBen Clayton <bclayton@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent a27f6975
......@@ -290,6 +290,8 @@ func (r *regres) test(change *changeInfo) (string, error) {
return msg, nil
}
var additionalTestsRE = regexp.MustCompile(`\n\s*Test[s]?:\s*([^\s]+)[^\n]*`)
func (r *regres) testLatest(change *changeInfo) (*CommitTestResults, testlist.Lists, error) {
// Get the test results for the latest patchset in the change.
test := r.newTest(change.latest)
......@@ -304,6 +306,29 @@ func (r *regres) testLatest(change *changeInfo) (*CommitTestResults, testlist.Li
return nil, nil, cause.Wrap(err, "Failed to load '%s'", change.latest)
}
if matches := additionalTestsRE.FindAllStringSubmatch(change.commitMessage, -1); len(matches) > 0 {
log.Println("Change description contains additional test patterns")
// Change specifies additional tests to try. Load the full test list.
fullTestLists, err := test.loadTestLists(fullTestListRelPath)
if err != nil {
return nil, nil, cause.Wrap(err, "Failed to load '%s'", change.latest)
}
// Add any tests in the full list that match the pattern to the list to test.
for _, match := range matches {
if len(match) > 1 {
pattern := match[1]
log.Printf("Adding custom tests with pattern '%s'\n", pattern)
filtered := fullTestLists.Filter(func(name string) bool {
ok, _ := filepath.Match(pattern, name)
return ok
})
testlists = append(testlists, filtered...)
}
}
}
cachePath := test.resultsCachePath(testlists)
if results, err := loadCommitTestResults(cachePath); err == nil {
......
......@@ -48,9 +48,36 @@ type Group struct {
Tests []string
}
// Filter returns a new Group that contains only tests that match the predicate.
func (g Group) Filter(pred func(string) bool) Group {
out := Group{
Name: g.Name,
File: g.File,
API: g.API,
}
for _, test := range g.Tests {
if pred(test) {
out.Tests = append(out.Tests, test)
}
}
return out
}
// Lists is the full list of tests to be run.
type Lists []Group
// Filter returns a new Lists that contains only tests that match the predicate.
func (l Lists) Filter(pred func(string) bool) Lists {
out := Lists{}
for _, group := range l {
filtered := group.Filter(pred)
if len(filtered.Tests) > 0 {
out = append(out, filtered)
}
}
return out
}
// Hash returns a SHA1 hash of the set of tests.
func (l Lists) Hash() string {
h := sha1.New()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment