Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
9d3db4b6
Commit
9d3db4b6
authored
Feb 03, 2011
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gotest: enable unit tests for cmd directories
R=r CC=golang-dev
https://golang.org/cl/4001056
parent
c1a695c1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
16 deletions
+49
-16
Make.cmd
src/Make.cmd
+19
-0
gotest
src/cmd/gotest/gotest
+30
-16
No files found.
src/Make.cmd
View file @
9d3db4b6
...
...
@@ -27,3 +27,22 @@ CLEANFILES+=$(TARG)
nuke: clean
rm -f $(QUOTED_GOBIN)/$(TARG)
# for gotest
testpackage: _test/main.a
testpackage-clean:
rm -f _test/main.a _gotest_.$O
testpackage: _test/main.a
_test/main.a: _gotest_.$O
@mkdir -p _test
rm -f $@
gopack grc $@ _gotest_.$O
_gotest_.$O: $(GOFILES) $(GOTESTFILES)
$(GC) -o $@ $(GOFILES) $(GOTESTFILES)
importpath:
echo main
src/cmd/gotest/gotest
View file @
9d3db4b6
...
...
@@ -119,6 +119,12 @@ nmgrep() {
done
}
localname
()
{
# The package main has been renamed to __main__ when imported.
# Adjust its uses.
echo
$1
|
sed
's/^main\./__main__./'
}
importpath
=
$(
gomake
-s
importpath
)
{
# test functions are named TestFoo
...
...
@@ -139,9 +145,20 @@ importpath=$(gomake -s importpath)
echo
# imports
if
echo
"
$tests
"
| egrep
-v
'_test\.'
>
/dev/null
;
then
if
[
"
$importpath
"
!=
"testing"
]
;
then
case
"
$importpath
"
in
testing
)
;;
main
)
# Import path main is reserved, so import with
# explicit reference to ./_test/main instead.
# Also, the file we are writing defines a function named main,
# so rename this import to __main__ to avoid name conflict.
echo
'import __main__ "./_test/main"'
;;
*
)
echo
'import "'
$importpath
'"'
fi
;;
esac
fi
if
$havex
;
then
echo
'import "./_xtest_"'
...
...
@@ -153,23 +170,20 @@ importpath=$(gomake -s importpath)
echo
'var tests = []testing.InternalTest{'
for
i
in
$tests
do
echo
' {"'
$i
'", '
$i
'},'
j
=
$(
localname
$i
)
echo
' {"'
$i
'", '
$j
'},'
done
echo
'}'
# benchmark array
if
[
"
$benchmarks
"
=
""
]
then
# keep the empty array gofmt-safe.
# (not an issue for the test array, which is never empty.)
echo
'var benchmarks = []testing.InternalBenchmark{}'
else
echo
'var benchmarks = []testing.InternalBenchmark{'
for
i
in
$benchmarks
do
echo
' {"'
$i
'", '
$i
'},'
done
echo
'}'
fi
# The comment makes the multiline declaration
# gofmt-safe even when there are no benchmarks.
echo
'var benchmarks = []testing.InternalBenchmark{ //'
for
i
in
$benchmarks
do
j
=
$(
localname
$i
)
echo
' {"'
$i
'", '
$j
'},'
done
echo
'}'
# body
echo
echo
'func main() {'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment