-
Notifications
You must be signed in to change notification settings - Fork 18.1k
cmd/link: TestLargeText in linkbig_test.go does not look right #45406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
TestLargeText
in linkbig_test.go
does not look right
CC @laboger |
I can fix the chdir stuff that doesn't look right. I can check the module issue. |
@laboger, no, I was not suggesting to enable it for amd64. I just forced the test to run on Linux amd64 and I got that module issue, but it is strange that the build bots don't report it. Thanks. |
By the way, is |
Here a patch to remove the use of diff --git a/src/cmd/link/linkbig_test.go b/src/cmd/link/linkbig_test.go
index d5d77d6c72..577fe0daae 100644
--- a/src/cmd/link/linkbig_test.go
+++ b/src/cmd/link/linkbig_test.go
@@ -14,7 +14,6 @@ import (
"fmt"
"internal/testenv"
"io/ioutil"
- "os"
"os/exec"
"testing"
)
@@ -80,26 +79,28 @@ func TestLargeText(t *testing.T) {
}
// Build and run with internal linking.
- os.Chdir(tmpdir)
cmd := exec.Command(testenv.GoToolPath(t), "build", "-o", "bigtext")
+ cmd.Dir = tmpdir
out, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("Build failed for big text program with internal linking: %v, output: %s", err, out)
}
- cmd = exec.Command(tmpdir + "/bigtext")
+ cmd = exec.Command("./bigtext")
+ cmd.Dir = tmpdir
out, err = cmd.CombinedOutput()
if err != nil {
t.Fatalf("Program built with internal linking failed to run with err %v, output: %s", err, out)
}
// Build and run with external linking
- os.Chdir(tmpdir)
- cmd = exec.Command(testenv.GoToolPath(t), "build", "-o", "bigtext", "-ldflags", "'-linkmode=external'")
+ cmd = exec.Command(testenv.GoToolPath(t), "build", "-o", "bigtext-ext", "-ldflags", "'-linkmode=external'")
+ cmd.Dir = tmpdir
out, err = cmd.CombinedOutput()
if err != nil {
t.Fatalf("Build failed for big text program with external linking: %v, output: %s", err, out)
}
- cmd = exec.Command(tmpdir + "/bigtext")
+ cmd = exec.Command("./bigtext-ext")
+ cmd.Dir = tmpdir
out, err = cmd.CombinedOutput()
if err != nil {
t.Fatalf("Program built with external linking failed to run with err %v, output: %s", err, out) Setting |
Change https://golang.org/cl/308935 mentions this issue: |
Uh oh!
There was an error while loading. Please reload this page.
What version of Go are you using (
go version
)?The
TestLargeText
seems to have some problems:os.Chdir
without checking the erroros.Chdir
later, instead of calling it early (allowing a simplification of the code)os.Chdir(tmpdir)
twiceHere is a patch that will allow the use of the
chtmpdir
function (see #45182).os.Chdir
error handling and working directory restoration is not included.It uses relative paths, since we have chdir early.
Commenting the code that skip the test on my system (linux amd64), the test works, but I'm not sure if there was a good reason for the current implementation.
However I have found an additional issue: the test only works if
GO111MODULE=off
, otherwise the test fails withand all the tests that follow (when executing
run.bash
) fails withThe text was updated successfully, but these errors were encountered: