| 1 | // These tests check that the foundations of gocheck are working properly. |
| 2 | // They already assume that fundamental failing is working already, though, |
| 3 | // since this was tested in bootstrap_test.go. Even then, some care may |
| 4 | // still have to be taken when using external functions, since they should |
| 5 | // of course not rely on functionality tested here. |
| 6 | |
| 7 | package check_testscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/ |
| 8 | |
| 9 | import ( |
| 10 | "fmtscip-go gomod github.com/golang/go/src go1.13 fmt/" |
| 11 | "logscip-go gomod github.com/golang/go/src go1.13 log/" |
| 12 | "osscip-go gomod github.com/golang/go/src go1.13 os/" |
| 13 | "regexpscip-go gomod github.com/golang/go/src go1.13 regexp/" |
| 14 | "stringsscip-go gomod github.com/golang/go/src go1.13 strings/" |
| 15 | |
| 16 | "github.com/pingcap/checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/" |
| 17 | ) |
| 18 | |
| 19 | // ----------------------------------------------------------------------- |
| 20 | // Foundation test suite. |
| 21 | |
| 22 | type FoundationSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/FoundationS# struct{} |
| 23 | |
| 24 | var foundationSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/foundationS. = checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Suitescip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/Suite().(&FoundationSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/FoundationS#{}) |
| 25 | |
| 26 | func (s *FoundationSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/FoundationS#) TestCountSuitescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/FoundationS#TestCountSuite().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 27 | suitesRunscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/suitesRun. += 1 |
| 28 | } |
| 29 | |
| 30 | func (s *FoundationSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/FoundationS#) TestErrorfscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/FoundationS#TestErrorf().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 31 | // Do not use checkState() here. It depends on Errorf() working. |
| 32 | expectedLog := fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.13 fmt/Sprintf().("foundation_test.go:%d:\n"+ |
| 33 | " c.Errorf(\"Error %%v!\", \"message\")\n"+ |
| 34 | "... Error: Error message!\n\n", |
| 35 | getMyLinescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/getMyLine().()+1) |
| 36 | c.Errorfscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Errorf().("Error %v!", "message") |
| 37 | failed := c.Failedscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Failed().() |
| 38 | c.Succeedscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Succeed().() |
| 39 | if log := c.GetTestLogscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#GetTestLog().(); log != expectedLog { |
| 40 | c.Logfscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Logf().("Errorf() logged %#v rather than %#v", log, expectedLog) |
| 41 | c.Failscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Fail().() |
| 42 | } |
| 43 | if !failed { |
| 44 | c.Logfscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Logf().("Errorf() didn't put the test in a failed state") |
| 45 | c.Failscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Fail().() |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | func (s *FoundationSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/FoundationS#) TestErrorscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/FoundationS#TestError().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 50 | expectedLog := fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.13 fmt/Sprintf().("foundation_test.go:%d:\n"+ |
| 51 | " c\\.Error\\(\"Error \", \"message!\"\\)\n"+ |
| 52 | "\\.\\.\\. Error: Error message!\n\n", |
| 53 | getMyLinescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/getMyLine().()+1) |
| 54 | c.Errorscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Error().("Error ", "message!") |
| 55 | checkStatescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/checkState().(c, nil, |
| 56 | &expectedStatescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/expectedState#{ |
| 57 | namescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/expectedState#name.: "Error(`Error `, `message!`)", |
| 58 | failedscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/expectedState#failed.: true, |
| 59 | logscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/expectedState#log.: expectedLog, |
| 60 | }) |
| 61 | } |
| 62 | |
| 63 | func (s *FoundationSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/FoundationS#) TestFailNowscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/FoundationS#TestFailNow().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 64 | defer (func() { |
| 65 | if !c.Failedscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Failed().() { |
| 66 | c.Errorscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Error().("FailNow() didn't fail the test") |
| 67 | } else { |
| 68 | c.Succeedscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Succeed().() |
| 69 | if c.GetTestLogscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#GetTestLog().() != "" { |
| 70 | c.Errorscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Error().("Something got logged:\n" + c.GetTestLogscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#GetTestLog().()) |
| 71 | } |
| 72 | } |
| 73 | })() |
| 74 | |
| 75 | c.FailNowscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#FailNow().() |
| 76 | c.Logscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Log().("FailNow() didn't stop the test") |
| 77 | } |
| 78 | |
| 79 | func (s *FoundationSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/FoundationS#) TestSucceedNowscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/FoundationS#TestSucceedNow().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 80 | defer (func() { |
| 81 | if c.Failedscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Failed().() { |
| 82 | c.Errorscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Error().("SucceedNow() didn't succeed the test") |
| 83 | } |
| 84 | if c.GetTestLogscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#GetTestLog().() != "" { |
| 85 | c.Errorscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Error().("Something got logged:\n" + c.GetTestLogscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#GetTestLog().()) |
| 86 | } |
| 87 | })() |
| 88 | |
| 89 | c.Failscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Fail().() |
| 90 | c.SucceedNowscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#SucceedNow().() |
| 91 | c.Logscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Log().("SucceedNow() didn't stop the test") |
| 92 | } |
| 93 | |
| 94 | func (s *FoundationSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/FoundationS#) TestFailureHeaderscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/FoundationS#TestFailureHeader().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 95 | output := Stringscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/String#{} |
| 96 | failHelper := FailHelperscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/FailHelper#{} |
| 97 | checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Runscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/Run().(&failHelper, &checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.RunConfscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/RunConf#{Outputscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/RunConf#Output.: &output}) |
| 98 | header := fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.13 fmt/Sprintf().(""+ |
| 99 | "\n-----------------------------------"+ |
| 100 | "-----------------------------------\n"+ |
| 101 | "FAIL: check_test.go:%d: FailHelper.TestLogAndFail\n", |
| 102 | failHelper.testLinescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/FailHelper#testLine.) |
| 103 | if stringsscip-go gomod github.com/golang/go/src go1.13 strings/.Indexscip-go gomod github.com/golang/go/src go1.13 strings/Index().(output.valuescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/String#value., header) == -1 { |
| 104 | c.Errorfscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Errorf().(""+ |
| 105 | "Failure didn't print a proper header.\n"+ |
| 106 | "... Got:\n%s... Expected something with:\n%s", |
| 107 | output.valuescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/String#value., header) |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | func (s *FoundationSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/FoundationS#) TestFatalscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/FoundationS#TestFatal().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 112 | var line int |
| 113 | defer (func() { |
| 114 | if !c.Failedscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Failed().() { |
| 115 | c.Errorscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Error().("Fatal() didn't fail the test") |
| 116 | } else { |
| 117 | c.Succeedscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Succeed().() |
| 118 | expected := fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.13 fmt/Sprintf().("foundation_test.go:%d:\n"+ |
| 119 | " c.Fatal(\"Die \", \"now!\")\n"+ |
| 120 | "... Error: Die now!\n\n", |
| 121 | line) |
| 122 | if c.GetTestLogscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#GetTestLog().() != expected { |
| 123 | c.Errorscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Error().("Incorrect log:", c.GetTestLogscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#GetTestLog().()) |
| 124 | } |
| 125 | } |
| 126 | })() |
| 127 | |
| 128 | line = getMyLinescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/getMyLine().() + 1 |
| 129 | c.Fatalscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Fatal().("Die ", "now!") |
| 130 | c.Logscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Log().("Fatal() didn't stop the test") |
| 131 | } |
| 132 | |
| 133 | func (s *FoundationSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/FoundationS#) TestFatalfscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/FoundationS#TestFatalf().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 134 | var line int |
| 135 | defer (func() { |
| 136 | if !c.Failedscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Failed().() { |
| 137 | c.Errorscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Error().("Fatalf() didn't fail the test") |
| 138 | } else { |
| 139 | c.Succeedscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Succeed().() |
| 140 | expected := fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.13 fmt/Sprintf().("foundation_test.go:%d:\n"+ |
| 141 | " c.Fatalf(\"Die %%s!\", \"now\")\n"+ |
| 142 | "... Error: Die now!\n\n", |
| 143 | line) |
| 144 | if c.GetTestLogscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#GetTestLog().() != expected { |
| 145 | c.Errorscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Error().("Incorrect log:", c.GetTestLogscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#GetTestLog().()) |
| 146 | } |
| 147 | } |
| 148 | })() |
| 149 | |
| 150 | line = getMyLinescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/getMyLine().() + 1 |
| 151 | c.Fatalfscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Fatalf().("Die %s!", "now") |
| 152 | c.Logscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Log().("Fatalf() didn't stop the test") |
| 153 | } |
| 154 | |
| 155 | func (s *FoundationSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/FoundationS#) TestCallerLoggingInsideTestscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/FoundationS#TestCallerLoggingInsideTest().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 156 | log := fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.13 fmt/Sprintf().(""+ |
| 157 | "foundation_test.go:%d:\n"+ |
| 158 | " result := c.Check\\(10, check.Equals, 20\\)\n"+ |
| 159 | "\\.\\.\\. obtained int = 10\n"+ |
| 160 | "\\.\\.\\. expected int = 20\n\n", |
| 161 | getMyLinescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/getMyLine().()+1) |
| 162 | result := c.Checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Check().(10, checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Equalsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/Equals., 20) |
| 163 | checkStatescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/checkState().(c, result, |
| 164 | &expectedStatescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/expectedState#{ |
| 165 | namescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/expectedState#name.: "Check(10, Equals, 20)", |
| 166 | resultscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/expectedState#result.: false, |
| 167 | failedscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/expectedState#failed.: true, |
| 168 | logscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/expectedState#log.: log, |
| 169 | }) |
| 170 | } |
| 171 | |
| 172 | func (s *FoundationSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/FoundationS#) TestCallerLoggingInDifferentFilescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/FoundationS#TestCallerLoggingInDifferentFile().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 173 | result, line := checkEqualWrapperscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/checkEqualWrapper().(c, 10, 20) |
| 174 | testLine := getMyLinescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/getMyLine().() - 1 |
| 175 | log := fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.13 fmt/Sprintf().(""+ |
| 176 | "foundation_test.go:%d:\n"+ |
| 177 | " result, line := checkEqualWrapper\\(c, 10, 20\\)\n"+ |
| 178 | "check_test.go:%d:\n"+ |
| 179 | " return c.Check\\(obtained, check.Equals, expected\\), getMyLine\\(\\)\n"+ |
| 180 | "\\.\\.\\. obtained int = 10\n"+ |
| 181 | "\\.\\.\\. expected int = 20\n\n", |
| 182 | testLine, line) |
| 183 | checkStatescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/checkState().(c, result, |
| 184 | &expectedStatescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/expectedState#{ |
| 185 | namescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/expectedState#name.: "Check(10, Equals, 20)", |
| 186 | resultscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/expectedState#result.: false, |
| 187 | failedscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/expectedState#failed.: true, |
| 188 | logscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/expectedState#log.: log, |
| 189 | }) |
| 190 | } |
| 191 | |
| 192 | // ----------------------------------------------------------------------- |
| 193 | // ExpectFailure() inverts the logic of failure. |
| 194 | |
| 195 | type ExpectFailureSucceedHelperscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/ExpectFailureSucceedHelper# struct{} |
| 196 | |
| 197 | func (s *ExpectFailureSucceedHelperscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/ExpectFailureSucceedHelper#) TestSucceedscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/ExpectFailureSucceedHelper#TestSucceed().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 198 | c.ExpectFailurescip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#ExpectFailure().("It booms!") |
| 199 | c.Errorscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Error().("Boom!") |
| 200 | } |
| 201 | |
| 202 | type ExpectFailureFailHelperscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/ExpectFailureFailHelper# struct{} |
| 203 | |
| 204 | func (s *ExpectFailureFailHelperscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/ExpectFailureFailHelper#) TestFailscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/ExpectFailureFailHelper#TestFail().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 205 | c.ExpectFailurescip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#ExpectFailure().("Bug #XYZ") |
| 206 | } |
| 207 | |
| 208 | func (s *FoundationSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/FoundationS#) TestExpectFailureFailscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/FoundationS#TestExpectFailureFail().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 209 | helper := ExpectFailureFailHelperscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/ExpectFailureFailHelper#{} |
| 210 | output := Stringscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/String#{} |
| 211 | result := checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Runscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/Run().(&helper, &checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.RunConfscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/RunConf#{Outputscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/RunConf#Output.: &output}) |
| 212 | |
| 213 | expected := "" + |
| 214 | "^\n-+\n" + |
| 215 | "FAIL: foundation_test\\.go:[0-9]+:" + |
| 216 | " ExpectFailureFailHelper\\.TestFail\n\n" + |
| 217 | "\\.\\.\\. Error: Test succeeded, but was expected to fail\n" + |
| 218 | "\\.\\.\\. Reason: Bug #XYZ\n$" |
| 219 | |
| 220 | matched, err := regexpscip-go gomod github.com/golang/go/src go1.13 regexp/.MatchStringscip-go gomod github.com/golang/go/src go1.13 regexp/MatchString().(expected, output.valuescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/String#value.) |
| 221 | if err != nil { |
| 222 | c.Errorscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Error().("Bad expression: ", expected) |
| 223 | } else if !matched { |
| 224 | c.Errorscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Error().("ExpectFailure() didn't log properly:\n", output.valuescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/String#value.) |
| 225 | } |
| 226 | |
| 227 | c.Assertscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Assert().(result.ExpectedFailuresscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/Result#ExpectedFailures., checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Equalsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/Equals., 0) |
| 228 | } |
| 229 | |
| 230 | func (s *FoundationSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/FoundationS#) TestExpectFailureSucceedscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/FoundationS#TestExpectFailureSucceed().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 231 | helper := ExpectFailureSucceedHelperscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/ExpectFailureSucceedHelper#{} |
| 232 | output := Stringscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/String#{} |
| 233 | result := checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Runscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/Run().(&helper, &checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.RunConfscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/RunConf#{Outputscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/RunConf#Output.: &output}) |
| 234 | |
| 235 | c.Assertscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Assert().(output.valuescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/String#value., checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Equalsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/Equals., "") |
| 236 | c.Assertscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Assert().(result.ExpectedFailuresscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/Result#ExpectedFailures., checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Equalsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/Equals., 1) |
| 237 | } |
| 238 | |
| 239 | func (s *FoundationSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/FoundationS#) TestExpectFailureSucceedVerbosescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/FoundationS#TestExpectFailureSucceedVerbose().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 240 | helper := ExpectFailureSucceedHelperscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/ExpectFailureSucceedHelper#{} |
| 241 | output := Stringscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/String#{} |
| 242 | result := checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Runscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/Run().(&helper, &checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.RunConfscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/RunConf#{Outputscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/RunConf#Output.: &output, Verbosescip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/RunConf#Verbose.: true}) |
| 243 | |
| 244 | expected := "" + |
| 245 | "FAIL EXPECTED: foundation_test\\.go:[0-9]+:" + |
| 246 | " ExpectFailureSucceedHelper\\.TestSucceed \\(It booms!\\)\t *[.0-9]+s\n" |
| 247 | |
| 248 | matched, err := regexpscip-go gomod github.com/golang/go/src go1.13 regexp/.MatchStringscip-go gomod github.com/golang/go/src go1.13 regexp/MatchString().(expected, output.valuescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/String#value.) |
| 249 | if err != nil { |
| 250 | c.Errorscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Error().("Bad expression: ", expected) |
| 251 | } else if !matched { |
| 252 | c.Errorscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Error().("ExpectFailure() didn't log properly:\n", output.valuescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/String#value.) |
| 253 | } |
| 254 | |
| 255 | c.Assertscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Assert().(result.ExpectedFailuresscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/Result#ExpectedFailures., checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Equalsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/Equals., 1) |
| 256 | } |
| 257 | |
| 258 | // ----------------------------------------------------------------------- |
| 259 | // Skip() allows stopping a test without positive/negative results. |
| 260 | |
| 261 | type SkipTestHelperscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/SkipTestHelper# struct{} |
| 262 | |
| 263 | func (s *SkipTestHelperscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/SkipTestHelper#) TestFailscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/SkipTestHelper#TestFail().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 264 | c.Skipscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Skip().("Wrong platform or whatever") |
| 265 | c.Errorscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Error().("Boom!") |
| 266 | } |
| 267 | |
| 268 | func (s *FoundationSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/FoundationS#) TestSkipscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/FoundationS#TestSkip().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 269 | helper := SkipTestHelperscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/SkipTestHelper#{} |
| 270 | output := Stringscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/String#{} |
| 271 | checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Runscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/Run().(&helper, &checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.RunConfscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/RunConf#{Outputscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/RunConf#Output.: &output}) |
| 272 | |
| 273 | if output.valuescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/String#value. != "" { |
| 274 | c.Errorscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Error().("Skip() logged something:\n", output.valuescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/String#value.) |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | func (s *FoundationSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/FoundationS#) TestSkipVerbosescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/FoundationS#TestSkipVerbose().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 279 | helper := SkipTestHelperscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/SkipTestHelper#{} |
| 280 | output := Stringscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/String#{} |
| 281 | checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Runscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/Run().(&helper, &checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.RunConfscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/RunConf#{Outputscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/RunConf#Output.: &output, Verbosescip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/RunConf#Verbose.: true}) |
| 282 | |
| 283 | expected := "SKIP: foundation_test\\.go:[0-9]+: SkipTestHelper\\.TestFail" + |
| 284 | " \\(Wrong platform or whatever\\)" |
| 285 | matched, err := regexpscip-go gomod github.com/golang/go/src go1.13 regexp/.MatchStringscip-go gomod github.com/golang/go/src go1.13 regexp/MatchString().(expected, output.valuescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/String#value.) |
| 286 | if err != nil { |
| 287 | c.Errorscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Error().("Bad expression: ", expected) |
| 288 | } else if !matched { |
| 289 | c.Errorscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Error().("Skip() didn't log properly:\n", output.valuescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/String#value.) |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | // ----------------------------------------------------------------------- |
| 294 | // Check minimum *log.Logger interface provided by *check.C. |
| 295 | |
| 296 | type minLoggerscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/minLogger# interface { |
| 297 | Outputscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/minLogger#Output.(calldepth int, s string) error |
| 298 | } |
| 299 | |
| 300 | func (s *BootstrapSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/BootstrapS#) TestMinLoggerscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/BootstrapS#TestMinLogger().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 301 | var logger minLoggerscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/minLogger# |
| 302 | logger = logscip-go gomod github.com/golang/go/src go1.13 log/.Newscip-go gomod github.com/golang/go/src go1.13 log/New().(osscip-go gomod github.com/golang/go/src go1.13 os/.Stderrscip-go gomod github.com/golang/go/src go1.13 os/Stderr., "", 0) |
| 303 | logger = c |
| 304 | logger.Outputscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/minLogger#Output.(0, "Hello there") |
| 305 | expected := `\[LOG\] [0-9]+:[0-9][0-9]\.[0-9][0-9][0-9] +Hello there\n` |
| 306 | output := c.GetTestLogscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#GetTestLog().() |
| 307 | c.Assertscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Assert().(output, checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Matchesscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/Matches., expected) |
| 308 | } |
| 309 | |
| 310 | // ----------------------------------------------------------------------- |
| 311 | // Ensure that suites with embedded types are working fine, including the |
| 312 | // the workaround for issue 906. |
| 313 | |
| 314 | type EmbeddedInternalSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/EmbeddedInternalS# struct { |
| 315 | calledscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/EmbeddedInternalS#called. bool |
| 316 | } |
| 317 | |
| 318 | type EmbeddedSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/EmbeddedS# struct { |
| 319 | EmbeddedInternalSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/EmbeddedS#EmbeddedInternalS. |
| 320 | } |
| 321 | |
| 322 | var embeddedSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/embeddedS. = checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Suitescip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/Suite().(&EmbeddedSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/EmbeddedS#{}) |
| 323 | |
| 324 | func (s *EmbeddedSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/EmbeddedS#) TestCountSuitescip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/EmbeddedS#TestCountSuite().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 325 | suitesRunscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/suitesRun. += 1 |
| 326 | } |
| 327 | |
| 328 | func (s *EmbeddedInternalSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/EmbeddedInternalS#) TestMethodscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/EmbeddedInternalS#TestMethod().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 329 | c.Errorscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Error().("TestMethod() of the embedded type was called!?") |
| 330 | } |
| 331 | |
| 332 | func (s *EmbeddedSscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/EmbeddedS#) TestMethodscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/EmbeddedS#TestMethod().(c *checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Cscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#) { |
| 333 | // http://code.google.com/p/go/issues/detail?id=906 |
| 334 | c.Checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/C#Check().(s.calledscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/EmbeddedInternalS#called., checkscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/.Equalsscip-go gomod github.com/pingcap/check . `github.com/pingcap/check`/Equals., false) // Go issue 906 is affecting the runner? |
| 335 | s.calledscip-go gomod github.com/pingcap/check . `github.com/pingcap/check_test`/EmbeddedInternalS#called. = true |
| 336 | } |