From 7c9b1cb8241522cc2857d1dbd08beb27867a6b8c Mon Sep 17 00:00:00 2001 From: EduardGomezEscandell Date: Thu, 30 Mar 2023 11:02:52 +0200 Subject: [PATCH 1/2] Bugfix: i18n is initialized too late See related issue: https://github.com/ubuntu/adsys/issues/656 --- windows-agent/cmd/ubuntu-pro-agent/main.go | 2 +- wsl-pro-service/cmd/wsl-pro-service/main.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/windows-agent/cmd/ubuntu-pro-agent/main.go b/windows-agent/cmd/ubuntu-pro-agent/main.go index bd7bb5508..0cef47bc5 100644 --- a/windows-agent/cmd/ubuntu-pro-agent/main.go +++ b/windows-agent/cmd/ubuntu-pro-agent/main.go @@ -19,6 +19,7 @@ import ( //go:generate go run ../generate_completion_documentation.go update-doc-cli-ref func main() { + i18n.InitI18nDomain(common.TEXTDOMAIN) a := agent.New() os.Exit(run(a)) } @@ -30,7 +31,6 @@ type app interface { } func run(a app) int { - i18n.InitI18nDomain(common.TEXTDOMAIN) defer installSignalHandler(a)() log.SetFormatter(&log.TextFormatter{ diff --git a/wsl-pro-service/cmd/wsl-pro-service/main.go b/wsl-pro-service/cmd/wsl-pro-service/main.go index 6dea1c079..83014838b 100644 --- a/wsl-pro-service/cmd/wsl-pro-service/main.go +++ b/wsl-pro-service/cmd/wsl-pro-service/main.go @@ -19,6 +19,7 @@ import ( //go:generate go run ../generate_completion_documentation.go update-doc-cli-ref func main() { + i18n.InitI18nDomain(common.TEXTDOMAIN) a := service.New() os.Exit(run(a)) } @@ -30,7 +31,6 @@ type app interface { } func run(a app) int { - i18n.InitI18nDomain(common.TEXTDOMAIN) defer installSignalHandler(a)() log.SetFormatter(&log.TextFormatter{ From c87c1e47e844d9a3e05677dafd34180ac0b92d18 Mon Sep 17 00:00:00 2001 From: EduardGomezEscandell Date: Thu, 30 Mar 2023 11:03:46 +0200 Subject: [PATCH 2/2] Made tests parallel These tests raced against each other due to the i18n initialization in the service. Now that has been moved to main, so there is no race anymore. --- wsl-pro-service/cmd/wsl-pro-service/main_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wsl-pro-service/cmd/wsl-pro-service/main_test.go b/wsl-pro-service/cmd/wsl-pro-service/main_test.go index a2aa2db06..9dd8034c3 100644 --- a/wsl-pro-service/cmd/wsl-pro-service/main_test.go +++ b/wsl-pro-service/cmd/wsl-pro-service/main_test.go @@ -64,6 +64,8 @@ func TestRunSignal(t *testing.T) { } func TestRun(t *testing.T) { + t.Parallel() + tests := map[string]struct { runError bool usageErrorReturn bool @@ -78,6 +80,8 @@ func TestRun(t *testing.T) { for name, tc := range tests { tc := tc t.Run(name, func(t *testing.T) { + t.Parallel() + a := myApp{ done: make(chan struct{}), runError: tc.runError,