Make edit test use subtests to identify flake

This commit is contained in:
Clayton Coleman 2017-11-16 15:45:59 -05:00
parent d77b95723c
commit 5519a7c5e9
No known key found for this signature in database
GPG Key ID: 3D16906B4F1C5CB3

View File

@ -193,7 +193,7 @@ func TestEdit(t *testing.T) {
} }
for _, testcaseName := range testcases.List() { for _, testcaseName := range testcases.List() {
t.Logf("Running testcase: %s", testcaseName) t.Run(testcaseName, func(t *testing.T) {
i = 0 i = 0
name = testcaseName name = testcaseName
testcase = EditTestCase{} testcase = EditTestCase{}
@ -240,8 +240,7 @@ func TestEdit(t *testing.T) {
case "edit-last-applied": case "edit-last-applied":
cmd = NewCmdApplyEditLastApplied(f, buf, errBuf) cmd = NewCmdApplyEditLastApplied(f, buf, errBuf)
default: default:
t.Errorf("%s: unexpected mode %s", name, testcase.Mode) t.Fatalf("%s: unexpected mode %s", name, testcase.Mode)
continue
} }
if len(testcase.Filename) > 0 { if len(testcase.Filename) > 0 {
cmd.Flags().Set("filename", filepath.Join(testcaseDir, testcase.Filename)) cmd.Flags().Set("filename", filepath.Join(testcaseDir, testcase.Filename))
@ -281,6 +280,7 @@ func TestEdit(t *testing.T) {
if i < len(testcase.Steps) { if i < len(testcase.Steps) {
t.Errorf("%s: saw %d steps, testcase included %d additional steps that were not exercised", name, i, len(testcase.Steps)-i) t.Errorf("%s: saw %d steps, testcase included %d additional steps that were not exercised", name, i, len(testcase.Steps)-i)
} }
})
} }
} }