Пример #1
0
func TestRecursiveInitPyCreation(t *testing.T) {
	state, _ := newState("//package1/package2:wevs")
	target1 := newPyFilegroup(state, "//package1/package2:target1", "file1.py")
	assert.NoError(t, buildFilegroup(0, state, target1))
	assert.True(t, core.FileExists("plz-out/gen/package1/package2/__init__.py"))
	assert.True(t, core.FileExists("plz-out/gen/package1/__init__.py"))
}
Пример #2
0
func TestInitPyCreation(t *testing.T) {
	state, _ := newState("//pypkg:wevs")
	target1 := newPyFilegroup(state, "//pypkg:target1", "file1.py")
	target2 := newPyFilegroup(state, "//pypkg:target2", "__init__.py")
	assert.NoError(t, buildFilegroup(0, state, target1))
	assert.True(t, core.FileExists("plz-out/gen/pypkg/__init__.py"))
	assert.NoError(t, buildFilegroup(0, state, target2))
	d, err := ioutil.ReadFile("plz-out/gen/pypkg/__init__.py")
	assert.NoError(t, err)
	assert.Equal(t, `"""output from //pypkg:target2"""`, strings.TrimSpace(string(d)))
}
Пример #3
0
func buildFileName(state *core.BuildState, pkgName string) string {
	// Bazel defines targets in its "external" package from its WORKSPACE file.
	// We will fake this by treating that as an actual package file...
	if state.Config.Bazel.Compatibility && pkgName == "external" {
		return "WORKSPACE"
	}
	for _, buildFileName := range state.Config.Please.BuildFileName {
		if filename := path.Join(pkgName, buildFileName); core.FileExists(filename) {
			return filename
		}
	}
	return ""
}