From a3c1a1257668d18c210c0a63299466e301f67c27 Mon Sep 17 00:00:00 2001 From: Charles Weill Date: Tue, 8 Nov 2016 12:45:43 -0500 Subject: [PATCH] Revert "Update tests to use subtests." This reverts commit efeb9cff0e4b88d0cf351234f917dd38c6c3894c. --- gotests/process/process_test.go | 12 +++----- gotests_test.go | 54 ++++++++++++++++----------------- 2 files changed, 31 insertions(+), 35 deletions(-) diff --git a/gotests/process/process_test.go b/gotests/process/process_test.go index 31b98d0..2244b9a 100644 --- a/gotests/process/process_test.go +++ b/gotests/process/process_test.go @@ -51,12 +51,10 @@ func TestRun(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - out := &bytes.Buffer{} - Run(out, tt.args, tt.opts) - if got := out.String(); got != tt.want { - t.Errorf("Run() =\n%v, want\n%v", got, tt.want) - } - }) + out := &bytes.Buffer{} + Run(out, tt.args, tt.opts) + if got := out.String(); got != tt.want { + t.Errorf("%q. Run() =\n%v, want\n%v", tt.name, got, tt.want) + } } } diff --git a/gotests_test.go b/gotests_test.go index 4dbfe6b..14fbead 100644 --- a/gotests_test.go +++ b/gotests_test.go @@ -509,35 +509,33 @@ func TestGenerateTests(t *testing.T) { t.Fatalf("ioutil.TempDir: %v", err) } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - gts, err := GenerateTests(tt.args.srcPath, &Options{ - Only: tt.args.only, - Exclude: tt.args.excl, - Exported: tt.args.exported, - PrintInputs: tt.args.printInputs, - Subtests: tt.args.subtests, - Importer: func() types.Importer { return tt.args.importer }, - }) - if (err != nil) != tt.wantErr { - t.Errorf("GenerateTests(%v) error = %v, wantErr %v", tt.args.srcPath, err, tt.wantErr) - return - } - if (len(gts) == 0) != tt.wantNoTests { - t.Errorf("GenerateTests(%v) returned no tests", tt.args.srcPath) - return - } - if (len(gts) > 1) != tt.wantMultipleTests { - t.Errorf("GenerateTests(%v) returned too many tests", tt.args.srcPath) - return - } - if tt.wantNoTests || tt.wantMultipleTests { - return - } - if got := string(gts[0].Output); got != tt.want { - t.Errorf("GenerateTests(%v) = \n%v, want \n%v", tt.args.srcPath, got, tt.want) - outputResult(t, tmp, tt.name, gts[0].Output) - } + gts, err := GenerateTests(tt.args.srcPath, &Options{ + Only: tt.args.only, + Exclude: tt.args.excl, + Exported: tt.args.exported, + PrintInputs: tt.args.printInputs, + Subtests: tt.args.subtests, + Importer: func() types.Importer { return tt.args.importer }, }) + if (err != nil) != tt.wantErr { + t.Errorf("%q. GenerateTests(%v) error = %v, wantErr %v", tt.name, tt.args.srcPath, err, tt.wantErr) + continue + } + if (len(gts) == 0) != tt.wantNoTests { + t.Errorf("%q. GenerateTests(%v) returned no tests", tt.name, tt.args.srcPath) + continue + } + if (len(gts) > 1) != tt.wantMultipleTests { + t.Errorf("%q. GenerateTests(%v) returned too many tests", tt.name, tt.args.srcPath) + continue + } + if tt.wantNoTests || tt.wantMultipleTests { + continue + } + if got := string(gts[0].Output); got != tt.want { + t.Errorf("%q. GenerateTests(%v) = \n%v, want \n%v", tt.name, tt.args.srcPath, got, tt.want) + outputResult(t, tmp, tt.name, gts[0].Output) + } } }