Skip to content

Commit 99a03b7

Browse files
committed
chore: skip tests that cannot work on Windows
WARNING! The reason some of these tests cannot run is because they rely on images that are not multi-arch (i.e. only have Linux variants and not Windows). The tests need to be reworked so that we verify: - that we cannot pull them with Docker on Windows - but we can pull them with our docker-pull library
1 parent 7823b27 commit 99a03b7

File tree

5 files changed

+98
-6
lines changed

5 files changed

+98
-6
lines changed

test/lib/analyzer/image-inspector.test.ts

+17
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// tslint:disable:object-literal-key-quotes
33

44
import * as fs from "fs";
5+
import { platform } from "os";
56
import * as path from "path";
67
import * as sinon from "sinon";
78
import { test } from "tap";
@@ -123,6 +124,10 @@ test("get image as an archive", async (t) => {
123124
const targetImage = "library/hello-world:latest";
124125

125126
t.test("from the local daemon if it exists", async (t) => {
127+
if (platform() === "win32") {
128+
return;
129+
}
130+
126131
const customPath = "./other_custom/image/save/path/local/daemon";
127132
const imageSavePath = path.join(customPath, uuidv4());
128133
const dockerPullSpy = sinon.spy(Docker.prototype, "pull");
@@ -167,6 +172,10 @@ test("get image as an archive", async (t) => {
167172
});
168173

169174
t.test("from remote registry with binary", async (t) => {
175+
if (platform() === "win32") {
176+
return;
177+
}
178+
170179
const customPath = tmp.dirSync().name;
171180
const imageSavePath = path.join(customPath, uuidv4());
172181
const dockerPullSpy = sinon.spy(Docker.prototype, "pull");
@@ -208,6 +217,10 @@ test("get image as an archive", async (t) => {
208217
});
209218

210219
t.test("from remote registry without binary", async (t) => {
220+
if (platform() === "win32") {
221+
return;
222+
}
223+
211224
const customPath = "./new_custom/image/save/path";
212225
const imageSavePath = path.join(customPath, uuidv4());
213226
const dockerPullSpy = sinon.spy(Docker.prototype, "pull");
@@ -251,6 +264,10 @@ test("get image as an archive", async (t) => {
251264
});
252265

253266
t.test("from remote registry with authentication", async (t) => {
267+
if (platform() === "win32") {
268+
return;
269+
}
270+
254271
const customPath = "./my_custom/image/save/path/auth";
255272
const imageSavePath = path.join(customPath, uuidv4());
256273
const dockerPullSpy: sinon.SinonSpy = sinon.spy(Docker.prototype, "pull");

test/lib/docker.test.ts

+22-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import * as crypto from "crypto";
22
import { createReadStream, existsSync, readFileSync, unlinkSync } from "fs";
33
import * as os from "os";
4+
import { platform } from "os";
45
import * as path from "path";
56
import * as sinon from "sinon";
67
import { test } from "tap";
7-
import * as subProcess from "../../lib/sub-process";
88

99
import { Docker } from "../../lib/docker";
10+
import * as subProcess from "../../lib/sub-process";
1011

1112
function getChecksum(path: string): Promise<string> {
1213
return new Promise((resolve, reject) => {
@@ -28,6 +29,10 @@ function getChecksum(path: string): Promise<string> {
2829
}
2930

3031
test("docker run", async (t) => {
32+
if (platform() !== "linux") {
33+
return;
34+
}
35+
3136
const stub = sinon.stub(subProcess, "execute");
3237
stub.resolves("text");
3338
t.beforeEach(async () => {
@@ -88,6 +93,10 @@ test("docker run", async (t) => {
8893
});
8994

9095
test("save from docker daemon", async (t) => {
96+
if (platform() !== "linux") {
97+
return;
98+
}
99+
91100
const targetImage = "hello-world:latest";
92101
const docker = new Docker(targetImage);
93102
const loadImage = path.join(
@@ -142,6 +151,10 @@ test("save from docker daemon", async (t) => {
142151
});
143152

144153
test("safeCat", async (t) => {
154+
if (platform() !== "linux") {
155+
return;
156+
}
157+
145158
const stub = sinon.stub(subProcess, "execute");
146159
t.beforeEach(async () => {
147160
stub.resetHistory();
@@ -181,6 +194,10 @@ test("safeCat", async (t) => {
181194
});
182195

183196
test("safeLs", async (t) => {
197+
if (platform() !== "linux") {
198+
return;
199+
}
200+
184201
const stub = sinon.stub(subProcess, "execute");
185202
t.beforeEach(async () => {
186203
stub.resetHistory();
@@ -253,6 +270,10 @@ const getLSOutputFixture = (file: string) =>
253270
path.join(__dirname, "../fixtures/ls-output", file);
254271

255272
test("findGlobs", async (t) => {
273+
if (platform() !== "linux") {
274+
return;
275+
}
276+
256277
const stub = sinon.stub(subProcess, "execute");
257278
t.beforeEach(async () => {
258279
stub.resetHistory();

test/lib/ls-utils.test.ts

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { platform } from "os";
12
import * as path from "path";
23
import { test } from "tap";
34
import { iterateFiles, parseLsOutput } from "../../lib/ls-utils";
@@ -214,6 +215,10 @@ const PARSER_TESTS = [
214215
];
215216

216217
test("parse ls output", async (t) => {
218+
if (platform() === "win32") {
219+
return;
220+
}
221+
217222
for (const data of PARSER_TESTS) {
218223
t.test(data.name, async (t) => {
219224
const res = parseLsOutput(data.in);

test/system/static.test.ts

+8
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,10 @@ test("static analysis for distroless base-debian10", async (t) => {
408408
});
409409

410410
test("experimental static analysis for debian images", async (t) => {
411+
if (os.platform() === "win32") {
412+
return;
413+
}
414+
411415
const dockerSaveStub = sinon.stub(Docker.prototype, "save").callThrough();
412416

413417
t.teardown(() => {
@@ -473,6 +477,10 @@ test("experimental static analysis for debian images", async (t) => {
473477
});
474478

475479
test("static and dynamic scanning results are aligned", async (t) => {
480+
if (os.platform() === "win32") {
481+
return;
482+
}
483+
476484
const imageNameAndTag = "debian:10";
477485
const dockerfile = undefined;
478486
const manifestGlobs = [

test/system/system.test.ts

+46-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { platform } from "os";
12
import * as path from "path";
23
import { test } from "tap";
34

@@ -13,7 +14,11 @@ import {
1314
const getDockerfileFixturePath = (folder) =>
1415
path.join(__dirname, "../fixtures/dockerfiles/library", folder, "Dockerfile");
1516

16-
test("attempt to connect to non-existent host", (t) => {
17+
test("attempt to connect to non-existent host", async (t) => {
18+
if (platform() === "win32") {
19+
return;
20+
}
21+
1722
const host = "does-not-exist:1234";
1823
const options = { host };
1924

@@ -48,6 +53,10 @@ test("inspect an image that does not exist and is not pullable", (t) => {
4853
});
4954

5055
test("inspect an image with an unsupported pkg manager", async (t) => {
56+
if (platform() === "win32") {
57+
return;
58+
}
59+
5160
const imgName = "archlinux/base@sha256";
5261
const imgTag =
5362
"42b6236b8f1b85a3bea6c8055f7e290f503440f722c9b4f82cc04bdcf3bcfcef";
@@ -67,6 +76,10 @@ test("inspect an image with an unsupported pkg manager", async (t) => {
6776
});
6877

6978
test("inspect a scratch image", async (t) => {
79+
if (platform() === "win32") {
80+
return;
81+
}
82+
7083
const imgName = "busybox";
7184
const imgTag = "1.31.1";
7285
const img = imgName + ":" + imgTag;
@@ -84,7 +97,11 @@ test("inspect a scratch image", async (t) => {
8497
t.same(pluginResult.plugin.packageManager, "linux", "package manager linux");
8598
});
8699

87-
test("inspect node:6.14.2 - provider and regular pkg as same dependency", (t) => {
100+
test("inspect node:6.14.2 - provider and regular pkg as same dependency", async (t) => {
101+
if (platform() === "win32") {
102+
return;
103+
}
104+
88105
const imgName = "node";
89106
const imgTag = "6.14.2";
90107
const img = imgName + ":" + imgTag;
@@ -189,7 +206,11 @@ test("inspect node:6.14.2 - provider and regular pkg as same dependency", (t) =>
189206
});
190207
});
191208

192-
test("inspect nginx:1.13.10", (t) => {
209+
test("inspect nginx:1.13.10", async (t) => {
210+
if (platform() === "win32") {
211+
return;
212+
}
213+
193214
const imgName = "nginx";
194215
const imgTag = "1.13.10";
195216
const img = imgName + ":" + imgTag;
@@ -344,7 +365,11 @@ test("inspect nginx:1.13.10", (t) => {
344365
});
345366
});
346367

347-
test("inspect redis:3.2.11-alpine", (t) => {
368+
test("inspect redis:3.2.11-alpine", async (t) => {
369+
if (platform() === "win32") {
370+
return;
371+
}
372+
348373
const imgName = "redis";
349374
const imgTag = "3.2.11-alpine";
350375
const img = imgName + ":" + imgTag;
@@ -581,6 +606,10 @@ test("inspect redis:3.2.11-alpine", (t) => {
581606
test(
582607
"inspect image with hostname " + "localhost:5000/redis:3.2.11-alpine",
583608
async (t) => {
609+
if (platform() === "win32") {
610+
return;
611+
}
612+
584613
const imgName = "redis";
585614
const imgTag = "3.2.11-alpine";
586615
const img = imgName + ":" + imgTag;
@@ -614,6 +643,10 @@ test(
614643
);
615644

616645
test("inspect image with sha@256 " + "ubuntu@sha256", async (t) => {
646+
if (platform() === "win32") {
647+
return;
648+
}
649+
617650
const imgName = "ubuntu";
618651
const imgTag = "";
619652
const imgSha =
@@ -644,6 +677,10 @@ test(
644677
"inspect image with hostname plus additional namespacing: " +
645678
"localhost:5000/redis:3.2.11-alpine",
646679
async (t) => {
680+
if (platform() === "win32") {
681+
return;
682+
}
683+
647684
const imgName = "redis";
648685
const imgTag = "3.2.11-alpine";
649686
const img = imgName + ":" + imgTag;
@@ -667,7 +704,11 @@ test(
667704
},
668705
);
669706

670-
test("inspect centos", (t) => {
707+
test("inspect centos", async (t) => {
708+
if (platform() === "win32") {
709+
return;
710+
}
711+
671712
const imgName = "centos";
672713
const imgTag = "7.4.1708";
673714
const img = imgName + ":" + imgTag;

0 commit comments

Comments
 (0)