diff options
author | Russ Cox <rsc@golang.org> | 2010-01-22 17:06:20 -0800 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2010-01-22 17:06:20 -0800 |
commit | a5b02d4bb66ff7269bdaca033382498c2a64eee9 (patch) | |
tree | c53ac65c567f463be044834b10f08f7f77dd405e /src/cmd/gotest | |
parent | ca3ec49f2cbf333bb7acb104778ec18693cf7038 (diff) | |
download | golang-a5b02d4bb66ff7269bdaca033382498c2a64eee9.tar.gz |
eliminate the package global name space assumption in object files
5g/6g/8g: add import statements to export metadata, mapping package path to package name.
recognize "" as the path of the package in export metadata.
use "" as the path of the package in object symbol names.
5c/6c/8c, 5a/6a/8a: rewrite leading . to "". so that ·Sin means Sin in this package.
5l/6l/8l: rewrite "" in symbol names as object files are read.
gotest: handle new symbol names.
gopack: handle new import lines in export metadata.
Collectively, these changes eliminate the assumption of a global
name space in the object file formats. Higher level pieces such as
reflect and the computation of type hashes still depend on the
assumption; we're not done yet.
R=ken2, r, ken3
CC=golang-dev
http://codereview.appspot.com/186263
Committer: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/cmd/gotest')
-rwxr-xr-x | src/cmd/gotest/gotest | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/cmd/gotest/gotest b/src/cmd/gotest/gotest index cb0a2cdd9..b97551309 100755 --- a/src/cmd/gotest/gotest +++ b/src/cmd/gotest/gotest @@ -109,20 +109,41 @@ trap "rm -f _testmain.go _testmain.$O" 0 1 2 3 14 15 MAKEFLAGS= MAKELEVEL= +# usage: nmgrep pattern file... +nmgrep() { + pat="$1" + shift + for i + do + # Package symbol "".Foo is pkg.Foo when imported in Go. + # Figure out pkg. + case "$i" in + *.a) + pkg=$(gopack p $i __.PKGDEF | sed -n 's/^package //p' | sed 1q) + ;; + *) + pkg=$(sed -n 's/^ .* in package "\(.*\)".*/\1/p' $i | sed 1q) + ;; + esac + "$GOBIN"/6nm -s "$i" | egrep ' T .*\.'"$pat"'$' | + sed 's/.* //; /\..*\./d; s/""\./'"$pkg"'./g' + done +} + importpath=$("$GOBIN"/gomake -s importpath) { # test functions are named TestFoo # the grep -v eliminates methods and other special names # that have multiple dots. pattern='Test([^a-z].*)?' - tests=$("$GOBIN"/6nm -s _test/$importpath.a $xofile | egrep ' T .*\.'$pattern'$' | sed 's/.* //; /\..*\./d') + tests=$(nmgrep $pattern _test/$importpath.a $xofile) if [ "x$tests" = x ]; then echo 'gotest: error: no tests matching '$pattern in _test/$importpath.a $xofile 1>&2 exit 2 fi # benchmarks are named BenchmarkFoo. pattern='Benchmark([^a-z].*)?' - benchmarks=$("$GOBIN"/6nm -s _test/$importpath.a $xofile | egrep ' T .*\.'$pattern'$' | sed 's/.* //; /\..*\./d') + benchmarks=$(nmgrep $pattern _test/$importpath.a $xofile) # package spec echo 'package main' |