Fix Rel() after ReplaceExtension or InSameDir

Copying p.rel doesn't work, as rel needs to match the end of the
value in path.  Apply the same transformation to p.rel as p.path.

Test: paths_test.go
Change-Id: I42d676c6c4fc18d9852c1a73f25e5a791d7553d0
This commit is contained in:
Colin Cross
2019-02-25 10:25:24 -08:00
parent 6bd446620c
commit 2cdd5df7cc
4 changed files with 12 additions and 8 deletions

View File

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