Merge pull request #1760 from dnephin/run-unit-tests-on-windows

Re-enable unit tests on appveyor
This commit is contained in:
Kenfe-Mickaël Laventure 2017-11-15 18:53:16 -08:00 committed by GitHub
commit cc7e5934c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 49 additions and 21 deletions

View File

@ -20,24 +20,18 @@ before_build:
- appveyor DownloadFile https://storage.googleapis.com/golang/go%GO_VERSION%.windows-amd64.zip - appveyor DownloadFile https://storage.googleapis.com/golang/go%GO_VERSION%.windows-amd64.zip
- 7z x go%GO_VERSION%.windows-amd64.zip -oC:\ >nul - 7z x go%GO_VERSION%.windows-amd64.zip -oC:\ >nul
- go version - go version
# TODO: re-enable once the content unit-test have been updated to pass on windows - choco install codecov
#- choco install codecov
build_script: build_script:
- bash.exe -elc "export PATH=/c/tools/mingw64/bin:/c/gopath/bin:$PATH ; mingw32-make.exe setup check" - bash.exe -elc "export PATH=/c/tools/mingw64/bin:/c/gopath/bin:$PATH ; mingw32-make.exe setup check"
- bash.exe -elc "export PATH=/c/tools/mingw64/bin:$PATH ; mingw32-make.exe build" - bash.exe -elc "export PATH=/c/tools/mingw64/bin:$PATH ; mingw32-make.exe build binaries"
- bash.exe -elc "export PATH=/c/tools/mingw64/bin:$PATH ; mingw32-make.exe binaries"
test_script: test_script:
# TODO: need an equivalent of TRAVIS_COMMIT_RANGE # TODO: need an equivalent of TRAVIS_COMMIT_RANGE
# - GIT_CHECK_EXCLUDE="./vendor" TRAVIS_COMMIT_RANGE="${TRAVIS_COMMIT_RANGE/.../..}" C:\MinGW\bin\mingw32-make.exe dco # - GIT_CHECK_EXCLUDE="./vendor" TRAVIS_COMMIT_RANGE="${TRAVIS_COMMIT_RANGE/.../..}" C:\MinGW\bin\mingw32-make.exe dco
- bash.exe -lc "export PATH=/c/tools/mingw64/bin:/c/gopath/src/github.com/containerd/containerd/bin:$PATH ; mingw32-make.exe coverage root-coverage"
- bash.exe -elc "export PATH=/c/tools/mingw64/bin:/c/gopath/src/github.com/containerd/containerd/bin:$PATH ; mingw32-make.exe integration" - bash.exe -elc "export PATH=/c/tools/mingw64/bin:/c/gopath/src/github.com/containerd/containerd/bin:$PATH ; mingw32-make.exe integration"
- bash.exe -elc "export PATH=/c/tools/mingw64/bin:/c/gopath/src/github.com/containerd/containerd/bin:$PATH ; mingw32-make.exe integration-parallel" - bash.exe -elc "export PATH=/c/tools/mingw64/bin:/c/gopath/src/github.com/containerd/containerd/bin:$PATH ; mingw32-make.exe integration-parallel"
# TODO: re-enable once the content unit-test have been updated to pass on windows
#- bash.exe -lc "export PATH=/c/tools/mingw64/bin:/c/gopath/src/github.com/containerd/containerd/bin:$PATH ; mingw32-make.exe coverage"
#- bash.exe -lc "export PATH=/c/tools/mingw64/bin:/c/gopath/src/github.com/containerd/containerd/bin:$PATH ; mingw32-make.exe root-coverage"
on_success: on_success:
# Note that, a Codecov upload token is not required. codecov --flag windows -f coverage.txt
# TODO: re-enable once the content unit-test have been updated to pass on windows
#- codecov -f coverage.txt

View File

