diff options
author | Michael Matloob <matloob@golang.org> | 2022-09-21 15:51:27 -0400 |
---|---|---|
committer | Michael Matloob <matloob@golang.org> | 2022-10-12 23:16:41 +0000 |
commit | 6f445a9db55f65e55c5be29d3c506ecf3be37915 (patch) | |
tree | ab724d4e441708257a4a5cf4141964c6b63238bf /test/linkmain_run.go | |
parent | 0ae042f977942a60d7955bc10bf654835e47e12a (diff) | |
download | go-6f445a9db55f65e55c5be29d3c506ecf3be37915.tar.gz go-6f445a9db55f65e55c5be29d3c506ecf3be37915.zip |
test: update test/run.go and some tests to use importcfg
Using importcfg instead of depending on the existence of .a files for
standard library packages will enable us to remove the .a files in a
future cl.
Change-Id: I6108384224508bc37d82fd990fc4a8649222502c
Reviewed-on: https://go-review.googlesource.com/c/go/+/440222
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'test/linkmain_run.go')
-rw-r--r-- | test/linkmain_run.go | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/test/linkmain_run.go b/test/linkmain_run.go index 6bc82dfafc..f4f6c4320e 100644 --- a/test/linkmain_run.go +++ b/test/linkmain_run.go @@ -61,16 +61,23 @@ func main() { return filepath.Join(tmpDir, name) } + importcfg, err := exec.Command("go", "list", "-export", "-f", "{{if .Export}}packagefile {{.ImportPath}}={{.Export}}{{end}}", "std").Output() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + os.WriteFile(tmp("importcfg"), importcfg, 0644) + // helloworld.go is package main - run("go tool compile -p=main -o", tmp("linkmain.o"), "helloworld.go") - run("go tool compile -p=main -pack -o", tmp("linkmain.a"), "helloworld.go") - run("go tool link -o", tmp("linkmain.exe"), tmp("linkmain.o")) - run("go tool link -o", tmp("linkmain.exe"), tmp("linkmain.a")) + run("go tool compile -p=main -importcfg", tmp("importcfg"), "-o", tmp("linkmain.o"), "helloworld.go") + run("go tool compile -p=main -importcfg", tmp("importcfg"), " -pack -o", tmp("linkmain.a"), "helloworld.go") + run("go tool link -importcfg", tmp("importcfg"), "-o", tmp("linkmain.exe"), tmp("linkmain.o")) + run("go tool link -importcfg", tmp("importcfg"), "-o", tmp("linkmain.exe"), tmp("linkmain.a")) // linkmain.go is not - run("go tool compile -p=notmain -o", tmp("linkmain1.o"), "linkmain.go") - run("go tool compile -p=notmain -pack -o", tmp("linkmain1.a"), "linkmain.go") - runFail("go tool link -o", tmp("linkmain.exe"), tmp("linkmain1.o")) - runFail("go tool link -o", tmp("linkmain.exe"), tmp("linkmain1.a")) + run("go tool compile -importcfg", tmp("importcfg"), "-p=notmain -o", tmp("linkmain1.o"), "linkmain.go") + run("go tool compile -importcfg", tmp("importcfg"), "-p=notmain -pack -o", tmp("linkmain1.a"), "linkmain.go") + runFail("go tool link -importcfg", tmp("importcfg"), "-o", tmp("linkmain.exe"), tmp("linkmain1.o")) + runFail("go tool link -importcfg", tmp("importcfg"), "-o", tmp("linkmain.exe"), tmp("linkmain1.a")) cleanup() } |