diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2021-06-21 14:33:26 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2021-06-21 14:33:26 +0000 |
commit | 9af8ba1f5598f9941a32831ad4cffc3b3cf0fa99 (patch) | |
tree | 73936aba47fe1dc71e9cc05af9747036e935608c /compiler_wrapper/compiler_wrapper_test.go | |
parent | b75f321fc8978b92ce3db6886ccb966768f0c7a8 (diff) | |
parent | 4e4201457e5f51a132101c611c79ccff9f713c8b (diff) | |
download | toolchain-utils-9af8ba1f5598f9941a32831ad4cffc3b3cf0fa99.tar.gz |
Snap for 7478028 from 4e4201457e5f51a132101c611c79ccff9f713c8b to mainline-documentsui-releaseandroid-mainline-12.0.0_r26android-mainline-12.0.0_r2aml_doc_310851020android12-mainline-documentsui-release
Change-Id: I5870264b834cfaf67936f2de5c515b264f04d354
Diffstat (limited to 'compiler_wrapper/compiler_wrapper_test.go')
-rw-r--r-- | compiler_wrapper/compiler_wrapper_test.go | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/compiler_wrapper/compiler_wrapper_test.go b/compiler_wrapper/compiler_wrapper_test.go index 67cbda92..52b92f56 100644 --- a/compiler_wrapper/compiler_wrapper_test.go +++ b/compiler_wrapper/compiler_wrapper_test.go @@ -148,3 +148,53 @@ func TestPrintOtherCompilerError(t *testing.T) { t.Errorf("Unexpected string. Got: %s", buffer.String()) } } + +func TestPrintOtherCompilerErrorForAndroidLLVM(t *testing.T) { + buffer := bytes.Buffer{} + + oldConfigName := ConfigName + defer func() { ConfigName = oldConfigName }() + + ConfigName = "android" + printCompilerError(&buffer, errors.New("abcd")) + if buffer.String() != "Internal error. Please report to android-llvm@google.com.\nabcd\n" { + t.Errorf("Unexpected string. Got: %s", buffer.String()) + } +} + +func TestCalculateAndroidWrapperPath(t *testing.T) { + t.Parallel() + + testCases := []struct { + mainBuilderPath string + absWrapperPath string + want string + }{ + { + mainBuilderPath: "/foo/bar", + absWrapperPath: "/bar/baz", + want: "/foo/baz.real", + }, + { + mainBuilderPath: "/my_wrapper", + absWrapperPath: "/bar/baz", + want: "/baz.real", + }, + { + mainBuilderPath: "no_seps", + absWrapperPath: "/bar/baz", + want: "baz.real", + }, + { + mainBuilderPath: "./a_sep", + absWrapperPath: "/bar/baz", + want: "./baz.real", + }, + } + + for _, tc := range testCases { + if result := calculateAndroidWrapperPath(tc.mainBuilderPath, tc.absWrapperPath); result != tc.want { + t.Errorf("Failed calculating the wrapper path with (%q, %q); got %q, want %q", tc.mainBuilderPath, tc.absWrapperPath, result, tc.want) + } + } +} |