Add more paths helper methods

Add PathsForOutput to convert multiple strings into WritablePaths.

Add OutputPath.InSameDir to build a new OutputPath pointing to a
file in the same directory as an existing OutputPath.

Add WritablePathForTesting and WritablePathsForTesting that mirror
PathForTesting and PathsForTesting but return WritablePaths.

Add PathContextForTesting to return a minimal PathContext
implementation.

Test: paths_test.go
Change-Id: I9708eb164b273514a96dae0a260ef9a963fb9bcf
This commit is contained in:
Colin Cross
2019-02-15 11:08:35 -08:00
parent e4759b9ab9
commit 40e3373d41
3 changed files with 83 additions and 2 deletions

View File

@@ -703,3 +703,15 @@ func ExampleOutputPath_ReplaceExtension() {
// Output:
// out/system/framework/boot.art out/system/framework/boot.oat
}
func ExampleOutputPath_FileInSameDir() {
ctx := &configErrorWrapper{
config: TestConfig("out", nil),
}
p := PathForOutput(ctx, "system/framework/boot.art")
p2 := p.InSameDir(ctx, "oat", "arm", "boot.vdex")
fmt.Println(p, p2)
// Output:
// out/system/framework/boot.art out/system/framework/oat/arm/boot.vdex
}