cmd/link: skip TestOldLink if the old linker does not exist

We don't ship the old linker in binary releases. Skip the test if
we cannot find the old linker.

Fixes #39509.

Change-Id: I1af5552bc56aff5314a384bcb5f3717b725d68e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/242604
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
This commit is contained in:
Cherry Zhang 2020-07-14 18:55:29 -04:00
parent fa98f46741
commit c5d7f2f1cb

View File

@ -541,6 +541,13 @@ func TestOldLink(t *testing.T) {
testenv.MustHaveGoBuild(t)
// Check that the old linker exists (we don't ship it in binary releases,
// see issue 39509).
cmd := exec.Command(testenv.GoToolPath(t), "tool", "-n", "oldlink")
if err := cmd.Run(); err != nil {
t.Skip("skipping because cannot find installed cmd/oldlink binary")
}
tmpdir, err := ioutil.TempDir("", "TestOldLink")
if err != nil {
t.Fatal(err)
@ -553,7 +560,7 @@ func TestOldLink(t *testing.T) {
t.Fatal(err)
}
cmd := exec.Command(testenv.GoToolPath(t), "run", "-gcflags=all=-go115newobj=false", "-asmflags=all=-go115newobj=false", "-ldflags=-go115newobj=false", src)
cmd = exec.Command(testenv.GoToolPath(t), "run", "-gcflags=all=-go115newobj=false", "-asmflags=all=-go115newobj=false", "-ldflags=-go115newobj=false", src)
if out, err := cmd.CombinedOutput(); err != nil {
t.Errorf("%v: %v:\n%s", cmd.Args, err, out)
}