Skip to content

Commit

Permalink
Revert "Update tests to use subtests."
Browse files Browse the repository at this point in the history
This reverts commit efeb9cf.
  • Loading branch information
cweill committed Nov 8, 2016
1 parent efeb9cf commit a3c1a12
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 35 deletions.
12 changes: 5 additions & 7 deletions gotests/process/process_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
54 changes: 26 additions & 28 deletions gotests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}

Expand Down

2 comments on commit a3c1a12

@dmitshur
Copy link

@dmitshur dmitshur commented on a3c1a12 Nov 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was that commit reverted?

Was it because subtests are supported in Go 1.7 and newer, but you're trying to support Go 1.6 too?

@cweill
Copy link
Owner Author

@cweill cweill commented on a3c1a12 Nov 13, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly. I broke the Go 1.6 build when I added them, so I rolled back.

Please sign in to comment.