aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-08-06 22:19:09 +0800
committerFelix Lange <fjl@twurst.com>2015-08-06 23:18:59 +0800
commit383201996463ddb91aa754f81d00d472e3436380 (patch)
treef9f32bd48949b85a14594f57a01de528d8695e02 /common
parenteae1191904fd739cdffdd2903509a44a35c4c2f2 (diff)
downloaddexon-383201996463ddb91aa754f81d00d472e3436380.tar
dexon-383201996463ddb91aa754f81d00d472e3436380.tar.gz
dexon-383201996463ddb91aa754f81d00d472e3436380.tar.bz2
dexon-383201996463ddb91aa754f81d00d472e3436380.tar.lz
dexon-383201996463ddb91aa754f81d00d472e3436380.tar.xz
dexon-383201996463ddb91aa754f81d00d472e3436380.tar.zst
dexon-383201996463ddb91aa754f81d00d472e3436380.zip
common/compiler, common/docserver, jsre: fix tests on windows
Diffstat (limited to 'common')
-rw-r--r--common/compiler/solidity_test.go5
-rw-r--r--common/docserver/docserver.go1
-rw-r--r--common/docserver/docserver_test.go19
3 files changed, 16 insertions, 9 deletions
diff --git a/common/compiler/solidity_test.go b/common/compiler/solidity_test.go
index 8255e8e2d..3303bc15a 100644
--- a/common/compiler/solidity_test.go
+++ b/common/compiler/solidity_test.go
@@ -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 {
@@ -110,4 +111,4 @@ func TestSaveInfo(t *testing.T) {
if cinfohash != infohash {
t.Errorf("content hash for info is incorrect. expected %v, got %v", infohash.Hex(), cinfohash.Hex())
}
-}
+} \ No newline at end of file
diff --git a/common/docserver/docserver.go b/common/docserver/docserver.go
index fa120fb38..dac542ba7 100644
--- a/common/docserver/docserver.go
+++ b/common/docserver/docserver.go
@@ -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
}
diff --git a/common/docserver/docserver_test.go b/common/docserver/docserver_test.go
index 92e39d167..632603add 100644
--- a/common/docserver/docserver_test.go
+++ b/common/docserver/docserver_test.go
@@ -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)
@@ -67,4 +74,4 @@ func TestRegisterScheme(t *testing.T) {
if !ds.HasScheme("scheme") {
t.Errorf("expected scheme to be registered")
}
-}
+} \ No newline at end of file