Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 33 additions & 6 deletions pkg/extension/extensiontests/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,45 @@ func (specs ExtensionTestSpecs) MustSelectAll(selectFns []SelectFunction) (Exten
return filtered, nil
}

// ModuleTestsOnly ensures that ginkgo tests from vendored sources aren't selected,
// except for the Origin extended util packages, that may contain Ginkgo nodes but
// should not cause a test exclusion.
// ModuleTestsOnly ensures that ginkgo tests from vendored sources aren't selected. Unfortunately, making use of
// kubernetes test helpers results in the entire Ginkgo suite being initialized (ginkgo loves global state), so we need
// to be careful about which tests we select.
//
// A test is excluded if ALL of its code locations with full paths are external (vendored or from external test suites).
// If at least one code location with a full path is from the local module, the test is included, since local tests
// may legitimately call helper functions from vendored test frameworks.
func ModuleTestsOnly() SelectFunction {
return func(spec *ExtensionTestSpec) bool {
hasLocalCode := false

for _, cl := range spec.CodeLocations {
if strings.Contains(cl, "/vendor/") && !strings.Contains(cl, "github.com/openshift/origin/test/extended/util") {
return false
// Short-form code locations (e.g., "set up framework | framework.go:200") are ignored in this determination.
if !strings.Contains(cl, "/") {
continue
}

// Check if this is an external/vendored code location
isExternal := false

// Check for vendored paths
if strings.Contains(cl, "/vendor/") {
isExternal = true
}

// Check for vendored kubernetes tests that may appear as module paths
if strings.Contains(cl, "k8s.io/kubernetes/test") {
isExternal = true
}

// If this code location is not external, it's local code
if !isExternal {
hasLocalCode = true
break
}
}

return true
// Include the test only if it has at least one local code location
return hasLocalCode
}
}

Expand Down