From a0a753c8cdcec7c42c2ef6fc111cfe6003f68f20 Mon Sep 17 00:00:00 2001 From: i4k Date: Thu, 26 Sep 2024 01:20:05 +0100 Subject: [PATCH] chore: generate Go boilerplate to disable logging in tests. Signed-off-by: i4k --- cloud/deployment/loglevel_disable_test.go | 10 +++++ cloud/drift/loglevel_disable_test.go | 10 +++++ .../loglevel_disable_test.go | 2 +- cloud/preview/loglevel_disable_test.go | 10 +++++ .../stack/loglevel_disable_test.go | 2 +- .../cloudstore/loglevel_disable_test.go | 10 +++++ cloud/testserver/loglevel_disable_test.go | 10 +++++ cmd/terramate/cli/cliconfig/cliconfig_test.go | 5 --- .../cli/cliconfig/loglevel_disable_test.go | 4 +- .../cli/github/loglevel_disable_test.go | 10 +++++ .../cli/gitlab/loglevel_disable_test.go | 10 +++++ .../cli/out/loglevel_disable_test.go | 10 +++++ config/config_test.go | 5 --- config/filter/loglevel_disable_test.go | 10 +++++ config/loglevel_disable_test.go | 10 +++++ e2etests/cloud/loglevel_disable_test.go | 10 +++++ ...level_test.go => loglevel_disable_test.go} | 2 +- errors/loglevel_disable_test.go | 10 +++++ event/loglevel_disable_test.go | 10 +++++ fs/copy_test.go | 5 --- fs/loglevel_disable_test.go | 10 +++++ generate/generate_test.go | 5 --- generate/genfile/genfile_test.go | 5 --- generate/genfile/loglevel_disable_test.go | 10 +++++ generate/genhcl/genhcl_test.go | 5 --- generate/genhcl/loglevel_disable_test.go | 10 +++++ generate/loglevel_disable_test.go | 10 +++++ generate_golang.tm | 38 +++++++++++++++++++ golangci.tm => generate_golangci.tm | 0 ...ate_preview.tm => generate_mock_preview.tm | 5 +-- git/git_test.go | 5 --- git/loglevel_disable_test.go | 10 +++++ globals/globals_test.go | 5 --- globals/loglevel_disable_test.go | 10 +++++ hcl/ast/expression_fuzz_test.go | 5 --- hcl/ast/loglevel_disable_test.go | 10 +++++ hcl/eval/loglevel_disable_test.go | 10 +++++ hcl/eval/partial_fuzz_test.go | 5 --- hcl/fmt/fmt_fuzz_test.go | 5 --- hcl/fmt/loglevel_disable_test.go | 10 +++++ hcl/hcl_test.go | 5 --- hcl/info/loglevel_disable_test.go | 10 +++++ hcl/loglevel_disable_test.go | 10 +++++ ls/loglevel_disable_test.go | 10 +++++ ls/ls_test.go | 5 --- modvendor/download/download_test.go | 5 --- modvendor/download/loglevel_disable_test.go | 10 +++++ printer/loglevel_disable_test.go | 10 +++++ project/loglevel_disable_test.go | 10 +++++ run/dag/dag_test.go | 6 --- run/dag/loglevel_disable_test.go | 10 +++++ run/env_test.go | 5 --- run/loglevel_disable_test.go | 10 +++++ scheduler/loglevel_disable_test.go | 10 +++++ stack/loglevel_disable_test.go | 10 +++++ stack/stack_test.go | 5 --- stack/trigger/loglevel_disable_test.go | 10 +++++ stack/trigger/trigger_test.go | 5 --- stdlib/funcs_test.go | 5 --- stdlib/loglevel_disable_test.go | 10 +++++ test/git_test.go | 5 --- test/hclwrite/hclwrite_test.go | 5 --- test/hclwrite/loglevel_disable_test.go | 10 +++++ test/loglevel_disable_test.go | 10 +++++ test/ls/doc.go | 4 +- test/ls/editor.go | 7 +--- test/ls/fixture.go | 2 +- test/sandbox/git_test.go | 5 --- test/sandbox/loglevel_disable_test.go | 10 +++++ tf/loglevel_disable_test.go | 10 +++++ tf/terraform_test.go | 5 --- ...level_test.go => loglevel_disable_test.go} | 2 +- versions/loglevel_disable_test.go | 10 +++++ 73 files changed, 439 insertions(+), 135 deletions(-) create mode 100644 cloud/deployment/loglevel_disable_test.go create mode 100644 cloud/drift/loglevel_disable_test.go rename e2etests/cloud/loglevel_test.go => cloud/loglevel_disable_test.go (81%) create mode 100644 cloud/preview/loglevel_disable_test.go rename stack/loglevel_test.go => cloud/stack/loglevel_disable_test.go (81%) create mode 100644 cloud/testserver/cloudstore/loglevel_disable_test.go create mode 100644 cloud/testserver/loglevel_disable_test.go rename loglevel_test.go => cmd/terramate/cli/cliconfig/loglevel_disable_test.go (69%) create mode 100644 cmd/terramate/cli/github/loglevel_disable_test.go create mode 100644 cmd/terramate/cli/gitlab/loglevel_disable_test.go create mode 100644 cmd/terramate/cli/out/loglevel_disable_test.go create mode 100644 config/filter/loglevel_disable_test.go create mode 100644 config/loglevel_disable_test.go create mode 100644 e2etests/cloud/loglevel_disable_test.go rename e2etests/core/{disable_loglevel_test.go => loglevel_disable_test.go} (81%) create mode 100644 errors/loglevel_disable_test.go create mode 100644 event/loglevel_disable_test.go create mode 100644 fs/loglevel_disable_test.go create mode 100644 generate/genfile/loglevel_disable_test.go create mode 100644 generate/genhcl/loglevel_disable_test.go create mode 100644 generate/loglevel_disable_test.go create mode 100644 generate_golang.tm rename golangci.tm => generate_golangci.tm (100%) rename generate_preview.tm => generate_mock_preview.tm (80%) create mode 100644 git/loglevel_disable_test.go create mode 100644 globals/loglevel_disable_test.go create mode 100644 hcl/ast/loglevel_disable_test.go create mode 100644 hcl/eval/loglevel_disable_test.go create mode 100644 hcl/fmt/loglevel_disable_test.go create mode 100644 hcl/info/loglevel_disable_test.go create mode 100644 hcl/loglevel_disable_test.go create mode 100644 ls/loglevel_disable_test.go create mode 100644 modvendor/download/loglevel_disable_test.go create mode 100644 printer/loglevel_disable_test.go create mode 100644 project/loglevel_disable_test.go create mode 100644 run/dag/loglevel_disable_test.go create mode 100644 run/loglevel_disable_test.go create mode 100644 scheduler/loglevel_disable_test.go create mode 100644 stack/loglevel_disable_test.go create mode 100644 stack/trigger/loglevel_disable_test.go create mode 100644 stdlib/loglevel_disable_test.go create mode 100644 test/hclwrite/loglevel_disable_test.go create mode 100644 test/loglevel_disable_test.go create mode 100644 test/sandbox/loglevel_disable_test.go create mode 100644 tf/loglevel_disable_test.go rename tg/{logging_level_test.go => loglevel_disable_test.go} (81%) create mode 100644 versions/loglevel_disable_test.go diff --git a/cloud/deployment/loglevel_disable_test.go b/cloud/deployment/loglevel_disable_test.go new file mode 100644 index 000000000..20b77260e --- /dev/null +++ b/cloud/deployment/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package deployment_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/cloud/drift/loglevel_disable_test.go b/cloud/drift/loglevel_disable_test.go new file mode 100644 index 000000000..6f7c7db5f --- /dev/null +++ b/cloud/drift/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package drift_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/e2etests/cloud/loglevel_test.go b/cloud/loglevel_disable_test.go similarity index 81% rename from e2etests/cloud/loglevel_test.go rename to cloud/loglevel_disable_test.go index 7f6adc001..7bf79bb8f 100644 --- a/e2etests/cloud/loglevel_test.go +++ b/cloud/loglevel_disable_test.go @@ -1,4 +1,4 @@ -// Copyright 2023 Terramate GmbH +// Copyright 2024 Terramate GmbH // SPDX-License-Identifier: MPL-2.0 package cloud_test diff --git a/cloud/preview/loglevel_disable_test.go b/cloud/preview/loglevel_disable_test.go new file mode 100644 index 000000000..888fa4c90 --- /dev/null +++ b/cloud/preview/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package preview_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/stack/loglevel_test.go b/cloud/stack/loglevel_disable_test.go similarity index 81% rename from stack/loglevel_test.go rename to cloud/stack/loglevel_disable_test.go index 50fb7dd29..735a5053f 100644 --- a/stack/loglevel_test.go +++ b/cloud/stack/loglevel_disable_test.go @@ -1,4 +1,4 @@ -// Copyright 2023 Terramate GmbH +// Copyright 2024 Terramate GmbH // SPDX-License-Identifier: MPL-2.0 package stack_test diff --git a/cloud/testserver/cloudstore/loglevel_disable_test.go b/cloud/testserver/cloudstore/loglevel_disable_test.go new file mode 100644 index 000000000..9a95b7ab4 --- /dev/null +++ b/cloud/testserver/cloudstore/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package cloudstore_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/cloud/testserver/loglevel_disable_test.go b/cloud/testserver/loglevel_disable_test.go new file mode 100644 index 000000000..c0ef43e2b --- /dev/null +++ b/cloud/testserver/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package testserver_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/cmd/terramate/cli/cliconfig/cliconfig_test.go b/cmd/terramate/cli/cliconfig/cliconfig_test.go index b98078e92..0771c42ad 100644 --- a/cmd/terramate/cli/cliconfig/cliconfig_test.go +++ b/cmd/terramate/cli/cliconfig/cliconfig_test.go @@ -7,7 +7,6 @@ import ( "testing" "github.com/madlambda/spells/assert" - "github.com/rs/zerolog" "github.com/terramate-io/terramate/cmd/terramate/cli/cliconfig" "github.com/terramate-io/terramate/errors" "github.com/terramate-io/terramate/hcl" @@ -158,7 +157,3 @@ func TestLoad(t *testing.T) { }) } } - -func init() { - zerolog.SetGlobalLevel(zerolog.Disabled) -} diff --git a/loglevel_test.go b/cmd/terramate/cli/cliconfig/loglevel_disable_test.go similarity index 69% rename from loglevel_test.go rename to cmd/terramate/cli/cliconfig/loglevel_disable_test.go index b2f041690..ff6a536f0 100644 --- a/loglevel_test.go +++ b/cmd/terramate/cli/cliconfig/loglevel_disable_test.go @@ -1,7 +1,7 @@ -// Copyright 2023 Terramate GmbH +// Copyright 2024 Terramate GmbH // SPDX-License-Identifier: MPL-2.0 -package terramate_test +package cliconfig_test import "github.com/rs/zerolog" diff --git a/cmd/terramate/cli/github/loglevel_disable_test.go b/cmd/terramate/cli/github/loglevel_disable_test.go new file mode 100644 index 000000000..b1787719f --- /dev/null +++ b/cmd/terramate/cli/github/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package github_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/cmd/terramate/cli/gitlab/loglevel_disable_test.go b/cmd/terramate/cli/gitlab/loglevel_disable_test.go new file mode 100644 index 000000000..97f825c72 --- /dev/null +++ b/cmd/terramate/cli/gitlab/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package gitlab_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/cmd/terramate/cli/out/loglevel_disable_test.go b/cmd/terramate/cli/out/loglevel_disable_test.go new file mode 100644 index 000000000..9e1cefa2b --- /dev/null +++ b/cmd/terramate/cli/out/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package out_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/config/config_test.go b/config/config_test.go index 96cc0244f..92740af72 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -9,7 +9,6 @@ import ( "testing" "github.com/madlambda/spells/assert" - "github.com/rs/zerolog" "github.com/terramate-io/terramate/config" "github.com/terramate-io/terramate/errors" "github.com/terramate-io/terramate/project" @@ -333,7 +332,3 @@ func TestConfigSkipdir(t *testing.T) { func isStack(root *config.Root, dir string) bool { return config.IsStack(root, filepath.Join(root.HostDir(), dir)) } - -func init() { - zerolog.SetGlobalLevel(zerolog.Disabled) -} diff --git a/config/filter/loglevel_disable_test.go b/config/filter/loglevel_disable_test.go new file mode 100644 index 000000000..eb01ae489 --- /dev/null +++ b/config/filter/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package filter_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/config/loglevel_disable_test.go b/config/loglevel_disable_test.go new file mode 100644 index 000000000..fb3be465a --- /dev/null +++ b/config/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package config_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/e2etests/cloud/loglevel_disable_test.go b/e2etests/cloud/loglevel_disable_test.go new file mode 100644 index 000000000..7bf79bb8f --- /dev/null +++ b/e2etests/cloud/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package cloud_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/e2etests/core/disable_loglevel_test.go b/e2etests/core/loglevel_disable_test.go similarity index 81% rename from e2etests/core/disable_loglevel_test.go rename to e2etests/core/loglevel_disable_test.go index 4d9e8e96a..8e42735f1 100644 --- a/e2etests/core/disable_loglevel_test.go +++ b/e2etests/core/loglevel_disable_test.go @@ -1,4 +1,4 @@ -// Copyright 2023 Terramate GmbH +// Copyright 2024 Terramate GmbH // SPDX-License-Identifier: MPL-2.0 package core_test diff --git a/errors/loglevel_disable_test.go b/errors/loglevel_disable_test.go new file mode 100644 index 000000000..09489d15f --- /dev/null +++ b/errors/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package errors_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/event/loglevel_disable_test.go b/event/loglevel_disable_test.go new file mode 100644 index 000000000..ffa2113d6 --- /dev/null +++ b/event/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package event_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/fs/copy_test.go b/fs/copy_test.go index e59b57a2c..d37469668 100644 --- a/fs/copy_test.go +++ b/fs/copy_test.go @@ -9,7 +9,6 @@ import ( "testing" "github.com/madlambda/spells/assert" - "github.com/rs/zerolog" "github.com/terramate-io/terramate/fs" "github.com/terramate-io/terramate/test" "github.com/terramate-io/terramate/test/sandbox" @@ -56,7 +55,3 @@ func TestCopyIfAllFilesAreFilteredDirIsNotCreated(t *testing.T) { } } } - -func init() { - zerolog.SetGlobalLevel(zerolog.Disabled) -} diff --git a/fs/loglevel_disable_test.go b/fs/loglevel_disable_test.go new file mode 100644 index 000000000..74615909b --- /dev/null +++ b/fs/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package fs_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/generate/generate_test.go b/generate/generate_test.go index 6fd43b3e9..f52501bc6 100644 --- a/generate/generate_test.go +++ b/generate/generate_test.go @@ -13,7 +13,6 @@ import ( "testing" "github.com/madlambda/spells/assert" - "github.com/rs/zerolog" "github.com/terramate-io/terramate/config" "github.com/terramate-io/terramate/errors" "github.com/terramate-io/terramate/generate" @@ -1201,7 +1200,3 @@ func assertEqualStringList(t *testing.T, got []string, want []string) { t.Fatalf("got %v != want %v", got, want) } } - -func init() { - zerolog.SetGlobalLevel(zerolog.Disabled) -} diff --git a/generate/genfile/genfile_test.go b/generate/genfile/genfile_test.go index 687afe485..33dc22804 100644 --- a/generate/genfile/genfile_test.go +++ b/generate/genfile/genfile_test.go @@ -8,7 +8,6 @@ import ( "testing" "github.com/madlambda/spells/assert" - "github.com/rs/zerolog" "github.com/terramate-io/terramate/config" "github.com/terramate-io/terramate/errors" "github.com/terramate-io/terramate/generate/genfile" @@ -1020,7 +1019,3 @@ func testGenfile(t *testing.T, tcase testcase) { } }) } - -func init() { - zerolog.SetGlobalLevel(zerolog.Disabled) -} diff --git a/generate/genfile/loglevel_disable_test.go b/generate/genfile/loglevel_disable_test.go new file mode 100644 index 000000000..eb01294d5 --- /dev/null +++ b/generate/genfile/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package genfile_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/generate/genhcl/genhcl_test.go b/generate/genhcl/genhcl_test.go index 010064998..9e9c4c5a6 100644 --- a/generate/genhcl/genhcl_test.go +++ b/generate/genhcl/genhcl_test.go @@ -11,7 +11,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/madlambda/spells/assert" - "github.com/rs/zerolog" "github.com/terramate-io/terramate/config" "github.com/terramate-io/terramate/errors" "github.com/terramate-io/terramate/generate/genhcl" @@ -1956,7 +1955,3 @@ func assertHCLEquals(t *testing.T, got string, want string) { t.Fatalf("diff:\n%s", diff) } } - -func init() { - zerolog.SetGlobalLevel(zerolog.Disabled) -} diff --git a/generate/genhcl/loglevel_disable_test.go b/generate/genhcl/loglevel_disable_test.go new file mode 100644 index 000000000..4205f3dab --- /dev/null +++ b/generate/genhcl/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package genhcl_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/generate/loglevel_disable_test.go b/generate/loglevel_disable_test.go new file mode 100644 index 000000000..d034ea3c8 --- /dev/null +++ b/generate/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package generate_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/generate_golang.tm b/generate_golang.tm new file mode 100644 index 000000000..66cdcf0d9 --- /dev/null +++ b/generate_golang.tm @@ -0,0 +1,38 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +globals { + # you can enable this only in the stack you are debugging the tests. + enable_test_logging = false + + is_go_package = tm_anytrue([ + tm_contains(terramate.stack.tags, "golang"), + tm_contains(terramate.stack.tags, "e2etests"), + ]) + has_test_files = tm_length(tm_fileset(".", "*_test.go")) > 0 +} + +generate_file "loglevel_disable_test.go" { + condition = !global.enable_test_logging && global.is_go_package && global.has_test_files + lets { + special_cases = { + "ls" = "tmls" + "/" = "terramate" + } + is_main = tm_can(tm_file("main.go")) + basename = terramate.stack.path.basename + pkgname = let.is_main ? "main" : tm_try(let.special_cases[let.basename], let.basename) + } + content = <<-EOF + // Copyright 2024 Terramate GmbH + // SPDX-License-Identifier: MPL-2.0 + + package ${let.pkgname}_test + + import "github.com/rs/zerolog" + + func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) + } + EOF +} diff --git a/golangci.tm b/generate_golangci.tm similarity index 100% rename from golangci.tm rename to generate_golangci.tm diff --git a/generate_preview.tm b/generate_mock_preview.tm similarity index 80% rename from generate_preview.tm rename to generate_mock_preview.tm index c52f30d9a..9a7766706 100644 --- a/generate_preview.tm +++ b/generate_mock_preview.tm @@ -4,10 +4,7 @@ // This file is required by the "preview" script. generate_hcl "_test_mock.tf" { - condition = tm_anytrue([ - tm_contains(terramate.stack.tags, "golang"), - tm_contains(terramate.stack.tags, "e2etests"), - ]) + condition = global.is_go_package lets { name = tm_ternary(terramate.stack.path.basename == "/", "terramate", terramate.stack.path.basename) } diff --git a/git/git_test.go b/git/git_test.go index b80226e1a..ce1c5b1c8 100644 --- a/git/git_test.go +++ b/git/git_test.go @@ -14,7 +14,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/madlambda/spells/assert" - "github.com/rs/zerolog" "github.com/terramate-io/terramate/git" "github.com/terramate-io/terramate/test" "github.com/terramate-io/terramate/test/sandbox" @@ -522,7 +521,3 @@ func assertEqualRemotes(t *testing.T, got []git.Remote, want []git.Remote) { ) } } - -func init() { - zerolog.SetGlobalLevel(zerolog.Disabled) -} diff --git a/git/loglevel_disable_test.go b/git/loglevel_disable_test.go new file mode 100644 index 000000000..335111782 --- /dev/null +++ b/git/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package git_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/globals/globals_test.go b/globals/globals_test.go index c380d27c2..e7672da25 100644 --- a/globals/globals_test.go +++ b/globals/globals_test.go @@ -8,7 +8,6 @@ import ( "testing" "github.com/madlambda/spells/assert" - "github.com/rs/zerolog" "github.com/terramate-io/terramate/config" "github.com/terramate-io/terramate/errors" "github.com/terramate-io/terramate/globals" @@ -4166,7 +4165,3 @@ func testGlobals(t *testing.T, tcase testcase) { } }) } - -func init() { - zerolog.SetGlobalLevel(zerolog.Disabled) -} diff --git a/globals/loglevel_disable_test.go b/globals/loglevel_disable_test.go new file mode 100644 index 000000000..a1ba75038 --- /dev/null +++ b/globals/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package globals_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/hcl/ast/expression_fuzz_test.go b/hcl/ast/expression_fuzz_test.go index 65a904505..31f0cf27e 100644 --- a/hcl/ast/expression_fuzz_test.go +++ b/hcl/ast/expression_fuzz_test.go @@ -10,7 +10,6 @@ import ( "strings" "testing" - "github.com/rs/zerolog" "github.com/terramate-io/hcl/v2" "github.com/terramate-io/hcl/v2/hclsyntax" "github.com/terramate-io/terramate/hcl/ast" @@ -67,7 +66,3 @@ func FuzzTokensForExpression(f *testing.F) { ast.TokensForExpression(expr) }) } - -func init() { - zerolog.SetGlobalLevel(zerolog.Disabled) -} diff --git a/hcl/ast/loglevel_disable_test.go b/hcl/ast/loglevel_disable_test.go new file mode 100644 index 000000000..c772a2039 --- /dev/null +++ b/hcl/ast/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package ast_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/hcl/eval/loglevel_disable_test.go b/hcl/eval/loglevel_disable_test.go new file mode 100644 index 000000000..743632a2c --- /dev/null +++ b/hcl/eval/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package eval_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/hcl/eval/partial_fuzz_test.go b/hcl/eval/partial_fuzz_test.go index 7481f0fb9..4ae8f0071 100644 --- a/hcl/eval/partial_fuzz_test.go +++ b/hcl/eval/partial_fuzz_test.go @@ -11,7 +11,6 @@ import ( "strings" "testing" - "github.com/rs/zerolog" "github.com/terramate-io/hcl/v2" "github.com/terramate-io/hcl/v2/hclsyntax" "github.com/terramate-io/terramate/hcl/ast" @@ -111,7 +110,3 @@ EOT`, } }) } - -func init() { - zerolog.SetGlobalLevel(zerolog.Disabled) -} diff --git a/hcl/fmt/fmt_fuzz_test.go b/hcl/fmt/fmt_fuzz_test.go index 9b83941ff..e1df93e3a 100644 --- a/hcl/fmt/fmt_fuzz_test.go +++ b/hcl/fmt/fmt_fuzz_test.go @@ -11,7 +11,6 @@ import ( "testing" "github.com/madlambda/spells/assert" - "github.com/rs/zerolog" "github.com/terramate-io/hcl/v2/hclparse" "github.com/terramate-io/terramate/hcl/fmt" ) @@ -110,7 +109,3 @@ func formatMultiline(t *testing.T, code string) string { return got } - -func init() { - zerolog.SetGlobalLevel(zerolog.Disabled) -} diff --git a/hcl/fmt/loglevel_disable_test.go b/hcl/fmt/loglevel_disable_test.go new file mode 100644 index 000000000..54c458fdf --- /dev/null +++ b/hcl/fmt/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package fmt_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/hcl/hcl_test.go b/hcl/hcl_test.go index 87b8526b2..0d2d52748 100644 --- a/hcl/hcl_test.go +++ b/hcl/hcl_test.go @@ -9,7 +9,6 @@ import ( "testing" "github.com/madlambda/spells/assert" - "github.com/rs/zerolog" "github.com/terramate-io/terramate/errors" "github.com/terramate-io/terramate/hcl" "github.com/terramate-io/terramate/safeguard" @@ -1832,7 +1831,3 @@ func TestHCLParseProvidesAllParsedBodies(t *testing.T) { assert.EqualStrings(t, "generate_file", blocks[2].Type) assert.EqualStrings(t, "globals", blocks[3].Type) } - -func init() { - zerolog.SetGlobalLevel(zerolog.Disabled) -} diff --git a/hcl/info/loglevel_disable_test.go b/hcl/info/loglevel_disable_test.go new file mode 100644 index 000000000..511bb52dd --- /dev/null +++ b/hcl/info/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package info_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/hcl/loglevel_disable_test.go b/hcl/loglevel_disable_test.go new file mode 100644 index 000000000..2dfa5fd41 --- /dev/null +++ b/hcl/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package hcl_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/ls/loglevel_disable_test.go b/ls/loglevel_disable_test.go new file mode 100644 index 000000000..40ddd4908 --- /dev/null +++ b/ls/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package tmls_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/ls/ls_test.go b/ls/ls_test.go index f62d67fcc..746756a22 100644 --- a/ls/ls_test.go +++ b/ls/ls_test.go @@ -13,7 +13,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/madlambda/spells/assert" - "github.com/rs/zerolog" stackpkg "github.com/terramate-io/terramate/stack" lstest "github.com/terramate-io/terramate/test/ls" "go.lsp.dev/jsonrpc2" @@ -526,7 +525,3 @@ stack { }) } } - -func init() { - zerolog.SetGlobalLevel(zerolog.Disabled) -} diff --git a/modvendor/download/download_test.go b/modvendor/download/download_test.go index 257edf49a..6b10c7592 100644 --- a/modvendor/download/download_test.go +++ b/modvendor/download/download_test.go @@ -14,7 +14,6 @@ import ( "text/template" "github.com/madlambda/spells/assert" - "github.com/rs/zerolog" "github.com/terramate-io/terramate/errors" "github.com/terramate-io/terramate/event" "github.com/terramate-io/terramate/hcl" @@ -1207,7 +1206,3 @@ func newSource(t *testing.T, uri uri.URI, ref string) tf.Source { assert.NoError(t, err) return source } - -func init() { - zerolog.SetGlobalLevel(zerolog.Disabled) -} diff --git a/modvendor/download/loglevel_disable_test.go b/modvendor/download/loglevel_disable_test.go new file mode 100644 index 000000000..57b103264 --- /dev/null +++ b/modvendor/download/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package download_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/printer/loglevel_disable_test.go b/printer/loglevel_disable_test.go new file mode 100644 index 000000000..25ad72b5d --- /dev/null +++ b/printer/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package printer_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/project/loglevel_disable_test.go b/project/loglevel_disable_test.go new file mode 100644 index 000000000..9facf1be6 --- /dev/null +++ b/project/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package project_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/run/dag/dag_test.go b/run/dag/dag_test.go index fd1cc4376..042ec3674 100644 --- a/run/dag/dag_test.go +++ b/run/dag/dag_test.go @@ -11,8 +11,6 @@ import ( "github.com/madlambda/spells/errutil" "github.com/terramate-io/terramate/errors" "github.com/terramate-io/terramate/run/dag" - - "github.com/rs/zerolog" ) type node struct { @@ -426,7 +424,3 @@ func assertOrder(t *testing.T, want, got []dag.ID) { assert.EqualStrings(t, string(w), string(got[i]), "id %d mismatch", i) } } - -func init() { - zerolog.SetGlobalLevel(zerolog.Disabled) -} diff --git a/run/dag/loglevel_disable_test.go b/run/dag/loglevel_disable_test.go new file mode 100644 index 000000000..5c75f8dfd --- /dev/null +++ b/run/dag/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package dag_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/run/env_test.go b/run/env_test.go index f26d4660b..590acddd0 100644 --- a/run/env_test.go +++ b/run/env_test.go @@ -9,7 +9,6 @@ import ( "testing" "github.com/madlambda/spells/assert" - "github.com/rs/zerolog" "github.com/terramate-io/terramate/config" "github.com/terramate-io/terramate/errors" "github.com/terramate-io/terramate/run" @@ -605,7 +604,3 @@ func TestLoadRunEnv(t *testing.T) { }) } } - -func init() { - zerolog.SetGlobalLevel(zerolog.Disabled) -} diff --git a/run/loglevel_disable_test.go b/run/loglevel_disable_test.go new file mode 100644 index 000000000..01e380243 --- /dev/null +++ b/run/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package run_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/scheduler/loglevel_disable_test.go b/scheduler/loglevel_disable_test.go new file mode 100644 index 000000000..447f286ae --- /dev/null +++ b/scheduler/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package scheduler_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/stack/loglevel_disable_test.go b/stack/loglevel_disable_test.go new file mode 100644 index 000000000..735a5053f --- /dev/null +++ b/stack/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package stack_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/stack/stack_test.go b/stack/stack_test.go index 8bc0a6752..b1e5f80f0 100644 --- a/stack/stack_test.go +++ b/stack/stack_test.go @@ -7,7 +7,6 @@ import ( "testing" "github.com/madlambda/spells/assert" - "github.com/rs/zerolog" "github.com/terramate-io/terramate/config" "github.com/terramate-io/terramate/errors" "github.com/terramate-io/terramate/test/sandbox" @@ -25,7 +24,3 @@ func TestLoadAllFailsIfStacksIDIsNotUnique(t *testing.T) { _, err = config.LoadAllStacks(root, root.Tree()) assert.IsError(t, err, errors.E(config.ErrStackDuplicatedID)) } - -func init() { - zerolog.SetGlobalLevel(zerolog.Disabled) -} diff --git a/stack/trigger/loglevel_disable_test.go b/stack/trigger/loglevel_disable_test.go new file mode 100644 index 000000000..778aaf18b --- /dev/null +++ b/stack/trigger/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package trigger_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/stack/trigger/trigger_test.go b/stack/trigger/trigger_test.go index 4f1522983..b837bc837 100644 --- a/stack/trigger/trigger_test.go +++ b/stack/trigger/trigger_test.go @@ -19,7 +19,6 @@ import ( errtest "github.com/terramate-io/terramate/test/errors" . "github.com/terramate-io/terramate/test/hclwrite/hclutils" - "github.com/rs/zerolog" "github.com/terramate-io/terramate/test/sandbox" ) @@ -317,7 +316,3 @@ func TestTriggerParser(t *testing.T) { }) } } - -func init() { - zerolog.SetGlobalLevel(zerolog.Disabled) -} diff --git a/stdlib/funcs_test.go b/stdlib/funcs_test.go index 7fef7e9f7..481e4a82c 100644 --- a/stdlib/funcs_test.go +++ b/stdlib/funcs_test.go @@ -9,7 +9,6 @@ import ( "testing" "github.com/madlambda/spells/assert" - "github.com/rs/zerolog" "github.com/terramate-io/terramate/event" "github.com/terramate-io/terramate/hcl/eval" "github.com/terramate-io/terramate/project" @@ -384,7 +383,3 @@ func TestStdlibTofuSanityCheck(t *testing.T) { } func nljoin(strs ...string) string { return strings.Join(strs, "\n") + "\n" } - -func init() { - zerolog.SetGlobalLevel(zerolog.Disabled) -} diff --git a/stdlib/loglevel_disable_test.go b/stdlib/loglevel_disable_test.go new file mode 100644 index 000000000..2901327fc --- /dev/null +++ b/stdlib/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package stdlib_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/test/git_test.go b/test/git_test.go index 576481ae7..2e5e00069 100644 --- a/test/git_test.go +++ b/test/git_test.go @@ -7,7 +7,6 @@ import ( "testing" "github.com/madlambda/spells/assert" - "github.com/rs/zerolog" "github.com/terramate-io/terramate/test" ) @@ -35,7 +34,3 @@ func TestRepoIsSetupWithSyncRemoteOriginMain(t *testing.T) { originMainRev, ) } - -func init() { - zerolog.SetGlobalLevel(zerolog.Disabled) -} diff --git a/test/hclwrite/hclwrite_test.go b/test/hclwrite/hclwrite_test.go index 715ae8bd6..a1add909b 100644 --- a/test/hclwrite/hclwrite_test.go +++ b/test/hclwrite/hclwrite_test.go @@ -9,7 +9,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/madlambda/spells/assert" - "github.com/rs/zerolog" "github.com/terramate-io/hcl/v2/hclparse" "github.com/terramate-io/hcl/v2/hclsyntax" "github.com/terramate-io/terramate/test/hclwrite" @@ -320,7 +319,3 @@ func evaluateValExpr(t *testing.T, valueExpr string) cty.Value { return val } - -func init() { - zerolog.SetGlobalLevel(zerolog.Disabled) -} diff --git a/test/hclwrite/loglevel_disable_test.go b/test/hclwrite/loglevel_disable_test.go new file mode 100644 index 000000000..33b74da12 --- /dev/null +++ b/test/hclwrite/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package hclwrite_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/test/loglevel_disable_test.go b/test/loglevel_disable_test.go new file mode 100644 index 000000000..8babe6064 --- /dev/null +++ b/test/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package test_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/test/ls/doc.go b/test/ls/doc.go index c07173dc3..f0988a3ba 100644 --- a/test/ls/doc.go +++ b/test/ls/doc.go @@ -1,5 +1,5 @@ // Copyright 2023 Terramate GmbH // SPDX-License-Identifier: MPL-2.0 -// Package ls provides test utilities used when testing the Terramate Language Server. -package ls +// Package tmls provides test utilities used when testing the Terramate Language Server. +package tmls diff --git a/test/ls/editor.go b/test/ls/editor.go index 9b72142fc..4ac408e30 100644 --- a/test/ls/editor.go +++ b/test/ls/editor.go @@ -1,7 +1,7 @@ // Copyright 2023 Terramate GmbH // SPDX-License-Identifier: MPL-2.0 -package ls +package tmls import ( "context" @@ -12,7 +12,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/madlambda/spells/assert" - "github.com/rs/zerolog" tmls "github.com/terramate-io/terramate/ls" "github.com/terramate-io/terramate/test/sandbox" "go.lsp.dev/jsonrpc2" @@ -153,7 +152,3 @@ func DefaultInitializeResult() lsp.InitializeResult { }, } } - -func init() { - zerolog.SetGlobalLevel(zerolog.Disabled) -} diff --git a/test/ls/fixture.go b/test/ls/fixture.go index 462b8f7ad..27fba8702 100644 --- a/test/ls/fixture.go +++ b/test/ls/fixture.go @@ -1,7 +1,7 @@ // Copyright 2023 Terramate GmbH // SPDX-License-Identifier: MPL-2.0 -package ls +package tmls import ( "context" diff --git a/test/sandbox/git_test.go b/test/sandbox/git_test.go index e23ade38b..302b4a7fc 100644 --- a/test/sandbox/git_test.go +++ b/test/sandbox/git_test.go @@ -6,7 +6,6 @@ package sandbox_test import ( "testing" - "github.com/rs/zerolog" "github.com/terramate-io/terramate/test" "github.com/terramate-io/terramate/test/sandbox" ) @@ -36,7 +35,3 @@ func TestInitializeArbitraryRemote(t *testing.T) { git.SetupRemote(remote, remoteBranch, "main") git.RevParse(remote + "/" + remoteBranch) } - -func init() { - zerolog.SetGlobalLevel(zerolog.Disabled) -} diff --git a/test/sandbox/loglevel_disable_test.go b/test/sandbox/loglevel_disable_test.go new file mode 100644 index 000000000..7b60f9c2c --- /dev/null +++ b/test/sandbox/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package sandbox_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/tf/loglevel_disable_test.go b/tf/loglevel_disable_test.go new file mode 100644 index 000000000..59ded3ddc --- /dev/null +++ b/tf/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package tf_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +} diff --git a/tf/terraform_test.go b/tf/terraform_test.go index 994605b5b..584ca1497 100644 --- a/tf/terraform_test.go +++ b/tf/terraform_test.go @@ -9,7 +9,6 @@ import ( "testing" "github.com/madlambda/spells/assert" - "github.com/rs/zerolog" hhcl "github.com/terramate-io/hcl/v2" "github.com/terramate-io/terramate/errors" "github.com/terramate-io/terramate/test" @@ -401,7 +400,3 @@ func fixupFiledirOnErrorsFileRanges(dir string, errs []error) { } var end = start - -func init() { - zerolog.SetGlobalLevel(zerolog.Disabled) -} diff --git a/tg/logging_level_test.go b/tg/loglevel_disable_test.go similarity index 81% rename from tg/logging_level_test.go rename to tg/loglevel_disable_test.go index 56677ee97..b2f236ee0 100644 --- a/tg/logging_level_test.go +++ b/tg/loglevel_disable_test.go @@ -1,4 +1,4 @@ -// Copyright 2023 Terramate GmbH +// Copyright 2024 Terramate GmbH // SPDX-License-Identifier: MPL-2.0 package tg_test diff --git a/versions/loglevel_disable_test.go b/versions/loglevel_disable_test.go new file mode 100644 index 000000000..f3776ed58 --- /dev/null +++ b/versions/loglevel_disable_test.go @@ -0,0 +1,10 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +package versions_test + +import "github.com/rs/zerolog" + +func init() { + zerolog.SetGlobalLevel(zerolog.Disabled) +}