From 47739abb300fb69b1a2ca2f7767f133ad1c0d1e7 Mon Sep 17 00:00:00 2001 From: Filipe Brandenburger Date: Wed, 28 Jan 2015 20:23:06 -0800 Subject: [PATCH 1/2] Make it possible to re-enable color output in Ginkgo e2e tests Instead of forcing the NoColor flag to on at runtime, make it default to being on in a way that it's still possible to override it by passing e2e the --ginkgo.noColor=false command-line flag. Tested by running the tests with and without the flag and confirming that both worked as expected. --- test/e2e/driver.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/e2e/driver.go b/test/e2e/driver.go index 95ca1643b5c..e6e0f3ca9c5 100644 --- a/test/e2e/driver.go +++ b/test/e2e/driver.go @@ -30,6 +30,12 @@ import ( type testResult bool +func init() { + // Turn off colors by default to make it easier to collect console output in Jenkins + // Override colors off with --ginkgo.noColor=false in the command-line + config.DefaultReporterConfig.NoColor = true +} + func (t *testResult) Fail() { *t = false } // Run each Go end-to-end-test. This function assumes the @@ -57,8 +63,6 @@ func RunE2ETests(authConfig, certDir, host, repoRoot, provider string, orderseed var passed testResult = true gomega.RegisterFailHandler(ginkgo.Fail) - // Turn of colors for now to make it easier to collect console output in Jenkins - config.DefaultReporterConfig.NoColor = true var r []ginkgo.Reporter if reportDir != "" { // TODO: When we start using parallel tests we need to change this to "junit_%d.xml", From fa845030c4acb5fcaed2e434ef38821263b6c9ad Mon Sep 17 00:00:00 2001 From: Filipe Brandenburger Date: Wed, 28 Jan 2015 21:11:23 -0800 Subject: [PATCH 2/2] Make cmd/e2e --test work after the conversion to Ginkgo Use the --ginkgo.focus flag which accepts a regexp to define which tests should be run. Create a regexp matching a full word that is exactly one of the test names passed as -t parameters. Tested with cmd/e2e -t TestLivenessHttp -t TestLivenessExec, confirmed that 2 tests were executed and 9 were skipped. --- test/e2e/driver.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/test/e2e/driver.go b/test/e2e/driver.go index e6e0f3ca9c5..384ff67bd0e 100644 --- a/test/e2e/driver.go +++ b/test/e2e/driver.go @@ -18,6 +18,8 @@ package e2e import ( "path" + "regexp" + "strings" "time" "github.com/GoogleCloudPlatform/kubernetes/pkg/util" @@ -57,7 +59,17 @@ func RunE2ETests(authConfig, certDir, host, repoRoot, provider string, orderseed glog.Fatalf("This test has timed out. Cleanup not guaranteed.") }() - // TODO: Make -t TestName work again. + if len(testList) != 0 { + if config.GinkgoConfig.FocusString != "" || config.GinkgoConfig.SkipString != "" { + glog.Fatal("Either specify --test/-t or --ginkgo.focus/--ginkgo.skip but not both.") + } + var testRegexps []string + for _, t := range testList { + testRegexps = append(testRegexps, regexp.QuoteMeta(t)) + } + config.GinkgoConfig.FocusString = `\b(` + strings.Join(testRegexps, "|") + `)\b` + } + // TODO: Make "times" work again. // TODO: Make orderseed work again.