func validateAndGetRelativeTestPkg()

in cli/bptest/run.go [38:69]


func validateAndGetRelativeTestPkg(intTestDir string, name string) (string, error) {
	// user wants to run all tests
	if name == allTests {
		return "./...", nil
	}

	tests, err := getTests(intTestDir)
	if err != nil {
		return "", err
	}
	testNames := []string{}
	for _, test := range tests {
		if test.bptestCfg.Spec.Skip {
			Log.Info(fmt.Sprintf("skipping %s due to BlueprintTest config %s", test.name, test.bptestCfg.Name))
			continue
		}
		matched, _ := regexp.Match(name, []byte(test.name))
		if test.name == name {
			//exact match, return test relative test pkg
			relPkg, err := filepath.Rel(intTestDir, path.Dir(test.location))
			if err != nil {
				return "", err
			}
			return fmt.Sprintf("./%s", relPkg), nil
		} else if matched {
			// loose match, more than one test could be specified
			return "./...", nil
		}
		testNames = append(testNames, test.name)
	}
	return "", fmt.Errorf("unable to find %s- one of %+q expected", name, append(testNames, allTests))
}