Permalink
Browse files

add appveyor.yml (#1381)

* add appveyor.yml

* fix various Windows test failures

* remove some filenames that Windows can't handle

* close serverTester in TestReloading

* remove OS-specific error check

* count lock file in TestStorageFolderUsage

* only skip permissions test on Windows
  • Loading branch information...
1 parent bf0e85a commit c79980f471300b38b787f019251d0746707cdf31 @lukechampine lukechampine committed with DavidVorick Aug 10, 2016
View
@@ -453,8 +453,8 @@ func TestRenterLoadNonexistent(t *testing.T) {
uploadValues := url.Values{}
uploadValues.Set("source", fakepath)
err = st.stdPostAPI("/renter/upload/dne", uploadValues)
- if err == nil || !strings.HasSuffix(err.Error(), "no such file or directory") {
- t.Errorf("expected error to end with 'no such file or directory; got %v", err)
+ if err == nil {
+ t.Errorf("expected error when uploading nonexistent file")
}
// Try downloading a nonexistent file.
View
@@ -39,12 +39,17 @@ func TestReloading(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- defer st.server.Close()
+ height := st.server.cs.Height()
+ err = st.server.Close()
+ if err != nil {
+ t.Fatal(err)
+ }
rst, err := st.reloadedServerTester()
if err != nil {
t.Fatal(err)
}
- if st.server.cs.Height() != rst.server.cs.Height() {
+ defer rst.server.Close()
+ if rst.server.cs.Height() != height {
t.Error("server heights do not match")
}
View
@@ -0,0 +1,23 @@
+version: "{build}"
+
+platform: x64
+
+clone_folder: c:\GOPATH\src\github.com\NebulousLabs\Sia
+
+shallow_clone: true
+
+environment:
+ GOPATH: c:\GOPATH
+
+branches:
+ only:
+ - master
+
+install:
+ - go version
+ - go env
+ - go get -d ./...
+
+build_script:
+ - go test -tags="testing debug" -short ./...
+ - go test -tags="testing debug" -v -race ./...
@@ -916,11 +916,12 @@ func TestStorageFolderUsage(t *testing.T) {
}
// Check the filesystem, there should be 3 files in the manager folder
// (storagemanager.db, storagemanager.json, storagemanager.log).
+ // NOTE: on Windows, a lock file for the db will also be present.
infos, err = ioutil.ReadDir(smt.sm.persistDir)
if err != nil {
t.Fatal(err)
}
- if len(infos) != 3 {
+ if len(infos) != 3 && len(infos) != 4 {
t.Error("unexpected number of files in the manager directory")
}
}
@@ -78,18 +78,6 @@ func TestNew(t *testing.T) {
if _, ok := err.(*json.SyntaxError); !ok {
t.Fatalf("expected invalid json, got %v", err)
}
-
- // Corrupted logfile.
- os.RemoveAll(filepath.Join(dir, "contractor.log"))
- f, err := os.OpenFile(filepath.Join(dir, "contractor.log"), os.O_CREATE, 0000)
- if err != nil {
- t.Fatal(err)
- }
- defer f.Close()
- _, err = New(stub, stub, stub, stub, dir)
- if !os.IsPermission(err) {
- t.Fatalf("expected permissions error, got %v", err)
- }
}
// TestContract tests the Contract method.
@@ -3,7 +3,6 @@ package hostdb
import (
"io/ioutil"
"os"
- "path/filepath"
"testing"
"github.com/NebulousLabs/Sia/build"
@@ -56,16 +55,4 @@ func TestNew(t *testing.T) {
if !os.IsNotExist(err) {
t.Fatalf("expected invalid directory, got %v", err)
}
-
- // Corrupted logfile.
- os.RemoveAll(filepath.Join(dir, "hostdb.log"))
- f, err := os.OpenFile(filepath.Join(dir, "hostdb.log"), os.O_CREATE, 0000)
- if err != nil {
- t.Fatal(err)
- }
- defer f.Close()
- _, err = New(stub, dir)
- if !os.IsPermission(err) {
- t.Fatalf("expected permissions error, got %v", err)
- }
}
@@ -285,7 +285,7 @@ func TestRenterPaths(t *testing.T) {
})
// walk will descend into foo/bar/, reading baz, bar, and finally foo
expWalkStr := (f3.name + ".sia") + (f2.name + ".sia") + (f1.name + ".sia")
- if walkStr != expWalkStr {
+ if filepath.ToSlash(walkStr) != expWalkStr {
t.Fatalf("Bad walk string: expected %v, got %v", expWalkStr, walkStr)
}
}
@@ -4,6 +4,7 @@ import (
"math/rand"
"os"
"path/filepath"
+ "runtime"
"testing"
"time"
@@ -44,19 +45,16 @@ var (
{Metadata{"\n\n", "Ṱ̺̺o͞ ̷i̲̬n̝̗v̟̜o̶̙kè͚̮ ̖t̝͕h̼͓e͇̣ ̢̼h͚͎i̦̲v̻͍e̺̭-m̢iͅn̖̺d̵̼ ̞̥r̛̗e͙p͠r̼̞e̺̠s̘͇e͉̥ǹ̬͎t͍̬i̪̱n͠g̴͉ ͏͉c̬̟h͡a̫̻o̫̟s̗̦.̨̹"}, Metadata{"\n\n", "Ṱ̺̺o͞ ̷i̲̬n̝̗v̟̜o̶̙kè͚̮ t̝͕h̼͓e͇̣ ̢̼h͚͎i̦̲v̻͍e̺̭-m̢iͅn̖̺d̵̼ ̞̥r̛̗e͙p͠r̼̞e̺̠s̘͇e͉̥ǹ̬͎t͍̬i̪̱n͠g̴͉ ͏͉c̬̟h͡a̫̻o̫̟s̗̦.̨̹"}, ErrBadVersion},
}
testFilenames = []string{
- " ",
"_",
"-",
"1234sg",
"@#$%@#",
- "¯|_(ツ)_|¯",
"你好好q wgc好",
"\xF0\x9F\x99\x8A",
"",
"",
"$HOME",
",.;'[]-=",
- "A:",
"%s",
}
)
@@ -99,17 +97,20 @@ func TestOpenDatabase(t *testing.T) {
// Create a new database.
db, err := OpenDatabase(in.md, dbFilepath)
if err != nil {
- t.Fatalf("calling OpenDatabase on a new database failed for metadata %v, filename %v; error was %v", in.md, dbFilename, err)
+ t.Errorf("calling OpenDatabase on a new database failed for metadata %v, filename %v; error was %v", in.md, dbFilename, err)
+ continue
}
// Close the newly-created, empty database.
err = db.Close()
if err != nil {
- t.Fatalf("closing a newly created database failed for metadata %v, filename %v; error was %v", in.md, dbFilename, err)
+ t.Errorf("closing a newly created database failed for metadata %v, filename %v; error was %v", in.md, dbFilename, err)
+ continue
}
// Call OpenDatabase again, this time on the existing empty database.
db, err = OpenDatabase(in.md, dbFilepath)
if err != nil {
- t.Fatalf("calling OpenDatabase on an existing empty database failed for metadata %v, filename %v; error was %v", in.md, dbFilename, err)
+ t.Errorf("calling OpenDatabase on an existing empty database failed for metadata %v, filename %v; error was %v", in.md, dbFilename, err)
+ continue
}
// Create buckets in the database.
err = db.Update(func(tx *bolt.Tx) error {
@@ -123,7 +124,8 @@ func TestOpenDatabase(t *testing.T) {
return nil
})
if err != nil {
- t.Fatal(err)
+ t.Error(err)
+ continue
}
// Make sure CreateBucketIfNotExists method handles invalid (nil)
// bucket name.
@@ -155,17 +157,20 @@ func TestOpenDatabase(t *testing.T) {
return nil
})
if err != nil {
- t.Fatal(err)
+ t.Error(err)
+ continue
}
// Close the newly-filled database.
err = db.Close()
if err != nil {
- t.Fatalf("closing a newly-filled database failed for metadata %v, filename %v; error was %v", in.md, dbFilename, err)
+ t.Errorf("closing a newly-filled database failed for metadata %v, filename %v; error was %v", in.md, dbFilename, err)
+ continue
}
// Call OpenDatabase on the database now that it's been filled.
db, err = OpenDatabase(in.md, dbFilepath)
if err != nil {
- t.Fatal(err)
+ t.Error(err)
+ continue
}
// Empty every bucket in the database.
err = db.Update(func(tx *bolt.Tx) error {
@@ -183,11 +188,13 @@ func TestOpenDatabase(t *testing.T) {
// Close and delete the newly emptied database.
err = db.Close()
if err != nil {
- t.Fatalf("closing a newly-emptied database for metadata %v, filename %v; error was %v", in.md, dbFilename, err)
+ t.Errorf("closing a newly-emptied database for metadata %v, filename %v; error was %v", in.md, dbFilename, err)
+ continue
}
err = os.Remove(dbFilepath)
if err != nil {
- t.Fatalf("removing database file failed for metadata %v, filename %v; error was %v", in.md, dbFilename, err)
+ t.Errorf("removing database file failed for metadata %v, filename %v; error was %v", in.md, dbFilename, err)
+ continue
}
}
}
@@ -196,9 +203,10 @@ func TestOpenDatabase(t *testing.T) {
// with the wrong filemode (< 0600), which should result in an os.ErrPermission
// error.
func TestErrPermissionOpenDatabase(t *testing.T) {
- if testing.Short() {
- t.SkipNow()
+ if runtime.GOOS == "windows" {
+ t.Skip("can't reproduce on Windows")
}
+
const (
dbHeader = "Fake Header"
dbVersion = "0.0.0"
@@ -385,6 +393,7 @@ func TestErrIntegratedCheckMetadata(t *testing.T) {
boltDB, err := OpenDatabase(in.md, dbFilepath)
if err != nil {
t.Errorf("OpenDatabase failed on input %v, filename %v; error was %v", in, dbFilename, err)
+ continue
}
err = boltDB.Close()
if err != nil {

0 comments on commit c79980f

Please sign in to comment.