diff options
Diffstat (limited to 'test/framework/fixtures/expectFixture.go')
-rw-r--r-- | test/framework/fixtures/expectFixture.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/framework/fixtures/expectFixture.go b/test/framework/fixtures/expectFixture.go index 3620c1368..377bce502 100644 --- a/test/framework/fixtures/expectFixture.go +++ b/test/framework/fixtures/expectFixture.go @@ -18,6 +18,7 @@ package fixtures import ( "bytes" + "fmt" "io/ioutil" "os" "os/exec" @@ -97,6 +98,10 @@ func (ef *ExpectFixture) removeTestDir(workingDir string) (err error) { // MakeExpectTest creates an expect test fixture for the current directory func MakeExpectTest(t *testing.T) *ExpectFixture { + if skipExpectTests() { + t.Skip("Expect tests disabled by environment variables.") + } + ef := &ExpectFixture{} ef.expectFiles = make(map[string]string) // map expect test to full file name. err := filepath.Walk(".", func(path string, info os.FileInfo, err error) error { @@ -111,11 +116,45 @@ func MakeExpectTest(t *testing.T) *ExpectFixture { return ef } +func skipExpectTests() bool { + // Explicitly enabled. + if strings.ToUpper(os.Getenv("RUN_EXPECT")) == "TRUE" { + return false + } + if strings.ToUpper(os.Getenv("RUN_EXPECT")) == "FALSE" { + return true + } + + // If any of the CI systems didn't set RUN_EXPECT, disable them. + if strings.ToUpper(os.Getenv("CI")) == "TRUE" { + return true + } + if strings.ToUpper(os.Getenv("CIRCLECI")) == "TRUE" { + return true + } + if strings.ToUpper(os.Getenv("TRAVIS")) == "TRUE" { + return true + } + if strings.ToUpper(os.Getenv("JENKINS_URL")) != "" { + return true + } + + // Implicitly enable for devs running tests. + return false +} + // Run Process all expect script files with suffix Test.exp within the current directory func (ef *ExpectFixture) Run() { + disabledTest := map[string]string{ + "pingpongTest.exp": "broken", + "listExpiredParticipationKeyTest.exp": "flaky", + } for testName := range ef.expectFiles { if match, _ := regexp.MatchString(ef.testFilter, testName); match { ef.t.Run(testName, func(t *testing.T) { + if reason, ok := disabledTest[testName]; ok { + t.Skip(fmt.Sprintf("Skipping %s test: %s", testName, reason)) + } partitiontest.PartitionTest(t) // Check if this expect test should by run, may SKIP syncTest := SynchronizedTest(t) |