示例#1
0
func findOriginalTask(state *core.BuildState, target core.BuildLabel) {
	if target.IsAllSubpackages() {
		for pkg := range utils.FindAllSubpackages(state.Config, target.PackageName, "") {
			state.AddOriginalTarget(core.NewBuildLabel(pkg, "all"))
		}
	} else {
		state.AddOriginalTarget(target)
	}
}
示例#2
0
func init() {
	runtime.GOMAXPROCS(1) // Don't allow tests to run in parallel, they should work but makes debugging tricky
	osName = runtime.GOOS + "_" + runtime.GOARCH
	label = core.NewBuildLabel("pkg/name", "label_name")

	// Move this directory from test_data to somewhere local.
	// This is easier than changing our working dir & a better test of some things too.
	if err := os.Rename("src/cache/test_data/plz-out", "plz-out"); err != nil {
		log.Fatalf("Failed to prepare test directory: %s\n", err)
	}

	startServer(7677, "", "", "")
	rpccache = buildClient(7677, "")
}
示例#3
0
func init() {
	osName = runtime.GOOS + "_" + runtime.GOARCH
	label = core.NewBuildLabel("pkg/name", "label_name")
	target = core.NewBuildTarget(label)

	// Arbitrary large numbers so the cleaner never needs to run.
	cache := server.NewCache("src/cache/test_data", 20*time.Hour, 100000, 100000000, 1000000000)
	key, _ = ioutil.ReadFile("src/cache/test_data/testfile")
	testServer := httptest.NewServer(server.BuildRouter(cache))

	config := core.DefaultConfiguration()
	config.Cache.HttpUrl = testServer.URL
	config.Cache.HttpWriteable = true
	httpcache = newHttpCache(config)
}
示例#4
0
// addTarget adds a new build target to the graph.
// Separated from AddTarget to make it possible to test (since you can't mix cgo and go test).
func addTarget(pkgPtr uintptr, name, cmd, testCmd string, binary, test, needsTransitiveDeps,
	outputIsComplete, containerise, noTestOutput, testOnly, stamp bool,
	flakiness, buildTimeout, testTimeout int, buildingDescription string) *core.BuildTarget {
	pkg := unsizep(pkgPtr)
	target := core.NewBuildTarget(core.NewBuildLabel(pkg.Name, name))
	target.IsBinary = binary
	target.IsTest = test
	target.NeedsTransitiveDependencies = needsTransitiveDeps
	target.OutputIsComplete = outputIsComplete
	target.Containerise = containerise
	target.NoTestOutput = noTestOutput
	target.TestOnly = testOnly
	target.Flakiness = flakiness
	target.BuildTimeout = time.Duration(buildTimeout) * time.Second
	target.TestTimeout = time.Duration(testTimeout) * time.Second
	target.Stamp = stamp
	// Automatically label containerised tests.
	if containerise {
		target.AddLabel("container")
	}
	// Automatically label flaky tests.
	if flakiness > 0 {
		target.AddLabel("flaky")
	}
	if binary {
		target.AddLabel("bin")
	}
	if buildingDescription != "" {
		target.BuildingDescription = buildingDescription
	}
	target.Command = cmd
	target.TestCommand = testCmd
	if _, present := pkg.Targets[name]; present {
		// NB. Not logged as an error because Python is now allowed to catch it.
		//     It will turn into an error later if the exception is not caught.
		log.Notice("Duplicate build target in %s: %s", pkg.Name, name)
		return nil
	}
	pkg.Targets[name] = target
	if core.State.Graph.Package(pkg.Name) != nil {
		// Package already added, so we're probably in a post-build function. Add target directly to graph now.
		log.Debug("Adding new target %s directly to graph", target.Label)
		core.State.Graph.AddTarget(target)
	}
	return target
}