Example #1
0
// testTargets handles test targets which can be given in two formats; a list of targets or a single
// target with a list of trailing arguments.
// Alternatively they can be completely omitted in which case we test everything under the working dir.
func testTargets(target core.BuildLabel, args []string) []core.BuildLabel {
	if target.Name == "" {
		return core.InitialPackage()
	} else if len(args) > 0 && core.LooksLikeABuildLabel(args[0]) {
		opts.Cover.Args.Args = []string{}
		opts.Test.Args.Args = []string{}
		return append(core.ParseBuildLabels(args), target)
	} else {
		return []core.BuildLabel{target}
	}
}
Example #2
0
// findOriginalTasks finds the original parse tasks for the original set of targets.
func findOriginalTasks(state *core.BuildState, targets []core.BuildLabel) {
	for _, target := range targets {
		if target == core.BuildLabelStdin {
			for label := range utils.ReadStdin() {
				findOriginalTask(state, core.ParseBuildLabels([]string{label})[0])
			}
		} else {
			findOriginalTask(state, target)
		}
	}
	state.TaskDone() // initial target adding counts as one.
}
Example #3
0
// QueryCompletionLabels produces a set of labels that complete a given input.
func QueryCompletionLabels(config *core.Configuration, args []string, repoRoot string) []core.BuildLabel {
	if len(args) == 0 {
		queryCompletionPackages(config, ".", repoRoot)
	} else if !strings.Contains(args[0], ":") {
		// Haven't picked a package yet so no parsing is necessary.
		if strings.HasPrefix(args[0], "//") {
			queryCompletionPackages(config, args[0][2:], repoRoot)
		} else {
			queryCompletionPackages(config, args[0], repoRoot)
		}
	}
	if strings.HasSuffix(args[0], ":") {
		args[0] += "all"
	}
	// Bash completion sometimes produces \: instead of just : (see issue #18).
	// We silently fix that here since we've not yet worked out how to fix Bash itself :(
	args[0] = strings.Replace(args[0], "\\:", ":", -1)
	labels := core.ParseBuildLabels([]string{args[0]})
	// Return this label without the trailing bit.
	return []core.BuildLabel{{PackageName: labels[0].PackageName, Name: "all"}}
}