Merge pull request #119103 from pohly/e2e-unexpected-args

e2e: detect unexpected command line arguments
This commit is contained in:
Kubernetes Prow Robot 2023-07-07 04:37:04 -07:00 committed by GitHub
commit ddb2013363
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 0 deletions

View File

@ -92,6 +92,11 @@ func TestMain(m *testing.M) {
os.Exit(0)
}
if flag.CommandLine.NArg() > 0 {
fmt.Fprintf(os.Stderr, "unknown additional command line arguments: %s", flag.CommandLine.Args())
os.Exit(1)
}
// Enable embedded FS file lookup as fallback
testfiles.AddFileSource(e2etestingmanifests.GetE2ETestingManifestsFS())
testfiles.AddFileSource(testfixtures.GetTestFixturesFS())

View File

@ -18,6 +18,7 @@ package kubeadm
import (
"flag"
"fmt"
"os"
"testing"
@ -42,6 +43,10 @@ func TestMain(m *testing.M) {
framework.RegisterClusterFlags(flag.CommandLine)
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
pflag.Parse()
if pflag.CommandLine.NArg() > 0 {
fmt.Fprintf(os.Stderr, "unknown additional command line arguments: %s", pflag.CommandLine.Args())
os.Exit(1)
}
framework.AfterReadingAllFlags(&framework.TestContext)
os.Exit(m.Run())
}

View File

@ -130,6 +130,10 @@ func TestMain(m *testing.M) {
rand.Seed(time.Now().UnixNano())
pflag.Parse()
if pflag.CommandLine.NArg() > 0 {
fmt.Fprintf(os.Stderr, "unknown additional command line arguments: %s", pflag.CommandLine.Args())
os.Exit(1)
}
framework.AfterReadingAllFlags(&framework.TestContext)
if err := e2eskipper.InitFeatureGates(utilfeature.DefaultFeatureGate, featureGates); err != nil {
fmt.Fprintf(os.Stderr, "ERROR: initialize feature gates: %v", err)