mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-22 10:58:57 +00:00
Fix integration tests for Windows native
This commit is contained in:
parent
c96c78892d
commit
d2c0b8374a
@ -48,10 +48,8 @@ const (
|
||||
|
||||
var env = []string{
|
||||
"HOME=.",
|
||||
"STTRACE=model,protocol",
|
||||
"STGUIAPIKEY=" + apiKey,
|
||||
"STNORESTART=1",
|
||||
"STPERFSTATS=1",
|
||||
}
|
||||
|
||||
type syncthingProcess struct {
|
||||
@ -78,7 +76,7 @@ func (p *syncthingProcess) start() error {
|
||||
cmd := exec.Command("../bin/syncthing", p.argv...)
|
||||
cmd.Stdout = p.logfd
|
||||
cmd.Stderr = p.logfd
|
||||
cmd.Env = append(env, fmt.Sprintf("STPROFILER=:%d", p.port+1000))
|
||||
cmd.Env = append(os.Environ(), env...)
|
||||
|
||||
err := cmd.Start()
|
||||
if err != nil {
|
||||
@ -97,7 +95,7 @@ func (p *syncthingProcess) start() error {
|
||||
}
|
||||
|
||||
func (p *syncthingProcess) stop() error {
|
||||
p.cmd.Process.Signal(os.Interrupt)
|
||||
p.cmd.Process.Signal(os.Kill)
|
||||
p.cmd.Wait()
|
||||
|
||||
fd, err := os.Open(p.log)
|
||||
@ -320,6 +318,16 @@ func (i *inifiteReader) Read(bs []byte) (int, error) {
|
||||
// rm -rf
|
||||
func removeAll(dirs ...string) error {
|
||||
for _, dir := range dirs {
|
||||
// Set any non-writeable files and dirs to writeable. This is necessary for os.RemoveAll to work on Windows.
|
||||
filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if info.Mode()&0700 != 0700 {
|
||||
os.Chmod(path, 0777)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
os.RemoveAll(dir)
|
||||
}
|
||||
return nil
|
||||
|
@ -81,7 +81,8 @@ func testRestartDuringTransfer(t *testing.T, restartSender, restartReceiver bool
|
||||
for {
|
||||
comp, err := sender.peerCompletion()
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "use of closed network connection") {
|
||||
if strings.Contains(err.Error(), "use of closed network connection") ||
|
||||
strings.Contains(err.Error(), "request cancelled while waiting") {
|
||||
time.Sleep(250 * time.Millisecond)
|
||||
continue
|
||||
}
|
||||
|
@ -18,8 +18,10 @@
|
||||
package integration_test
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@ -29,7 +31,21 @@ import (
|
||||
"github.com/syncthing/syncthing/internal/symlinks"
|
||||
)
|
||||
|
||||
func symlinksSupported() bool {
|
||||
tmp, err := ioutil.TempDir("", "symlink-test")
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
defer os.RemoveAll(tmp)
|
||||
err = os.Symlink("tmp", filepath.Join(tmp, "link"))
|
||||
return err == nil
|
||||
}
|
||||
|
||||
func TestSymlinks(t *testing.T) {
|
||||
if !symlinksSupported() {
|
||||
t.Skip("symlinks unsupported")
|
||||
}
|
||||
|
||||
// Use no versioning
|
||||
id, _ := protocol.DeviceIDFromString(id2)
|
||||
cfg, _ := config.Load("h2/config.xml", id)
|
||||
@ -42,6 +58,10 @@ func TestSymlinks(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSymlinksSimpleVersioning(t *testing.T) {
|
||||
if !symlinksSupported() {
|
||||
t.Skip("symlinks unsupported")
|
||||
}
|
||||
|
||||
// Use no versioning
|
||||
id, _ := protocol.DeviceIDFromString(id2)
|
||||
cfg, _ := config.Load("h2/config.xml", id)
|
||||
@ -57,6 +77,10 @@ func TestSymlinksSimpleVersioning(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSymlinksStaggeredVersioning(t *testing.T) {
|
||||
if !symlinksSupported() {
|
||||
t.Skip("symlinks unsupported")
|
||||
}
|
||||
|
||||
// Use no versioning
|
||||
id, _ := protocol.DeviceIDFromString(id2)
|
||||
cfg, _ := config.Load("h2/config.xml", id)
|
||||
|
Loading…
Reference in New Issue
Block a user