From 61682a93bdb9bf5f7e9d4f26f15a51a53979031d Mon Sep 17 00:00:00 2001 From: Nuno Cruces Date: Thu, 15 Dec 2022 14:29:56 +0000 Subject: [PATCH] Parallel tests. --- file_filter_test.go | 4 ++++ file_test.go | 3 +++ file_util_test.go | 2 ++ internal/zencmd/markup_test.go | 1 + internal/zencmd/unescape_test.go | 1 + internal/zencmd/window_unix_test.go | 1 + internal/zenutil/color_test.go | 4 ++++ util_test.go | 10 +++++++++- zenity_test.go | 1 + 9 files changed, 26 insertions(+), 1 deletion(-) diff --git a/file_filter_test.go b/file_filter_test.go index 22ae48c..fc5ed4c 100644 --- a/file_filter_test.go +++ b/file_filter_test.go @@ -6,6 +6,7 @@ import ( ) func TestFileFilters_name(t *testing.T) { + t.Parallel() tests := []struct { data FileFilters want string @@ -23,6 +24,7 @@ func TestFileFilters_name(t *testing.T) { } func TestFileFilters_simplify(t *testing.T) { + t.Parallel() tests := []struct { data []string want []string @@ -53,6 +55,7 @@ func TestFileFilters_simplify(t *testing.T) { } func TestFileFilters_casefold(t *testing.T) { + t.Parallel() tests := []struct { data []string want []string @@ -82,6 +85,7 @@ func TestFileFilters_casefold(t *testing.T) { } func TestFileFilters_types(t *testing.T) { + t.Parallel() tests := []struct { data []string want []string diff --git a/file_test.go b/file_test.go index b1c7802..8cafe97 100644 --- a/file_test.go +++ b/file_test.go @@ -122,6 +122,7 @@ func TestSelectFile_script(t *testing.T) { if testing.Short() { t.Skip("skipping test in short mode.") } + t.Run("Cancel", func(t *testing.T) { zenity.Info(fmt.Sprintf("In the file selection dialog, cancel.")) str, err := zenity.SelectFile() @@ -166,6 +167,7 @@ func TestSelectFileMultiple_script(t *testing.T) { if testing.Short() { t.Skip("skipping test in short mode.") } + t.Run("Cancel", func(t *testing.T) { zenity.Info(fmt.Sprintf("In the file selection dialog, cancel.")) lst, err := zenity.SelectFileMultiple() @@ -217,6 +219,7 @@ func TestSelectFileSave_script(t *testing.T) { if testing.Short() { t.Skip("skipping test in short mode.") } + t.Run("Cancel", func(t *testing.T) { zenity.Info(fmt.Sprintf("In the file save dialog, cancel.")) str, err := zenity.SelectFileSave() diff --git a/file_util_test.go b/file_util_test.go index f45909b..84672b2 100644 --- a/file_util_test.go +++ b/file_util_test.go @@ -7,6 +7,8 @@ import ( ) func Test_splitDirAndName(t *testing.T) { + t.Parallel() + tempDir := os.TempDir() tests := []struct { path string diff --git a/internal/zencmd/markup_test.go b/internal/zencmd/markup_test.go index e66b821..f031037 100644 --- a/internal/zencmd/markup_test.go +++ b/internal/zencmd/markup_test.go @@ -28,6 +28,7 @@ var markupTests = []struct { } func TestStripMarkup(t *testing.T) { + t.Parallel() for _, test := range markupTests { if got := StripMarkup(test.data); got != test.want { t.Errorf("StripMarkup(%q) = %q; want %q", test.data, got, test.want) diff --git a/internal/zencmd/unescape_test.go b/internal/zencmd/unescape_test.go index 13fe902..4f06e5b 100644 --- a/internal/zencmd/unescape_test.go +++ b/internal/zencmd/unescape_test.go @@ -44,6 +44,7 @@ var unescapeTests = []struct { } func TestUnescape(t *testing.T) { + t.Parallel() for _, test := range unescapeTests { if got := Unescape(test.data); got != test.want { t.Errorf("Unescape(%q) = %q; want %q", test.data, got, test.want) diff --git a/internal/zencmd/window_unix_test.go b/internal/zencmd/window_unix_test.go index bd82624..4b002b6 100644 --- a/internal/zencmd/window_unix_test.go +++ b/internal/zencmd/window_unix_test.go @@ -8,6 +8,7 @@ import ( ) func TestParseWindowId(t *testing.T) { + t.Parallel() tests := []struct { name string text string diff --git a/internal/zenutil/color_test.go b/internal/zenutil/color_test.go index 25fc577..382d8f5 100644 --- a/internal/zenutil/color_test.go +++ b/internal/zenutil/color_test.go @@ -8,6 +8,7 @@ import ( ) func TestColorEquals(t *testing.T) { + t.Parallel() if 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) { + t.Parallel() for _, name := range colornames.Names { c1 := colornames.Map[name] c2 := ParseColor(name) @@ -52,6 +54,7 @@ func TestColor_names(t *testing.T) { } func TestColor_colors(t *testing.T) { + t.Parallel() colors := []color.Color{ color.Black, color.White, @@ -112,6 +115,7 @@ var colorTests = []struct { } func TestParseColor(t *testing.T) { + t.Parallel() for _, test := range colorTests { c := ParseColor(test.data) if !ColorEquals(c, test.want) { diff --git a/util_test.go b/util_test.go index 2a8f7ab..0fea195 100644 --- a/util_test.go +++ b/util_test.go @@ -11,6 +11,7 @@ import ( ) func Test_quoteAccelerators(t *testing.T) { + t.Parallel() tests := []struct { name string text string @@ -31,6 +32,7 @@ func Test_quoteAccelerators(t *testing.T) { } func Test_appendGeneral(t *testing.T) { + t.Parallel() got := appendGeneral(nil, options{ title: ptr("Title"), attach: 12345, @@ -43,6 +45,7 @@ func Test_appendGeneral(t *testing.T) { } func Test_appendButtons(t *testing.T) { + t.Parallel() tests := []struct { name string opts options @@ -62,6 +65,7 @@ func Test_appendButtons(t *testing.T) { } func Test_appendWidthHeight(t *testing.T) { + t.Parallel() tests := []struct { name string opts options @@ -80,6 +84,7 @@ func Test_appendWidthHeight(t *testing.T) { } func Test_appendWindowIcon(t *testing.T) { + t.Parallel() tests := []struct { name string opts options @@ -105,6 +110,7 @@ func Test_appendWindowIcon(t *testing.T) { func Test_strResult(t *testing.T) { sentinel := errors.New("sentinel") cancel := exit1Cmd().Run() + t.Parallel() if out, err := strResult(options{}, []byte("out"), nil); out != "out" || err != nil { 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) { - zenutil.Separator = "|" sentinel := errors.New("sentinel") cancel := exit1Cmd().Run() + zenutil.Separator = "|" + t.Parallel() if out, err := lstResult(options{}, []byte(""), nil); !reflect.DeepEqual(out, []string{}) || err != nil { t.Errorf(`lstResult("", nil) = %v, %v`, out, err) @@ -143,6 +150,7 @@ func Test_pwdResult(t *testing.T) { username := options{username: true} sentinel := errors.New("sentinel") cancel := exit1Cmd().Run() + t.Parallel() if usr, pwd, err := pwdResult("|", options{}, []byte(""), nil); usr != "" || pwd != "" || err != nil { t.Errorf(`pwdResult("", nil) = %v, %q, %q`, usr, pwd, err) diff --git a/zenity_test.go b/zenity_test.go index 5c3b20b..5daec16 100644 --- a/zenity_test.go +++ b/zenity_test.go @@ -11,6 +11,7 @@ import ( ) func Test_applyOptions(t *testing.T) { + t.Parallel() date := time.Date(2006, 1, 1, 0, 0, 0, 0, time.Local) tests := []struct { name string