@ -65,7 +65,7 @@ script:
- if [ "$GOOS" = "linux" ]; then sudo PATH=$PATH GOPATH=$GOPATH make integration-parallel ; fi - if [ "$GOOS" = "linux" ]; then sudo PATH=$PATH GOPATH=$GOPATH make integration-parallel ; fi
after_success: after_success:
- bash <(curl -s https://codecov.io/bash) - bash <(curl -s https://codecov.io/bash) -F linux
before_deploy: before_deploy:
- make release - make release

View File

@ -7,6 +7,7 @@ import (
"io/ioutil" "io/ioutil"
"math/rand" "math/rand"
"os" "os"
"runtime"
"testing" "testing"
"time" "time"
@ -329,7 +330,10 @@ func checkInfo(ctx context.Context, cs content.Store, d digest.Digest, expected
if info.CreatedAt.After(c2) || info.CreatedAt.Before(c1) { if info.CreatedAt.After(c2) || info.CreatedAt.Before(c1) {
return errors.Errorf("unexpected created at time %s, expected between %s and %s", info.CreatedAt, c1, c2) return errors.Errorf("unexpected created at time %s, expected between %s and %s", info.CreatedAt, c1, c2)
} }
if info.UpdatedAt.After(u2) || info.UpdatedAt.Before(u1) { // FIXME: broken on windows: unexpected updated at time 2017-11-14 13:43:22.178013 -0800 PST,
// expected between 2017-11-14 13:43:22.1790195 -0800 PST m=+1.022137300 and
// 2017-11-14 13:43:22.1790195 -0800 PST m=+1.022137300
if runtime.GOOS != "windows" && (info.UpdatedAt.After(u2) || info.UpdatedAt.Before(u1)) {
return errors.Errorf("unexpected updated at time %s, expected between %s and %s", info.UpdatedAt, u1, u2) return errors.Errorf("unexpected updated at time %s, expected between %s and %s", info.UpdatedAt, u1, u2)
} }

View File

@ -6,6 +6,7 @@ import (
"io/ioutil" "io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"runtime"
"strings" "strings"
"testing" "testing"
"time" "time"
@ -20,7 +21,14 @@ import (
// - symlink test // - symlink test
// - hardlink test // - hardlink test
func skipDiffTestOnWindows(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("diff implementation is incomplete on windows")
}
}
func TestSimpleDiff(t *testing.T) { func TestSimpleDiff(t *testing.T) {
skipDiffTestOnWindows(t)
l1 := fstest.Apply( l1 := fstest.Apply(
fstest.CreateDir("/etc", 0755), fstest.CreateDir("/etc", 0755),
fstest.CreateFile("/etc/hosts", []byte("mydomain 10.0.0.1"), 0644), fstest.CreateFile("/etc/hosts", []byte("mydomain 10.0.0.1"), 0644),
@ -49,6 +57,7 @@ func TestSimpleDiff(t *testing.T) {
} }
func TestDirectoryReplace(t *testing.T) { func TestDirectoryReplace(t *testing.T) {
skipDiffTestOnWindows(t)
l1 := fstest.Apply( l1 := fstest.Apply(
fstest.CreateDir("/dir1", 0755), fstest.CreateDir("/dir1", 0755),
fstest.CreateFile("/dir1/f1", []byte("#####"), 0644), fstest.CreateFile("/dir1/f1", []byte("#####"), 0644),
@ -109,6 +118,7 @@ func TestFileReplace(t *testing.T) {
} }
func TestParentDirectoryPermission(t *testing.T) { func TestParentDirectoryPermission(t *testing.T) {
skipDiffTestOnWindows(t)
l1 := fstest.Apply( l1 := fstest.Apply(
fstest.CreateDir("/dir1", 0700), fstest.CreateDir("/dir1", 0700),
fstest.CreateDir("/dir2", 0751), fstest.CreateDir("/dir2", 0751),
@ -134,6 +144,7 @@ func TestParentDirectoryPermission(t *testing.T) {
} }
} }
func TestUpdateWithSameTime(t *testing.T) { func TestUpdateWithSameTime(t *testing.T) {
skipDiffTestOnWindows(t)
tt := time.Now().Truncate(time.Second) tt := time.Now().Truncate(time.Second)
t1 := tt.Add(5 * time.Nanosecond) t1 := tt.Add(5 * time.Nanosecond)
t2 := tt.Add(6 * time.Nanosecond) t2 := tt.Add(6 * time.Nanosecond)
@ -322,20 +333,20 @@ func changesString(c []TestChange) string {
func Add(p string) TestChange { func Add(p string) TestChange {
return TestChange{ return TestChange{
Kind: ChangeKindAdd, Kind: ChangeKindAdd,
Path: p, Path: filepath.FromSlash(p),
} }
} }
func Delete(p string) TestChange { func Delete(p string) TestChange {
return TestChange{ return TestChange{
Kind: ChangeKindDelete, Kind: ChangeKindDelete,
Path: p, Path: filepath.FromSlash(p),
} }
} }
func Modify(p string) TestChange { func Modify(p string) TestChange {
return TestChange{ return TestChange{
Kind: ChangeKindModify, Kind: ChangeKindModify,
Path: p, Path: filepath.FromSlash(p),
} }
} }

View File

@ -1,15 +1,26 @@
package fs package fs
import "os" import (
"os"
"golang.org/x/sys/windows"
)
func detectDirDiff(upper, lower string) *diffDirOptions { func detectDirDiff(upper, lower string) *diffDirOptions {
return nil return nil
} }
func compareSysStat(s1, s2 interface{}) (bool, error) { func compareSysStat(s1, s2 interface{}) (bool, error) {
// TODO: Use windows specific sys type f1, ok := s1.(windows.Win32FileAttributeData)
if !ok {
return false, nil return false, nil
} }
f2, ok := s2.(windows.Win32FileAttributeData)
if !ok {
return false, nil
}
return f1.FileAttributes == f2.FileAttributes, nil
}
func compareCapabilities(p1, p2 string) (bool, error) { func compareCapabilities(p1, p2 string) (bool, error) {
// TODO: Use windows equivalent // TODO: Use windows equivalent

View File

@ -4,6 +4,7 @@ import (
"context" "context"
"os" "os"
"path/filepath" "path/filepath"
"runtime"
"testing" "testing"
"github.com/boltdb/bolt" "github.com/boltdb/bolt"
@ -39,6 +40,9 @@ func newTestSnapshotter(ctx context.Context, root string) (snapshot.Snapshotter,
} }
func TestMetadata(t *testing.T) { func TestMetadata(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("snapshotter not implemented on windows")
}
// Snapshot tests require mounting, still requires root // Snapshot tests require mounting, still requires root
testutil.RequiresRoot(t) testutil.RequiresRoot(t)
testsuite.SnapshotterSuite(t, "Metadata", newTestSnapshotter) testsuite.SnapshotterSuite(t, "Metadata", newTestSnapshotter)

View File

@ -87,7 +87,7 @@ func TestParseSelector(t *testing.T) {
OS: defaultOS, OS: defaultOS,
Architecture: "arm", Architecture: "arm",
}, },
formatted: "linux/arm", formatted: joinNotEmpty(defaultOS, "arm"),
}, },
{ {
input: "armel", input: "armel",
@ -96,7 +96,7 @@ func TestParseSelector(t *testing.T) {
Architecture: "arm", Architecture: "arm",
Variant: "v6", Variant: "v6",
}, },
formatted: "linux/arm/v6", formatted: joinNotEmpty(defaultOS, "arm/v6"),
}, },
{ {
input: "armhf", input: "armhf",
@ -104,7 +104,7 @@ func TestParseSelector(t *testing.T) {
OS: defaultOS, OS: defaultOS,
Architecture: "arm", Architecture: "arm",
}, },
formatted: "linux/arm", formatted: joinNotEmpty(defaultOS, "arm"),
}, },
{ {
input: "Aarch64", input: "Aarch64",

View File

@ -2,6 +2,7 @@ package naive
import ( import (
"context" "context"
"runtime"
"testing" "testing"
"github.com/containerd/containerd/snapshot" "github.com/containerd/containerd/snapshot"
@ -19,6 +20,9 @@ func newSnapshotter(ctx context.Context, root string) (snapshot.Snapshotter, fun
} }
func TestNaive(t *testing.T) { func TestNaive(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("snapshotter not implemented on windows")
}
testutil.RequiresRoot(t) testutil.RequiresRoot(t)
testsuite.SnapshotterSuite(t, "Naive", newSnapshotter) testsuite.SnapshotterSuite(t, "Naive", newSnapshotter)
} }