summaryrefslogtreecommitdiff
path: root/android/testing.go
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2024-07-26 11:52:57 -0700
committer Colin Cross <ccross@android.com> 2024-07-29 14:00:46 -0700
commit3b1c6847c4920392ca00fe32fe3acc17246eda91 (patch)
tree4aa0292a32e601b3d659a7558345358f92a47fb5 /android/testing.go
parente0aa52f6c720305113fb935386ae53bd4ec81d88 (diff)
Make PathForArbitraryOutput return an OutputPath
The only place basePath is used as a Path is when being returned from PathForArbitraryOutput. Using it as a Path requires implementing the RelativeToTop() method on it, which then allowed that method to be inherited by SourcePath, breaking the contract on RelativeToTop that specifies that the returned Path is of the same concrete type as the input Path. Make PathForArbitraryOutput return an OutputPath, and update OutputPath to support base paths that are not out/soong. This also fixes RelativeToTop, which was previously not working for PathForArbitraryOutput paths. Test: all soong tests pass Flag: EXEMPT refactor Change-Id: Ie8d8e2290961f35280e97137d2bd641c4d57ab87
Diffstat (limited to 'android/testing.go')
-rw-r--r--android/testing.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/android/testing.go b/android/testing.go
index e39a1a749..dae787b7f 100644
--- a/android/testing.go
+++ b/android/testing.go
@@ -822,15 +822,15 @@ func newBaseTestingComponent(config Config, provider testBuildProvider) baseTest
// containing at most one instance of the temporary build directory at the start of the path while
// this assumes that there can be any number at any position.
func normalizeStringRelativeToTop(config Config, s string) string {
- // The soongOutDir usually looks something like: /tmp/testFoo2345/001
+ // The outDir usually looks something like: /tmp/testFoo2345/001
//
- // Replace any usage of the soongOutDir with out/soong, e.g. replace "/tmp/testFoo2345/001" with
+ // Replace any usage of the outDir with out/soong, e.g. replace "/tmp/testFoo2345/001" with
// "out/soong".
outSoongDir := filepath.Clean(config.soongOutDir)
re := regexp.MustCompile(`\Q` + outSoongDir + `\E\b`)
s = re.ReplaceAllString(s, "out/soong")
- // Replace any usage of the soongOutDir/.. with out, e.g. replace "/tmp/testFoo2345" with
+ // Replace any usage of the outDir/.. with out, e.g. replace "/tmp/testFoo2345" with
// "out". This must come after the previous replacement otherwise this would replace
// "/tmp/testFoo2345/001" with "out/001" instead of "out/soong".
outDir := filepath.Dir(outSoongDir)
@@ -1234,8 +1234,14 @@ func StringPathRelativeToTop(soongOutDir string, path string) string {
}
if isRel {
- // The path is in the soong out dir so indicate that in the relative path.
- return filepath.Join("out/soong", rel)
+ if strings.HasSuffix(soongOutDir, testOutSoongSubDir) {
+ // The path is in the soong out dir so indicate that in the relative path.
+ return filepath.Join(TestOutSoongDir, rel)
+ } else {
+ // Handle the PathForArbitraryOutput case
+ return filepath.Join(testOutDir, rel)
+
+ }
}
// Check to see if the path is relative to the top level out dir.