Parallel tests.

This commit is contained in:
Nuno Cruces 2022-12-15 14:29:56 +00:00
parent 66863de571
commit 61682a93bd
9 changed files with 26 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import (
) )
func TestFileFilters_name(t *testing.T) { func TestFileFilters_name(t *testing.T) {
t.Parallel()
tests := []struct { tests := []struct {
data FileFilters data FileFilters
want string want string
@ -23,6 +24,7 @@ func TestFileFilters_name(t *testing.T) {
} }
func TestFileFilters_simplify(t *testing.T) { func TestFileFilters_simplify(t *testing.T) {
t.Parallel()
tests := []struct { tests := []struct {
data []string data []string
want []string want []string
@ -53,6 +55,7 @@ func TestFileFilters_simplify(t *testing.T) {
} }
func TestFileFilters_casefold(t *testing.T) { func TestFileFilters_casefold(t *testing.T) {
t.Parallel()
tests := []struct { tests := []struct {
data []string data []string
want []string want []string
@ -82,6 +85,7 @@ func TestFileFilters_casefold(t *testing.T) {
} }
func TestFileFilters_types(t *testing.T) { func TestFileFilters_types(t *testing.T) {
t.Parallel()
tests := []struct { tests := []struct {
data []string data []string
want []string want []string

View File

@ -122,6 +122,7 @@ func TestSelectFile_script(t *testing.T) {
if testing.Short() { if testing.Short() {
t.Skip("skipping test in short mode.") t.Skip("skipping test in short mode.")
} }
t.Run("Cancel", func(t *testing.T) { t.Run("Cancel", func(t *testing.T) {
zenity.Info(fmt.Sprintf("In the file selection dialog, cancel.")) zenity.Info(fmt.Sprintf("In the file selection dialog, cancel."))
str, err := zenity.SelectFile() str, err := zenity.SelectFile()
@ -166,6 +167,7 @@ func TestSelectFileMultiple_script(t *testing.T) {
if testing.Short() { if testing.Short() {
t.Skip("skipping test in short mode.") t.Skip("skipping test in short mode.")
} }
t.Run("Cancel", func(t *testing.T) { t.Run("Cancel", func(t *testing.T) {
zenity.Info(fmt.Sprintf("In the file selection dialog, cancel.")) zenity.Info(fmt.Sprintf("In the file selection dialog, cancel."))
lst, err := zenity.SelectFileMultiple() lst, err := zenity.SelectFileMultiple()
@ -217,6 +219,7 @@ func TestSelectFileSave_script(t *testing.T) {
if testing.Short() { if testing.Short() {
t.Skip("skipping test in short mode.") t.Skip("skipping test in short mode.")
} }
t.Run("Cancel", func(t *testing.T) { t.Run("Cancel", func(t *testing.T) {
zenity.Info(fmt.Sprintf("In the file save dialog, cancel.")) zenity.Info(fmt.Sprintf("In the file save dialog, cancel."))
str, err := zenity.SelectFileSave() str, err := zenity.SelectFileSave()

View File

@ -7,6 +7,8 @@ import (
) )
func Test_splitDirAndName(t *testing.T) { func Test_splitDirAndName(t *testing.T) {
t.Parallel()
tempDir := os.TempDir() tempDir := os.TempDir()
tests := []struct { tests := []struct {
path string path string

View File

@ -28,6 +28,7 @@ var markupTests = []struct {
} }
func TestStripMarkup(t *testing.T) { func TestStripMarkup(t *testing.T) {
t.Parallel()
for _, test := range markupTests { for _, test := range markupTests {
if got := StripMarkup(test.data); got != test.want { if got := StripMarkup(test.data); got != test.want {
t.Errorf("StripMarkup(%q) = %q; want %q", test.data, got, test.want) t.Errorf("StripMarkup(%q) = %q; want %q", test.data, got, test.want)

View File

@ -44,6 +44,7 @@ var unescapeTests = []struct {
} }
func TestUnescape(t *testing.T) { func TestUnescape(t *testing.T) {
t.Parallel()
for _, test := range unescapeTests { for _, test := range unescapeTests {
if got := Unescape(test.data); got != test.want { if got := Unescape(test.data); got != test.want {
t.Errorf("Unescape(%q) = %q; want %q", test.data, got, test.want) t.Errorf("Unescape(%q) = %q; want %q", test.data, got, test.want)

View File

@ -8,6 +8,7 @@ import (
) )
func TestParseWindowId(t *testing.T) { func TestParseWindowId(t *testing.T) {
t.Parallel()
tests := []struct { tests := []struct {
name string name string
text string text string

View File

@ -8,6 +8,7 @@ import (
) )
func TestColorEquals(t *testing.T) { func TestColorEquals(t *testing.T) {
t.Parallel()
if ColorEquals(nil, nil) == false { if ColorEquals(nil, nil) == false {
t.Error("ColorEquals(nil, nil) == false") t.Error("ColorEquals(nil, nil) == false")
} }
@ -38,6 +39,7 @@ func TestColorEquals(t *testing.T) {
} }
func TestColor_names(t *testing.T) { func TestColor_names(t *testing.T) {
t.Parallel()
for _, name := range colornames.Names { for _, name := range colornames.Names {
c1 := colornames.Map[name] c1 := colornames.Map[name]
c2 := ParseColor(name) c2 := ParseColor(name)
@ -52,6 +54,7 @@ func TestColor_names(t *testing.T) {
} }
func TestColor_colors(t *testing.T) { func TestColor_colors(t *testing.T) {
t.Parallel()
colors := []color.Color{ colors := []color.Color{
color.Black, color.Black,
color.White, color.White,
@ -112,6 +115,7 @@ var colorTests = []struct {
} }
func TestParseColor(t *testing.T) { func TestParseColor(t *testing.T) {
t.Parallel()
for _, test := range colorTests { for _, test := range colorTests {
c := ParseColor(test.data) c := ParseColor(test.data)
if !ColorEquals(c, test.want) { if !ColorEquals(c, test.want) {

View File

@ -11,6 +11,7 @@ import (
) )
func Test_quoteAccelerators(t *testing.T) { func Test_quoteAccelerators(t *testing.T) {
t.Parallel()
tests := []struct { tests := []struct {
name string name string
text string text string
@ -31,6 +32,7 @@ func Test_quoteAccelerators(t *testing.T) {
} }
func Test_appendGeneral(t *testing.T) { func Test_appendGeneral(t *testing.T) {
t.Parallel()
got := appendGeneral(nil, options{ got := appendGeneral(nil, options{
title: ptr("Title"), title: ptr("Title"),
attach: 12345, attach: 12345,
@ -43,6 +45,7 @@ func Test_appendGeneral(t *testing.T) {
} }
func Test_appendButtons(t *testing.T) { func Test_appendButtons(t *testing.T) {
t.Parallel()
tests := []struct { tests := []struct {
name string name string
opts options opts options
@ -62,6 +65,7 @@ func Test_appendButtons(t *testing.T) {
} }
func Test_appendWidthHeight(t *testing.T) { func Test_appendWidthHeight(t *testing.T) {
t.Parallel()
tests := []struct { tests := []struct {
name string name string
opts options opts options
@ -80,6 +84,7 @@ func Test_appendWidthHeight(t *testing.T) {
} }
func Test_appendWindowIcon(t *testing.T) { func Test_appendWindowIcon(t *testing.T) {
t.Parallel()
tests := []struct { tests := []struct {
name string name string
opts options opts options
@ -105,6 +110,7 @@ func Test_appendWindowIcon(t *testing.T) {
func Test_strResult(t *testing.T) { func Test_strResult(t *testing.T) {
sentinel := errors.New("sentinel") sentinel := errors.New("sentinel")
cancel := exit1Cmd().Run() cancel := exit1Cmd().Run()
t.Parallel()
if out, err := strResult(options{}, []byte("out"), nil); out != "out" || err != nil { if out, err := strResult(options{}, []byte("out"), nil); out != "out" || err != nil {
t.Errorf(`strResult("out", nil) = %q, %v`, out, err) t.Errorf(`strResult("out", nil) = %q, %v`, out, err)
@ -118,9 +124,10 @@ func Test_strResult(t *testing.T) {
} }
func Test_lstResult(t *testing.T) { func Test_lstResult(t *testing.T) {
zenutil.Separator = "|"
sentinel := errors.New("sentinel") sentinel := errors.New("sentinel")
cancel := exit1Cmd().Run() cancel := exit1Cmd().Run()
zenutil.Separator = "|"
t.Parallel()
if out, err := lstResult(options{}, []byte(""), nil); !reflect.DeepEqual(out, []string{}) || err != nil { if out, err := lstResult(options{}, []byte(""), nil); !reflect.DeepEqual(out, []string{}) || err != nil {
t.Errorf(`lstResult("", nil) = %v, %v`, out, err) t.Errorf(`lstResult("", nil) = %v, %v`, out, err)
@ -143,6 +150,7 @@ func Test_pwdResult(t *testing.T) {
username := options{username: true} username := options{username: true}
sentinel := errors.New("sentinel") sentinel := errors.New("sentinel")
cancel := exit1Cmd().Run() cancel := exit1Cmd().Run()
t.Parallel()
if usr, pwd, err := pwdResult("|", options{}, []byte(""), nil); usr != "" || pwd != "" || err != nil { if usr, pwd, err := pwdResult("|", options{}, []byte(""), nil); usr != "" || pwd != "" || err != nil {
t.Errorf(`pwdResult("", nil) = %v, %q, %q`, usr, pwd, err) t.Errorf(`pwdResult("", nil) = %v, %q, %q`, usr, pwd, err)

View File

@ -11,6 +11,7 @@ import (
) )
func Test_applyOptions(t *testing.T) { func Test_applyOptions(t *testing.T) {
t.Parallel()
date := time.Date(2006, 1, 1, 0, 0, 0, 0, time.Local) date := time.Date(2006, 1, 1, 0, 0, 0, 0, time.Local)
tests := []struct { tests := []struct {
name string name string