aboutsummaryrefslogtreecommitdiff
path: root/compiler_wrapper/compiler_wrapper_test.go
diff options
context:
space:
mode:
authorTobias Bosch <tbosch@google.com>2019-10-28 14:26:51 -0700
committerTobias Bosch <tbosch@google.com>2019-11-01 00:05:45 +0000
commit8dd67e1063927b99ee18caa11ccee9abc1c0cbd1 (patch)
treec4a14c61db6294de2b58ab1b7b09d28c656fc047 /compiler_wrapper/compiler_wrapper_test.go
parentb922860193acc4c2f5c9ae28e29f0f33deffcd1b (diff)
downloadtoolchain-utils-8dd67e1063927b99ee18caa11ccee9abc1c0cbd1.tar.gz
toolchain_utils: Remove comparison to old wrapper from compiler_wrapper.
BUG=chromium:773875 TEST='go test' passes Change-Id: Iecbe15067bf37fd86fbb8a907d42df32288821d6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1884701 Reviewed-by: George Burgess <gbiv@chromium.org> Tested-by: Tobias Bosch <tbosch@google.com>
Diffstat (limited to 'compiler_wrapper/compiler_wrapper_test.go')
-rw-r--r--compiler_wrapper/compiler_wrapper_test.go80
1 files changed, 16 insertions, 64 deletions
diff --git a/compiler_wrapper/compiler_wrapper_test.go b/compiler_wrapper/compiler_wrapper_test.go
index 71cd36df..67cbda92 100644
--- a/compiler_wrapper/compiler_wrapper_test.go
+++ b/compiler_wrapper/compiler_wrapper_test.go
@@ -9,7 +9,6 @@ import (
"errors"
"fmt"
"io"
- "path/filepath"
"strings"
"syscall"
"testing"
@@ -50,27 +49,18 @@ func TestAddClangConfigFlags(t *testing.T) {
func TestLogGeneralExecError(t *testing.T) {
withTestContext(t, func(ctx *testContext) {
- testOldWrapperPaths := []string{
- "",
- filepath.Join(ctx.tempDir, "fakewrapper"),
- }
- for _, testOldWrapperPath := range testOldWrapperPaths {
- ctx.cfg.oldWrapperPath = testOldWrapperPath
- // Note: No need to write the old wrapper as we don't execute
- // it due to the general error from the new error.
- ctx.cmdMock = func(cmd *command, stdin io.Reader, stdout io.Writer, stderr io.Writer) error {
- return errors.New("someerror")
- }
- stderr := ctx.mustFail(callCompiler(ctx, ctx.cfg, ctx.newCommand(gccX86_64, mainCc)))
- if err := verifyInternalError(stderr); err != nil {
- t.Fatal(err)
- }
- if !strings.Contains(stderr, gccX86_64) {
- t.Errorf("could not find compiler path on stderr. Got: %s", stderr)
- }
- if !strings.Contains(stderr, "someerror") {
- t.Errorf("could not find original error on stderr. Got: %s", stderr)
- }
+ ctx.cmdMock = func(cmd *command, stdin io.Reader, stdout io.Writer, stderr io.Writer) error {
+ return errors.New("someerror")
+ }
+ stderr := ctx.mustFail(callCompiler(ctx, ctx.cfg, ctx.newCommand(gccX86_64, mainCc)))
+ if err := verifyInternalError(stderr); err != nil {
+ t.Fatal(err)
+ }
+ if !strings.Contains(stderr, gccX86_64) {
+ t.Errorf("could not find compiler path on stderr. Got: %s", stderr)
+ }
+ if !strings.Contains(stderr, "someerror") {
+ t.Errorf("could not find original error on stderr. Got: %s", stderr)
}
})
}
@@ -93,50 +83,12 @@ func TestLogMissingCCacheExecError(t *testing.T) {
withTestContext(t, func(ctx *testContext) {
ctx.cfg.useCCache = true
- testOldWrapperPaths := []string{
- "",
- filepath.Join(ctx.tempDir, "fakewrapper"),
- }
- for _, testOldWrapperPath := range testOldWrapperPaths {
- ctx.cfg.oldWrapperPath = testOldWrapperPath
- // Note: No need to write the old wrapper as we don't execute
- // it due to the general error from the new error.
- ctx.cmdMock = func(cmd *command, stdin io.Reader, stdout io.Writer, stderr io.Writer) error {
- return syscall.ENOENT
- }
- ctx.stderrBuffer.Reset()
- stderr := ctx.mustFail(callCompiler(ctx, ctx.cfg, ctx.newCommand(gccX86_64, mainCc)))
- if err := verifyNonInternalError(stderr, "ccache not found under .*. Please install it"); err != nil {
- t.Fatal(err)
- }
- }
- })
-}
-
-func TestLogExitCodeErrorWhenComparingToOldWrapper(t *testing.T) {
- withTestContext(t, func(ctx *testContext) {
- ctx.cfg.mockOldWrapperCmds = false
- ctx.cfg.oldWrapperPath = filepath.Join(ctx.tempDir, "fakewrapper")
-
ctx.cmdMock = func(cmd *command, stdin io.Reader, stdout io.Writer, stderr io.Writer) error {
- writePythonMockWrapper(ctx, &mockWrapperConfig{
- Cmds: []*mockWrapperCmd{
- {
- Path: cmd.Path,
- Args: cmd.Args,
- ExitCode: 2,
- },
- },
- })
- fmt.Fprint(stderr, "someerror")
- return newExitCodeError(2)
+ return syscall.ENOENT
}
-
- exitCode := callCompiler(ctx, ctx.cfg, ctx.newCommand(gccX86_64, mainCc))
- if exitCode != 2 {
- t.Fatalf("Expected exit code 2. Got: %d", exitCode)
- }
- if err := verifyNonInternalError(ctx.stderrString(), "someerror"); err != nil {
+ ctx.stderrBuffer.Reset()
+ stderr := ctx.mustFail(callCompiler(ctx, ctx.cfg, ctx.newCommand(gccX86_64, mainCc)))
+ if err := verifyNonInternalError(stderr, "ccache not found under .*. Please install it"); err != nil {
t.Fatal(err)
}
})