Skip to content

Commit 257b5c4

Browse files
authored
Fixes rejections in Windows tests (#2452)
1 parent 18939e4 commit 257b5c4

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

infra/testing/confirm-directory-contains.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88

99
const expect = require('chai').expect;
1010
const globby = require('globby');
11-
const path = require('path');
11+
const upath = require('upath');
1212

1313
module.exports = async (directory, expectedContents) => {
14-
const globbedFiles = await globby(directory);
15-
const filesWithNativeSeparator =
16-
globbedFiles.map((file) => file.replace(/\//g, path.sep));
17-
expect(filesWithNativeSeparator).to.have.members(expectedContents);
14+
const relativeFiles = await globby('**', {cwd: directory});
15+
const absoluteFilesWithNativeSeparator = relativeFiles.map(
16+
(file) => upath.resolve(directory, file).replace(/\//g, upath.sep));
17+
expect(absoluteFilesWithNativeSeparator).to.have.members(expectedContents);
1818
};

test/workbox-build/node/generate-sw.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ describe(`[workbox-build] generate-sw.js (End to End)`, function() {
137137
// Line ending differences lead to different sizes on Windows.
138138
expect(size).to.be.oneOf([2604, 2686]);
139139

140-
confirmDirectoryContains(outputDir, filePaths);
140+
await confirmDirectoryContains(outputDir, filePaths);
141141

142142
await validateServiceWorkerRuntime({swFile: swDest, expectedMethodCalls: {
143143
__WB_DISABLE_DEV_LOGS: undefined,
@@ -178,7 +178,7 @@ describe(`[workbox-build] generate-sw.js (End to End)`, function() {
178178
// Line ending differences lead to different sizes on Windows.
179179
expect(size).to.be.oneOf([2604, 2686]);
180180

181-
confirmDirectoryContains(outputDir, filePaths);
181+
await confirmDirectoryContains(outputDir, filePaths);
182182

183183
await validateServiceWorkerRuntime({swFile: swDest, expectedMethodCalls: {
184184
__WB_DISABLE_DEV_LOGS: true,
@@ -220,7 +220,7 @@ describe(`[workbox-build] generate-sw.js (End to End)`, function() {
220220
// Line ending differences lead to different sizes on Windows.
221221
expect(size).to.be.oneOf([2604, 2686]);
222222

223-
confirmDirectoryContains(outputDir, filePaths);
223+
await confirmDirectoryContains(outputDir, filePaths);
224224

225225
await validateServiceWorkerRuntime({swFile: swDest, expectedMethodCalls: {
226226
importScripts: [
@@ -270,7 +270,7 @@ describe(`[workbox-build] generate-sw.js (End to End)`, function() {
270270
// Line ending differences lead to different sizes on Windows.
271271
expect(size).to.be.oneOf([2604, 2686]);
272272

273-
confirmDirectoryContains(outputDir, filePaths);
273+
await confirmDirectoryContains(outputDir, filePaths);
274274

275275
await validateServiceWorkerRuntime({swFile: swDest, expectedMethodCalls: {
276276
importScripts: [[/^\.\/workbox-[0-9a-f]{8}$/]],
@@ -321,7 +321,7 @@ describe(`[workbox-build] generate-sw.js (End to End)`, function() {
321321
// Line ending differences lead to different sizes on Windows.
322322
expect(size).to.be.oneOf([2604, 2686]);
323323

324-
confirmDirectoryContains(outputDir, filePaths);
324+
await confirmDirectoryContains(outputDir, filePaths);
325325

326326
await validateServiceWorkerRuntime({swFile: swDest, expectedMethodCalls: {
327327
importScripts: [[/^\.\/workbox-[0-9a-f]{8}$/]],
@@ -367,7 +367,7 @@ describe(`[workbox-build] generate-sw.js (End to End)`, function() {
367367
// Line ending differences lead to different sizes on Windows.
368368
expect(size).to.be.oneOf([2604, 2686]);
369369

370-
confirmDirectoryContains(outputDir, filePaths);
370+
await confirmDirectoryContains(outputDir, filePaths);
371371

372372
await validateServiceWorkerRuntime({swFile: swDest, expectedMethodCalls: {
373373
importScripts: [[/^\.\/workbox-[0-9a-f]{8}$/]],
@@ -419,7 +419,7 @@ describe(`[workbox-build] generate-sw.js (End to End)`, function() {
419419
// Line ending differences lead to different sizes on Windows.
420420
expect(size).to.be.oneOf([2604, 2686]);
421421

422-
confirmDirectoryContains(outputDir, filePaths);
422+
await confirmDirectoryContains(outputDir, filePaths);
423423

424424
await validateServiceWorkerRuntime({swFile: swDest, expectedMethodCalls: {
425425
createHandlerBoundToURL: [[navigateFallback]],
@@ -469,7 +469,7 @@ describe(`[workbox-build] generate-sw.js (End to End)`, function() {
469469
// Line ending differences lead to different sizes on Windows.
470470
expect(size).to.be.oneOf([2604, 2686]);
471471

472-
confirmDirectoryContains(outputDir, filePaths);
472+
await confirmDirectoryContains(outputDir, filePaths);
473473

474474
await validateServiceWorkerRuntime({swFile: swDest, expectedMethodCalls: {
475475
importScripts: [[/^\.\/workbox-[0-9a-f]{8}$/]],
@@ -514,7 +514,7 @@ describe(`[workbox-build] generate-sw.js (End to End)`, function() {
514514
// Line ending differences lead to different sizes on Windows.
515515
expect(size).to.be.oneOf([2535, 2611]);
516516

517-
confirmDirectoryContains(outputDir, filePaths);
517+
await confirmDirectoryContains(outputDir, filePaths);
518518

519519
await validateServiceWorkerRuntime({swFile: swDest, expectedMethodCalls: {
520520
importScripts: [[/^\.\/workbox-[0-9a-f]{8}$/]],
@@ -548,7 +548,7 @@ describe(`[workbox-build] generate-sw.js (End to End)`, function() {
548548
// Line ending differences lead to different sizes on Windows.
549549
expect(size).to.be.oneOf([2604, 2686]);
550550

551-
confirmDirectoryContains(outputDir, filePaths);
551+
await confirmDirectoryContains(outputDir, filePaths);
552552

553553
await validateServiceWorkerRuntime({swFile: swDest, expectedMethodCalls: {
554554
importScripts: [[/^\.\/workbox-[0-9a-f]{8}$/]],
@@ -593,7 +593,7 @@ describe(`[workbox-build] generate-sw.js (End to End)`, function() {
593593
// Line ending differences lead to different sizes on Windows.
594594
expect(size).to.be.oneOf([2604, 2686]);
595595

596-
confirmDirectoryContains(outputDir, filePaths);
596+
await confirmDirectoryContains(outputDir, filePaths);
597597

598598
await validateServiceWorkerRuntime({swFile: swDest, expectedMethodCalls: {
599599
importScripts: [[/^\.\/workbox-[0-9a-f]{8}$/]],
@@ -637,7 +637,7 @@ describe(`[workbox-build] generate-sw.js (End to End)`, function() {
637637
// Line ending differences lead to different sizes on Windows.
638638
expect(size).to.be.oneOf([2604, 2686]);
639639

640-
confirmDirectoryContains(outputDir, filePaths);
640+
await confirmDirectoryContains(outputDir, filePaths);
641641
});
642642

643643
it(`should inline the Workbox runtime when 'inlineWorkboxRuntime' is true`, async function() {
@@ -654,7 +654,7 @@ describe(`[workbox-build] generate-sw.js (End to End)`, function() {
654654
// Line ending differences lead to different sizes on Windows.
655655
expect(size).to.be.oneOf([2604, 2686]);
656656

657-
confirmDirectoryContains(outputDir, filePaths);
657+
await confirmDirectoryContains(outputDir, filePaths);
658658
// We can't validate the generated sw.js file, unfortunately.
659659
});
660660
});

0 commit comments

Comments
 (0)