当前位置: 首页>>代码示例>>Golang>>正文


Golang BuildGraph.AllTargets方法代码示例

本文整理汇总了Golang中core.BuildGraph.AllTargets方法的典型用法代码示例。如果您正苦于以下问题:Golang BuildGraph.AllTargets方法的具体用法?Golang BuildGraph.AllTargets怎么用?Golang BuildGraph.AllTargets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在core.BuildGraph的用法示例。


在下文中一共展示了BuildGraph.AllTargets方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: updateDependencies

// Set dependency pointers on all contents of the graph.
// Has to be done after to test cycles etc.
func updateDependencies(graph *core.BuildGraph) {
	for _, target := range graph.AllTargets() {
		for _, dep := range target.DeclaredDependencies() {
			graph.AddDependency(target.Label, dep)
		}
	}
}
开发者ID:thought-machine,项目名称:please,代码行数:9,代码来源:shell_output_test.go

示例2: QueryAffectedTargets

// QueryAffectedTargets walks over the build graph and identifies all targets that have a transitive
// dependency on the given set of files.
// Targets are filtered by given include / exclude labels and if 'tests' is true only
// test targets will be returned.
func QueryAffectedTargets(graph *core.BuildGraph, files, include, exclude []string, tests, transitive bool) {
	affectedTargets := make(chan *core.BuildTarget, 100)
	done := make(chan bool)

	filePaths := map[string]bool{}
	for _, file := range files {
		filePaths[file] = true
	}

	// Check all the targets to see if any own one of these files
	go func() {
		for _, target := range graph.AllTargets() {
			for _, source := range target.AllSourcePaths(graph) {
				if _, present := filePaths[source]; present {
					affectedTargets <- target
					break
				}
			}
		}
		done <- true
	}()

	// Check all the packages to see if any are defined by these files.
	// This is pretty pessimistic, we have to just assume the whole package is invalidated.
	// A better approach involves using plz query graph and plz_diff_graphs - see that tool
	// for more explanation.
	go func() {
		invalidatePackage := func(pkg *core.Package) {
			for _, target := range pkg.Targets {
				affectedTargets <- target
			}
		}
		for _, pkg := range graph.PackageMap() {
			if _, present := filePaths[pkg.Filename]; present {
				invalidatePackage(pkg)
			} else {
				for _, subinclude := range pkg.Subincludes {
					for _, source := range graph.TargetOrDie(subinclude).AllSourcePaths(graph) {
						if _, present := filePaths[source]; present {
							invalidatePackage(pkg)
							break
						}
					}
				}
			}
		}
		done <- true
	}()

	go handleAffectedTargets(graph, affectedTargets, done, include, exclude, tests, transitive)

	<-done
	<-done
	close(affectedTargets)
	<-done
}
开发者ID:thought-machine,项目名称:please,代码行数:60,代码来源:affected_targets.go

示例3: unbuiltTargetsMessage

// Prints all targets in the build graph that are marked to be built but not built yet.
func unbuiltTargetsMessage(graph *core.BuildGraph) string {
	msg := ""
	for _, target := range graph.AllTargets() {
		if target.State() == core.Active {
			if graph.AllDepsBuilt(target) {
				msg += fmt.Sprintf("  %s (waiting for deps to build)\n", target.Label)
			} else {
				msg += fmt.Sprintf("  %s\n", target.Label)
			}
		} else if target.State() == core.Pending {
			msg += fmt.Sprintf("  %s (pending build)\n", target.Label)
		}
	}
	if msg != "" {
		return "\nThe following targets have not yet built:\n" + msg
	}
	return ""
}
开发者ID:thought-machine,项目名称:please,代码行数:19,代码来源:shell_output.go

示例4: WriteResultsToFileOrDie

// Write test results out to a file in xUnit format. Dies on any errors.
func WriteResultsToFileOrDie(graph *core.BuildGraph, filename string) {
	if err := os.MkdirAll(path.Dir(filename), core.DirPermissions); err != nil {
		log.Fatalf("Failed to create directory for test output")
	}
	results := JUnitXMLTestResults{}
	results.XMLName.Local = "testsuites"
	for _, target := range graph.AllTargets() {
		if target.Results.NumTests > 0 {
			suite := JUnitXMLTestSuite{
				Name:     target.Label.String(),
				Failures: target.Results.Failed,
				Tests:    target.Results.NumTests,
			}
			for _, pass := range target.Results.Passes {
				suite.TestCases = append(suite.TestCases, JUnitXMLTest{Name: pass})
			}
			for _, fail := range target.Results.Failures {
				suite.TestCases = append(suite.TestCases, JUnitXMLTest{
					Name:   fail.Name,
					Type:   fail.Type,
					Stdout: fail.Stdout,
					Stderr: fail.Stderr,
					Error: &JUnitXMLFailure{
						Type:      fail.Type,
						Traceback: fail.Traceback,
					},
				})
			}
			results.TestSuites = append(results.TestSuites, suite)
		}
	}
	if b, err := xml.MarshalIndent(results, "", "    "); err != nil {
		log.Fatalf("Failed to serialise XML: %s", err)
	} else if err = ioutil.WriteFile(filename, b, 0644); err != nil {
		log.Fatalf("Failed to write XML to %s: %s", filename, err)
	}
}
开发者ID:thought-machine,项目名称:please,代码行数:38,代码来源:xml_results.go


注:本文中的core.BuildGraph.AllTargets方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。