Fix integration tests for Windows native
This commit is contained in:
parent
c96c78892d
commit
d2c0b8374a
@ -48,10 +48,8 @@ const (
|
|||||||
|
|
||||||
var env = []string{
|
var env = []string{
|
||||||
"HOME=.",
|
"HOME=.",
|
||||||
"STTRACE=model,protocol",
|
|
||||||
"STGUIAPIKEY=" + apiKey,
|
"STGUIAPIKEY=" + apiKey,
|
||||||
"STNORESTART=1",
|
"STNORESTART=1",
|
||||||
"STPERFSTATS=1",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type syncthingProcess struct {
|
type syncthingProcess struct {
|
||||||
@ -78,7 +76,7 @@ func (p *syncthingProcess) start() error {
|
|||||||
cmd := exec.Command("../bin/syncthing", p.argv...)
|
cmd := exec.Command("../bin/syncthing", p.argv...)
|
||||||
cmd.Stdout = p.logfd
|
cmd.Stdout = p.logfd
|
||||||
cmd.Stderr = 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()
|
err := cmd.Start()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -97,7 +95,7 @@ func (p *syncthingProcess) start() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *syncthingProcess) stop() error {
|
func (p *syncthingProcess) stop() error {
|
||||||
p.cmd.Process.Signal(os.Interrupt)
|
p.cmd.Process.Signal(os.Kill)
|
||||||
p.cmd.Wait()
|
p.cmd.Wait()
|
||||||
|
|
||||||
fd, err := os.Open(p.log)
|
fd, err := os.Open(p.log)
|
||||||
@ -320,6 +318,16 @@ func (i *inifiteReader) Read(bs []byte) (int, error) {
|
|||||||
// rm -rf
|
// rm -rf
|
||||||
func removeAll(dirs ...string) error {
|
func removeAll(dirs ...string) error {
|
||||||
for _, dir := range dirs {
|
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)
|
os.RemoveAll(dir)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@ -81,7 +81,8 @@ func testRestartDuringTransfer(t *testing.T, restartSender, restartReceiver bool
|
|||||||
for {
|
for {
|
||||||
comp, err := sender.peerCompletion()
|
comp, err := sender.peerCompletion()
|
||||||
if err != nil {
|
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)
|
time.Sleep(250 * time.Millisecond)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,8 +18,10 @@
|
|||||||
package integration_test
|
package integration_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
@ -29,7 +31,21 @@ import (
|
|||||||
"github.com/syncthing/syncthing/internal/symlinks"
|
"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) {
|
func TestSymlinks(t *testing.T) {
|
||||||
|
if !symlinksSupported() {
|
||||||
|
t.Skip("symlinks unsupported")
|
||||||
|
}
|
||||||
|
|
||||||
// Use no versioning
|
// Use no versioning
|
||||||
id, _ := protocol.DeviceIDFromString(id2)
|
id, _ := protocol.DeviceIDFromString(id2)
|
||||||
cfg, _ := config.Load("h2/config.xml", id)
|
cfg, _ := config.Load("h2/config.xml", id)
|
||||||
@ -42,6 +58,10 @@ func TestSymlinks(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSymlinksSimpleVersioning(t *testing.T) {
|
func TestSymlinksSimpleVersioning(t *testing.T) {
|
||||||
|
if !symlinksSupported() {
|
||||||
|
t.Skip("symlinks unsupported")
|
||||||
|
}
|
||||||
|
|
||||||
// Use no versioning
|
// Use no versioning
|
||||||
id, _ := protocol.DeviceIDFromString(id2)
|
id, _ := protocol.DeviceIDFromString(id2)
|
||||||
cfg, _ := config.Load("h2/config.xml", id)
|
cfg, _ := config.Load("h2/config.xml", id)
|
||||||
@ -57,6 +77,10 @@ func TestSymlinksSimpleVersioning(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSymlinksStaggeredVersioning(t *testing.T) {
|
func TestSymlinksStaggeredVersioning(t *testing.T) {
|
||||||
|
if !symlinksSupported() {
|
||||||
|
t.Skip("symlinks unsupported")
|
||||||
|
}
|
||||||
|
|
||||||
// Use no versioning
|
// Use no versioning
|
||||||
id, _ := protocol.DeviceIDFromString(id2)
|
id, _ := protocol.DeviceIDFromString(id2)
|
||||||
cfg, _ := config.Load("h2/config.xml", id)
|
cfg, _ := config.Load("h2/config.xml", id)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user