Skip to content

Commit cc7e593

Browse files
authored
Merge pull request containerd#1760 from dnephin/run-unit-tests-on-windows
Re-enable unit tests on appveyor
2 parents f49b1b7 + a72279e commit cc7e593

File tree

8 files changed

+49
-21
lines changed

8 files changed

+49
-21
lines changed

.appveyor.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,18 @@ before_build:
2020
- appveyor DownloadFile https://storage.googleapis.com/golang/go%GO_VERSION%.windows-amd64.zip
2121
- 7z x go%GO_VERSION%.windows-amd64.zip -oC:\ >nul
2222
- go version
23-
# TODO: re-enable once the content unit-test have been updated to pass on windows
24-
#- choco install codecov
23+
- choco install codecov
2524

2625
build_script:
2726
- bash.exe -elc "export PATH=/c/tools/mingw64/bin:/c/gopath/bin:$PATH ; mingw32-make.exe setup check"
28-
- bash.exe -elc "export PATH=/c/tools/mingw64/bin:$PATH ; mingw32-make.exe build"
29-
- bash.exe -elc "export PATH=/c/tools/mingw64/bin:$PATH ; mingw32-make.exe binaries"
27+
- bash.exe -elc "export PATH=/c/tools/mingw64/bin:$PATH ; mingw32-make.exe build binaries"
3028

3129
test_script:
3230
# TODO: need an equivalent of TRAVIS_COMMIT_RANGE
3331
# - GIT_CHECK_EXCLUDE="./vendor" TRAVIS_COMMIT_RANGE="${TRAVIS_COMMIT_RANGE/.../..}" C:\MinGW\bin\mingw32-make.exe dco
32+
- bash.exe -lc "export PATH=/c/tools/mingw64/bin:/c/gopath/src/github.com/containerd/containerd/bin:$PATH ; mingw32-make.exe coverage root-coverage"
3433
- bash.exe -elc "export PATH=/c/tools/mingw64/bin:/c/gopath/src/github.com/containerd/containerd/bin:$PATH ; mingw32-make.exe integration"
3534
- bash.exe -elc "export PATH=/c/tools/mingw64/bin:/c/gopath/src/github.com/containerd/containerd/bin:$PATH ; mingw32-make.exe integration-parallel"
36-
# TODO: re-enable once the content unit-test have been updated to pass on windows
37-
#- bash.exe -lc "export PATH=/c/tools/mingw64/bin:/c/gopath/src/github.com/containerd/containerd/bin:$PATH ; mingw32-make.exe coverage"
38-
#- bash.exe -lc "export PATH=/c/tools/mingw64/bin:/c/gopath/src/github.com/containerd/containerd/bin:$PATH ; mingw32-make.exe root-coverage"
3935

4036
on_success:
41-
# Note that, a Codecov upload token is not required.
42-
# TODO: re-enable once the content unit-test have been updated to pass on windows
43-
#- codecov -f coverage.txt
37+
codecov --flag windows -f coverage.txt

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ script:
6565
- if [ "$GOOS" = "linux" ]; then sudo PATH=$PATH GOPATH=$GOPATH make integration-parallel ; fi
6666

