Migrate from result methods to function Asserts

Bug: 181070625
Test: m nothing
Change-Id: Iadb85270290acb52c55f2ad70c9f145f1c34b611
This commit is contained in:
Paul Duffin
2021-03-12 11:59:43 +00:00
parent bf6dcccfc4
commit e84b1338c5
5 changed files with 29 additions and 46 deletions

View File

@@ -745,19 +745,3 @@ func (r *TestResult) NormalizePathsForTesting(paths Paths) []string {
func (r *TestResult) Module(name string, variant string) Module {
return r.ModuleForTests(name, variant).Module()
}
// Create a *TestResult object suitable for use within a subtest.
//
// This ensures that any errors reported by the TestResult, e.g. from within one of its
// Assert... methods, will be associated with the sub test and not the main test.
//
// result := ....RunTest()
// t.Run("subtest", func(t *testing.T) {
// subResult := result.ResultForSubTest(t)
// subResult.AssertStringEquals("something", ....)
// })
func (r *TestResult) ResultForSubTest(t *testing.T) *TestResult {
subTestResult := *r
r.T = t
return &subTestResult
}