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
38320199
Commit
38320199
authored
Aug 06, 2015
by
Felix Lange
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
common/compiler, common/docserver, jsre: fix tests on windows
parent
eae11919
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
17 deletions
+38
-17
solidity_test.go
common/compiler/solidity_test.go
+3
-2
docserver.go
common/docserver/docserver.go
+0
-1
docserver_test.go
common/docserver/docserver_test.go
+13
-6
jsre_test.go
jsre/jsre_test.go
+22
-8
No files found.
common/compiler/solidity_test.go
View file @
38320199
...
...
@@ -20,6 +20,7 @@ import (
"encoding/json"
"io/ioutil"
"os"
"path"
"testing"
"github.com/ethereum/go-ethereum/common"
...
...
@@ -94,7 +95,7 @@ func TestSaveInfo(t *testing.T) {
if
err
!=
nil
{
t
.
Errorf
(
"%v"
,
err
)
}
filename
:=
"/tmp/solctest.info.json"
filename
:=
path
.
Join
(
os
.
TempDir
(),
"solctest.info.json"
)
os
.
Remove
(
filename
)
cinfohash
,
err
:=
SaveInfo
(
&
cinfo
,
filename
)
if
err
!=
nil
{
...
...
common/docserver/docserver.go
View file @
38320199
...
...
@@ -38,7 +38,6 @@ func New(docRoot string) (self *DocServer) {
DocRoot
:
docRoot
,
schemes
:
[]
string
{
"file"
},
}
self
.
DocRoot
=
"/tmp/"
self
.
RegisterProtocol
(
"file"
,
http
.
NewFileTransport
(
http
.
Dir
(
self
.
DocRoot
)))
return
}
...
...
common/docserver/docserver_test.go
View file @
38320199
...
...
@@ -20,6 +20,7 @@ import (
"io/ioutil"
"net/http"
"os"
"path"
"testing"
"github.com/ethereum/go-ethereum/common"
...
...
@@ -27,12 +28,18 @@ import (
)
func
TestGetAuthContent
(
t
*
testing
.
T
)
{
text
:=
"test"
hash
:=
common
.
Hash
{}
copy
(
hash
[
:
],
crypto
.
Sha3
([]
byte
(
text
)))
ioutil
.
WriteFile
(
"/tmp/test.content"
,
[]
byte
(
text
),
os
.
ModePerm
)
dir
,
err
:=
ioutil
.
TempDir
(
""
,
"docserver-test"
)
if
err
!=
nil
{
t
.
Fatal
(
"cannot create temporary directory:"
,
err
)
}
defer
os
.
RemoveAll
(
dir
)
ds
:=
New
(
dir
)
ds
:=
New
(
"/tmp/"
)
text
:=
"test"
hash
:=
crypto
.
Sha3Hash
([]
byte
(
text
))
if
err
:=
ioutil
.
WriteFile
(
path
.
Join
(
dir
,
"test.content"
),
[]
byte
(
text
),
os
.
ModePerm
);
err
!=
nil
{
t
.
Fatal
(
"could not write test file"
,
err
)
}
content
,
err
:=
ds
.
GetAuthContent
(
"file:///test.content"
,
hash
)
if
err
!=
nil
{
t
.
Errorf
(
"no error expected, got %v"
,
err
)
...
...
jsre/jsre_test.go
View file @
38320199
...
...
@@ -19,6 +19,7 @@ package jsre
import
(
"io/ioutil"
"os"
"path"
"testing"
"time"
...
...
@@ -40,10 +41,23 @@ func (no *testNativeObjectBinding) TestMethod(call otto.FunctionCall) otto.Value
return
v
}
func
newWithTestJS
(
t
*
testing
.
T
,
testjs
string
)
(
*
JSRE
,
string
)
{
dir
,
err
:=
ioutil
.
TempDir
(
""
,
"jsre-test"
)
if
err
!=
nil
{
t
.
Fatal
(
"cannot create temporary directory:"
,
err
)
}
if
testjs
!=
""
{
if
err
:=
ioutil
.
WriteFile
(
path
.
Join
(
dir
,
"test.js"
),
[]
byte
(
testjs
),
os
.
ModePerm
);
err
!=
nil
{
t
.
Fatal
(
"cannot create test.js:"
,
err
)
}
}
return
New
(
dir
),
dir
}
func
TestExec
(
t
*
testing
.
T
)
{
jsre
:=
New
(
"/tmp"
)
jsre
,
dir
:=
newWithTestJS
(
t
,
`msg = "testMsg"`
)
defer
os
.
RemoveAll
(
dir
)
ioutil
.
WriteFile
(
"/tmp/test.js"
,
[]
byte
(
`msg = "testMsg"`
),
os
.
ModePerm
)
err
:=
jsre
.
Exec
(
"test.js"
)
if
err
!=
nil
{
t
.
Errorf
(
"expected no error, got %v"
,
err
)
...
...
@@ -64,9 +78,9 @@ func TestExec(t *testing.T) {
}
func
TestNatto
(
t
*
testing
.
T
)
{
jsre
:=
New
(
"/tmp"
)
jsre
,
dir
:=
newWithTestJS
(
t
,
`setTimeout(function(){msg = "testMsg"}, 1);`
)
defer
os
.
RemoveAll
(
dir
)
ioutil
.
WriteFile
(
"/tmp/test.js"
,
[]
byte
(
`setTimeout(function(){msg = "testMsg"}, 1);`
),
os
.
ModePerm
)
err
:=
jsre
.
Exec
(
"test.js"
)
if
err
!=
nil
{
t
.
Errorf
(
"expected no error, got %v"
,
err
)
...
...
@@ -88,7 +102,7 @@ func TestNatto(t *testing.T) {
}
func
TestBind
(
t
*
testing
.
T
)
{
jsre
:=
New
(
"
/tmp
"
)
jsre
:=
New
(
""
)
jsre
.
Bind
(
"no"
,
&
testNativeObjectBinding
{})
...
...
@@ -105,9 +119,9 @@ func TestBind(t *testing.T) {
}
func
TestLoadScript
(
t
*
testing
.
T
)
{
jsre
:=
New
(
"/tmp"
)
jsre
,
dir
:=
newWithTestJS
(
t
,
`msg = "testMsg"`
)
defer
os
.
RemoveAll
(
dir
)
ioutil
.
WriteFile
(
"/tmp/test.js"
,
[]
byte
(
`msg = "testMsg"`
),
os
.
ModePerm
)
_
,
err
:=
jsre
.
Run
(
`loadScript("test.js")`
)
if
err
!=
nil
{
t
.
Errorf
(
"expected no error, got %v"
,
err
)
...
...
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