diff --git a/test/init_test.go b/test/init_test.go index efac58ae8ee..8b17fa56c38 100644 --- a/test/init_test.go +++ b/test/init_test.go @@ -44,6 +44,11 @@ import ( ) var initMetrics sync.Once +var skipRootUserTests = false + +func init() { + flag.BoolVar(&skipRootUserTests, "skipRootUserTests", false, "Skip tests that require root user") +} func setup(t *testing.T, fn ...func(*testing.T, *clients, string)) (*clients, string) { t.Helper() @@ -146,6 +151,7 @@ func verifyServiceAccountExistence(t *testing.T, namespace string, kubeClient *k // TestMain initializes anything global needed by the tests. Right now this is just log and metric // setup since the log and metric libs we're using use global state :( func TestMain(m *testing.M) { + flag.Parse() c := m.Run() fmt.Fprintf(os.Stderr, "Using kubeconfig at `%s` with cluster `%s`\n", knativetest.Flags.Kubeconfig, knativetest.Flags.Cluster) os.Exit(c) diff --git a/test/kaniko_task_test.go b/test/kaniko_task_test.go index 2c579b4424b..8bfe3a65d31 100644 --- a/test/kaniko_task_test.go +++ b/test/kaniko_task_test.go @@ -19,7 +19,6 @@ limitations under the License. package test import ( - "flag" "fmt" "strings" "testing" @@ -44,14 +43,6 @@ const ( revision = "1c9d566ecd13535f93789595740f20932f655905" ) -var ( - skipRootUserTests = "false" -) - -func init() { - flag.StringVar(&skipRootUserTests, "skipRootUserTests", "false", "Skip tests that require root user") -} - // TestTaskRun is an integration test that will verify a TaskRun using kaniko func TestKanikoTaskRun(t *testing.T) { if skipRootUserTests == "true" { diff --git a/test/v1alpha1/init_test.go b/test/v1alpha1/init_test.go index efac58ae8ee..8b17fa56c38 100644 --- a/test/v1alpha1/init_test.go +++ b/test/v1alpha1/init_test.go @@ -44,6 +44,11 @@ import ( ) var initMetrics sync.Once +var skipRootUserTests = false + +func init() { + flag.BoolVar(&skipRootUserTests, "skipRootUserTests", false, "Skip tests that require root user") +} func setup(t *testing.T, fn ...func(*testing.T, *clients, string)) (*clients, string) { t.Helper() @@ -146,6 +151,7 @@ func verifyServiceAccountExistence(t *testing.T, namespace string, kubeClient *k // TestMain initializes anything global needed by the tests. Right now this is just log and metric // setup since the log and metric libs we're using use global state :( func TestMain(m *testing.M) { + flag.Parse() c := m.Run() fmt.Fprintf(os.Stderr, "Using kubeconfig at `%s` with cluster `%s`\n", knativetest.Flags.Kubeconfig, knativetest.Flags.Cluster) os.Exit(c) diff --git a/test/v1alpha1/kaniko_task_test.go b/test/v1alpha1/kaniko_task_test.go index cbe9a608ff4..d4157ac7167 100644 --- a/test/v1alpha1/kaniko_task_test.go +++ b/test/v1alpha1/kaniko_task_test.go @@ -41,10 +41,6 @@ const ( revision = "1c9d566ecd13535f93789595740f20932f655905" ) -var ( - skipRootUserTests = "false" -) - // TestTaskRun is an integration test that will verify a TaskRun using kaniko func TestKanikoTaskRun(t *testing.T) { if skipRootUserTests == "true" {