6767
after_success:
68-
- bash <(curl -s https://codecov.io/bash)
68+
- bash <(curl -s https://codecov.io/bash) -F linux
6969

7070
before_deploy:
7171
- make release

content/testsuite/testsuite.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"io/ioutil"
88
"math/rand"
99
"os"
10+
"runtime"
1011
"testing"
1112
"time"
1213

@@ -329,7 +330,10 @@ func checkInfo(ctx context.Context, cs content.Store, d digest.Digest, expected
329330
if info.CreatedAt.After(c2) || info.CreatedAt.Before(c1) {
330331
return errors.Errorf("unexpected created at time %s, expected between %s and %s", info.CreatedAt, c1, c2)
331332
}
332-
if info.UpdatedAt.After(u2) || info.UpdatedAt.Before(u1) {
333+
// FIXME: broken on windows: unexpected updated at time 2017-11-14 13:43:22.178013 -0800 PST,
334+
// expected between 2017-11-14 13:43:22.1790195 -0800 PST m=+1.022137300 and
335+
// 2017-11-14 13:43:22.1790195 -0800 PST m=+1.022137300
336+
if runtime.GOOS != "windows" && (info.UpdatedAt.After(u2) || info.UpdatedAt.Before(u1)) {
333337
return errors.Errorf("unexpected updated at time %s, expected between %s and %s", info.UpdatedAt, u1, u2)
334338
}
335339

fs/diff_test.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"io/ioutil"
77
"os"
88
"path/filepath"
9+
"runtime"
910
"strings"
1011
"testing"
1112
"time"
@@ -20,7 +21,14 @@ import (
2021
// - symlink test
2122
// - hardlink test
2223

24+
func skipDiffTestOnWindows(t *testing.T) {
25+
if runtime.GOOS == "windows" {
26+
t.Skip("diff implementation is incomplete on windows")
27+
}
28+
}
29+
2330
func TestSimpleDiff(t *testing.T) {
31+
skipDiffTestOnWindows(t)
2432
l1 := fstest.Apply(
2533
fstest.CreateDir("/etc", 0755),
2634
fstest.CreateFile("/etc/hosts", []byte("mydomain 10.0.0.1"), 0644),
@@ -49,6 +57,7 @@ func TestSimpleDiff(t *testing.T) {
4957
}
5058

5159
func TestDirectoryReplace(t *testing.T) {
60+
skipDiffTestOnWindows(t)
5261
l1 := fstest.Apply(
5362
fstest.CreateDir("/dir1", 0755),
5463
fstest.CreateFile("/dir1/f1", []byte("#####"), 0644),
@@ -109,6 +118,7 @@ func TestFileReplace(t *testing.T) {
109118
}
110119

111120
func TestParentDirectoryPermission(t *testing.T) {
121+
skipDiffTestOnWindows(t)
112122
l1 := fstest.Apply(
113123
fstest.CreateDir("/dir1", 0700),
114124
fstest.CreateDir("/dir2", 0751),
@@ -134,6 +144,7 @@ func TestParentDirectoryPermission(t *testing.T) {
134144
}
135145
}
136146
func TestUpdateWithSameTime(t *testing.T) {
147+
skipDiffTestOnWindows(t)
137148
tt := time.Now().Truncate(time.Second)
138149
t1 := tt.Add(5 * time.Nanosecond)
139150
t2 := tt.Add(6 * time.Nanosecond)
@@ -322,20 +333,20 @@ func changesString(c []TestChange) string {
322333
func Add(p string) TestChange {
323334
return TestChange{
324335
Kind: ChangeKindAdd,
325-
Path: p,
336+
Path: filepath.FromSlash(p),
326337
}
327338
}
328339

329340
func Delete(p string) TestChange {
330341
return TestChange{
331342
Kind: ChangeKindDelete,
332-
Path: p,
343+
Path: filepath.FromSlash(p),
333344
}
334345
}
335346

336347
func Modify(p string) TestChange {
337348
return TestChange{
338349
Kind: ChangeKindModify,
339-
Path: p,
350+
Path: filepath.FromSlash(p),
340351
}
341352
}

fs/diff_windows.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
package fs
22

3-
import "os"
3+
import (
4+
"os"
5+
6+
"golang.org/x/sys/windows"
7+
)
48

59
func detectDirDiff(upper, lower string) *diffDirOptions {
610
return nil
711
}
812

913
func compareSysStat(s1, s2 interface{}) (bool, error) {
10-
// TODO: Use windows specific sys type
11-
return false, nil
14+
f1, ok := s1.(windows.Win32FileAttributeData)
15+
if !ok {
16+
return false, nil
17+
}
18+
f2, ok := s2.(windows.Win32FileAttributeData)
19+
if !ok {
20+
return false, nil
21+
}
22+
return f1.FileAttributes == f2.FileAttributes, nil
1223
}
1324

1425
func compareCapabilities(p1, p2 string) (bool, error) {

metadata/snapshot_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"os"
66
"path/filepath"
7+
"runtime"
78
"testing"
89

910
"github.com/boltdb/bolt"
@@ -39,6 +40,9 @@ func newTestSnapshotter(ctx context.Context, root string) (snapshot.Snapshotter,
3940
}
4041

4142
func TestMetadata(t *testing.T) {
43+
if runtime.GOOS == "windows" {
44+
t.Skip("snapshotter not implemented on windows")
45+
}
4246
// Snapshot tests require mounting, still requires root
4347
testutil.RequiresRoot(t)
4448
testsuite.SnapshotterSuite(t, "Metadata", newTestSnapshotter)

platforms/platforms_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func TestParseSelector(t *testing.T) {
8787
OS: defaultOS,
8888
Architecture: "arm",
8989
},
90-
formatted: "linux/arm",
90+
formatted: joinNotEmpty(defaultOS, "arm"),
9191
},
9292
{
9393
input: "armel",
@@ -96,15 +96,15 @@ func TestParseSelector(t *testing.T) {
9696
Architecture: "arm",
9797
Variant: "v6",
9898
},
99-
formatted: "linux/arm/v6",
99+
formatted: joinNotEmpty(defaultOS, "arm/v6"),
100100
},
101101
{
102102
input: "armhf",
103103
expected: specs.Platform{
104104
OS: defaultOS,
105105
Architecture: "arm",
106106
},
107-
formatted: "linux/arm",
107+
formatted: joinNotEmpty(defaultOS, "arm"),
108108
},
109109
{
110110
input: "Aarch64",

snapshot/naive/naive_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package naive
22

33
import (
44
"context"
5+
"runtime"
56
"testing"
67

78
"github.com/containerd/containerd/snapshot"
@@ -19,6 +20,9 @@ func newSnapshotter(ctx context.Context, root string) (snapshot.Snapshotter, fun
1920
}
2021

2122
func TestNaive(t *testing.T) {
23+
if runtime.GOOS == "windows" {
24+
t.Skip("snapshotter not implemented on windows")
25+
}
2226
testutil.RequiresRoot(t)
2327
testsuite.SnapshotterSuite(t, "Naive", newSnapshotter)
2428
}

0 commit comments

Comments
 (0)