Add (String)Path(s)RelativeToTop and assert functions
The existing NormalizePathForTesting function does not handle make install paths very well, as it returns a relative path with a leading "../" which is very confusing. It also does not clearly differentiate between the different paths. These functions return paths that are basically what are seen in a normal developer build, i.e. * <source path> * out/soong/<soong output path> * out/<make output path> That makes tests that use them easier to understand. Follow up changes will clean up the existing usages of the Normalize... functions. Bug: 182885307 Test: m nothing Change-Id: I17ddc996bef5bbbf4a62da8334ea6ce29e306109
This commit is contained in:
@@ -40,6 +40,34 @@ func AssertStringEquals(t *testing.T, message string, expected string, actual st
|
||||
}
|
||||
}
|
||||
|
||||
// AssertPathRelativeToTopEquals checks if the expected value is equal to the result of calling
|
||||
// PathRelativeToTop on the actual Path.
|
||||
func AssertPathRelativeToTopEquals(t *testing.T, message string, expected string, actual Path) {
|
||||
t.Helper()
|
||||
AssertStringEquals(t, message, expected, PathRelativeToTop(actual))
|
||||
}
|
||||
|
||||
// AssertPathsRelativeToTopEquals checks if the expected value is equal to the result of calling
|
||||
// PathsRelativeToTop on the actual Paths.
|
||||
func AssertPathsRelativeToTopEquals(t *testing.T, message string, expected []string, actual Paths) {
|
||||
t.Helper()
|
||||
AssertDeepEquals(t, message, expected, PathsRelativeToTop(actual))
|
||||
}
|
||||
|
||||
// AssertStringPathRelativeToTopEquals checks if the expected value is equal to the result of calling
|
||||
// StringPathRelativeToTop on the actual string path.
|
||||
func AssertStringPathRelativeToTopEquals(t *testing.T, message string, config Config, expected string, actual string) {
|
||||
t.Helper()
|
||||
AssertStringEquals(t, message, expected, StringPathRelativeToTop(config.buildDir, actual))
|
||||
}
|
||||
|
||||
// AssertStringPathsRelativeToTopEquals checks if the expected value is equal to the result of
|
||||
// calling StringPathsRelativeToTop on the actual string paths.
|
||||
func AssertStringPathsRelativeToTopEquals(t *testing.T, message string, config Config, expected []string, actual []string) {
|
||||
t.Helper()
|
||||
AssertDeepEquals(t, message, expected, StringPathsRelativeToTop(config.buildDir, actual))
|
||||
}
|
||||
|
||||
// AssertErrorMessageEquals checks if the error is not nil and has the expected message. If it does
|
||||
// not then this reports an error prefixed with the supplied message and including a reason for why
|
||||
// it failed.
|
||||
|
Reference in New Issue
Block a user