Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
c2bbff61
Commit
c2bbff61
authored
Mar 31, 2016
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
accounts/abi/bind: merge all tests into a single suite
parent
787d688c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
22 deletions
+22
-22
bind_test.go
accounts/abi/bind/bind_test.go
+22
-22
No files found.
accounts/abi/bind/bind_test.go
View file @
c2bbff61
...
@@ -247,41 +247,41 @@ func TestBindings(t *testing.T) {
...
@@ -247,41 +247,41 @@ func TestBindings(t *testing.T) {
if
!
strings
.
Contains
(
string
(
linkTestDeps
),
"go-ethereum"
)
{
if
!
strings
.
Contains
(
string
(
linkTestDeps
),
"go-ethereum"
)
{
t
.
Skip
(
"symlinked environment doesn't support bind (https://github.com/golang/go/issues/14845)"
)
t
.
Skip
(
"symlinked environment doesn't support bind (https://github.com/golang/go/issues/14845)"
)
}
}
// All is well, run the tests
// Create a temporary workspace for the test suite
for
i
,
tt
:=
range
bindTests
{
ws
,
err
:=
ioutil
.
TempDir
(
""
,
""
)
// Create a temporary workspace for this test
if
err
!=
nil
{
ws
,
err
:=
ioutil
.
TempDir
(
""
,
""
)
t
.
Fatalf
(
"failed to create temporary workspace: %v"
,
err
)
if
err
!=
nil
{
}
t
.
Fatalf
(
"test %d: failed to create temporary workspace: %v"
,
i
,
err
)
defer
os
.
RemoveAll
(
ws
)
}
defer
os
.
RemoveAll
(
ws
)
// Generate the binding and create a Go package in the workspace
pkg
:=
filepath
.
Join
(
ws
,
"bindtest"
)
if
err
=
os
.
MkdirAll
(
pkg
,
0700
);
err
!=
nil
{
t
.
Fatalf
(
"failed to create package: %v"
,
err
)
}
// Generate the test suite for all the contracts
for
i
,
tt
:=
range
bindTests
{
// Generate the binding and create a Go source file in the workspace
bind
,
err
:=
Bind
([]
string
{
tt
.
name
},
[]
string
{
tt
.
abi
},
[]
string
{
tt
.
bytecode
},
"bindtest"
)
bind
,
err
:=
Bind
([]
string
{
tt
.
name
},
[]
string
{
tt
.
abi
},
[]
string
{
tt
.
bytecode
},
"bindtest"
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"test %d: failed to generate binding: %v"
,
i
,
err
)
t
.
Fatalf
(
"test %d: failed to generate binding: %v"
,
i
,
err
)
}
}
pkg
:=
filepath
.
Join
(
ws
,
"bindtest"
)
if
err
=
ioutil
.
WriteFile
(
filepath
.
Join
(
pkg
,
strings
.
ToLower
(
tt
.
name
)
+
".go"
),
[]
byte
(
bind
),
0600
);
err
!=
nil
{
if
err
=
os
.
MkdirAll
(
pkg
,
0700
);
err
!=
nil
{
t
.
Fatalf
(
"test %d: failed to create package: %v"
,
i
,
err
)
}
if
err
=
ioutil
.
WriteFile
(
filepath
.
Join
(
pkg
,
"main.go"
),
[]
byte
(
bind
),
0600
);
err
!=
nil
{
t
.
Fatalf
(
"test %d: failed to write binding: %v"
,
i
,
err
)
t
.
Fatalf
(
"test %d: failed to write binding: %v"
,
i
,
err
)
}
}
// Generate the test file with the injected test code
// Generate the test file with the injected test code
code
:=
fmt
.
Sprintf
(
"package bindtest
\n
import
\"
testing
\"\n
func Test
Binding%d(t *testing.T){
\n
%s
\n
}"
,
i
,
tt
.
tester
)
code
:=
fmt
.
Sprintf
(
"package bindtest
\n
import
\"
testing
\"\n
func Test
%s(t *testing.T){
\n
%s
\n
}"
,
tt
.
name
,
tt
.
tester
)
blob
,
err
:=
imports
.
Process
(
""
,
[]
byte
(
code
),
nil
)
blob
,
err
:=
imports
.
Process
(
""
,
[]
byte
(
code
),
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"test %d: failed to generate tests: %v"
,
i
,
err
)
t
.
Fatalf
(
"test %d: failed to generate tests: %v"
,
i
,
err
)
}
}
if
err
:=
ioutil
.
WriteFile
(
filepath
.
Join
(
pkg
,
"main
_test.go"
),
blob
,
0600
);
err
!=
nil
{
if
err
:=
ioutil
.
WriteFile
(
filepath
.
Join
(
pkg
,
strings
.
ToLower
(
tt
.
name
)
+
"
_test.go"
),
blob
,
0600
);
err
!=
nil
{
t
.
Fatalf
(
"test %d: failed to write tests: %v"
,
i
,
err
)
t
.
Fatalf
(
"test %d: failed to write tests: %v"
,
i
,
err
)
}
}
// Test the entire package and report any failures
}
cmd
:=
exec
.
Command
(
gocmd
,
"test"
,
"-v"
)
// Test the entire package and report any failures
cmd
.
Dir
=
pkg
cmd
:=
exec
.
Command
(
gocmd
,
"test"
,
"-v"
)
if
out
,
err
:=
cmd
.
CombinedOutput
();
err
!=
nil
{
cmd
.
Dir
=
pkg
t
.
Fatalf
(
"test %d: failed to run binding test: %v
\n
%s
\n
%s"
,
i
,
err
,
out
,
bind
)
if
out
,
err
:=
cmd
.
CombinedOutput
();
err
!=
nil
{
}
t
.
Fatalf
(
"failed to run binding test: %v
\n
%s"
,
err
,
out
)
}
}
}
}
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