Пример #1
0
func findSuites(args []string, recurse bool, skipPackage string) []*testsuite.TestSuite {
	suites := []*testsuite.TestSuite{}

	if len(args) > 0 {
		for _, arg := range args {
			suites = append(suites, testsuite.SuitesInDir(arg, recurse)...)
		}
	} else {
		suites = testsuite.SuitesInDir(".", recurse)
	}

	if skipPackage != "" {
		re := regexp.MustCompile(skipPackage)
		filteredSuites := []*testsuite.TestSuite{}
		skippedPackages := []string{}
		for _, suite := range suites {
			if re.Match([]byte(suite.PackageName)) {
				skippedPackages = append(skippedPackages, suite.PackageName)
			} else {
				filteredSuites = append(filteredSuites, suite)
			}
		}
		if len(skippedPackages) > 0 {
			fmt.Printf("Will skip %s\n", strings.Join(skippedPackages, ", "))
		}
		suites = filteredSuites
	}

	if len(suites) == 0 {
		complainAndQuit("Found no test suites")
	}

	return suites
}
Пример #2
0
func findSuites(args []string, recurse bool, skipPackage string) ([]testsuite.TestSuite, []string) {
	suites := []testsuite.TestSuite{}

	if len(args) > 0 {
		for _, arg := range args {
			suites = append(suites, testsuite.SuitesInDir(arg, recurse)...)
		}
	} else {
		suites = testsuite.SuitesInDir(".", recurse)
	}

	skippedPackages := []string{}
	if skipPackage != "" {
		skipFilters := strings.Split(skipPackage, ",")
		filteredSuites := []testsuite.TestSuite{}
		for _, suite := range suites {
			skip := false
			for _, skipFilter := range skipFilters {
				if strings.Contains(suite.Path, skipFilter) {
					skip = true
					break
				}
			}
			if skip {
				skippedPackages = append(skippedPackages, suite.Path)
			} else {
				filteredSuites = append(filteredSuites, suite)
			}
		}
		suites = filteredSuites
	}

	return suites, skippedPackages
}
Пример #3
0
func findSuites(args []string, recurse bool, skipPackage string) ([]testsuite.TestSuite, []string) {
	suites := []testsuite.TestSuite{}

	if len(args) > 0 {
		for _, arg := range args {
			suites = append(suites, testsuite.SuitesInDir(arg, recurse)...)
		}
	} else {
		suites = testsuite.SuitesInDir(".", recurse)
	}

	skippedPackages := []string{}
	if skipPackage != "" {
		re := regexp.MustCompile(skipPackage)
		filteredSuites := []testsuite.TestSuite{}
		for _, suite := range suites {
			if re.Match([]byte(suite.PackageName)) {
				skippedPackages = append(skippedPackages, suite.Path)
			} else {
				filteredSuites = append(filteredSuites, suite)
			}
		}
		suites = filteredSuites
	}

	return suites, skippedPackages
}
Пример #4
0
func findSuites() []*testsuite.TestSuite {
	suites := []*testsuite.TestSuite{}

	if flag.NArg() > 0 {
		for _, dir := range flag.Args() {
			suites = append(suites, testsuite.SuitesInDir(dir, recurse)...)
		}
	} else {
		suites = testsuite.SuitesInDir(".", recurse)
	}

	if len(suites) == 0 {
		fmt.Printf("Found no test suites.\nFor usage instructions:\n\tginkgo help\n")
		os.Exit(1)
	}

	return suites
}