Skip to content

Commit

Permalink
Fix Windows support, closes #10
Browse files Browse the repository at this point in the history
- Upgrade parsed-html-rewriter to 0.1.8 which inlines whatwg-stream-to-async-iter
- Fix a few broken tests on Windows
- Add Windows testing to GitHub actions workflow
  • Loading branch information
mrbbot committed Jul 10, 2021
1 parent 81a4d1a commit 65037a1
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 38 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,26 @@

name: Test

on: [push, pull_request]
on:
push:
branches: [ master ]

jobs:
test:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}

strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
os: [ubuntu-latest, windows-latest]
node: [10.12, 14.x, 16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
node-version: ${{ matrix.node }}
- run: npm ci
- run: npm run build --if-present
- run: npm test
39 changes: 10 additions & 29 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"dependencies": {
"@mrbbot/node-fetch": "^4.2.0",
"@peculiar/webcrypto": "^1.1.4",
"@mrbbot/parsed-html-rewriter": "^0.1.6",
"@mrbbot/parsed-html-rewriter": "^0.1.8",
"chalk": "^4.1.0",
"chokidar": "^3.5.1",
"cjstoesm": "^1.1.4",
Expand Down
17 changes: 16 additions & 1 deletion test/kv/storage/storage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const fileStorageFactory: TestStorageFactory = {
},
};
const unsanitisedFileStorageFactory: TestStorageFactory = {
// Only used for read tests, we never write to an unsanitised FileKVStorage
name: "FileKVStorage (Unsanitised)",
async factory(t) {
const tmp = await useTmp(t);
Expand All @@ -116,6 +117,15 @@ const unsanitisedFileStorageFactory: TestStorageFactory = {
);
await fs.mkdir(path.join(tmp, "dir"));
await fs.writeFile(path.join(tmp, "dir", "key4"), "value3", "utf8");
if (path.sep !== "/") {
// On platforms with a path separator that's not "/" (e.g. Windows), the
// key won't be correct so write an additional meta file containing it
await fs.writeFile(
path.join(tmp, "dir", "key4.meta.json"),
JSON.stringify({ key: "dir/key4" }),
"utf8"
);
}
return new FileKVStorage(tmp, false, testClock);
},
};
Expand Down Expand Up @@ -219,6 +229,7 @@ getExistingMacro.title = (providedTitle, { name }) =>
`${name}: get: gets existing key`;
test(getExistingMacro, memoryStorageFactory);
test(getExistingMacro, fileStorageFactory);
test(getExistingMacro, unsanitisedFileStorageFactory);
redisTest(getExistingMacro, redisStorageFactory);

const getExistingWithMetadataMacro: Macro<[TestStorageFactory]> = async (
Expand All @@ -235,6 +246,7 @@ getExistingWithMetadataMacro.title = (providedTitle, { name }) =>
`${name}: get: gets existing key with metadata`;
test(getExistingWithMetadataMacro, memoryStorageFactory);
test(getExistingWithMetadataMacro, fileStorageFactory);
test(getExistingWithMetadataMacro, unsanitisedFileStorageFactory);
redisTest(getExistingWithMetadataMacro, redisStorageFactory);

const getNonExistentMacro: Macro<[TestStorageFactory]> = async (
Expand All @@ -249,6 +261,7 @@ getNonExistentMacro.title = (providedTitle, { name }) =>
`${name}: get: returns undefined for non-existent key`;
test(getNonExistentMacro, memoryStorageFactory);
test(getNonExistentMacro, fileStorageFactory);
test(getNonExistentMacro, unsanitisedFileStorageFactory);
redisTest(getNonExistentMacro, redisStorageFactory);

const getExpiredMacro: Macro<[TestStorageFactory]> = async (t, { factory }) => {
Expand All @@ -260,6 +273,7 @@ getExpiredMacro.title = (providedTitle, { name }) =>
`${name}: get: respects expiration`;
test(getExpiredMacro, memoryStorageFactory);
test(getExpiredMacro, fileStorageFactory);
test(getExpiredMacro, unsanitisedFileStorageFactory);
redisTest(getExpiredMacro, redisStorageFactory);

const getSkipsMetadataMacro: Macro<[TestStorageFactory]> = async (
Expand Down Expand Up @@ -301,6 +315,7 @@ getManyMacro.title = (providedTitle, { name }) =>
`${name}: get: gets many keys`;
test(getManyMacro, memoryStorageFactory);
test(getManyMacro, fileStorageFactory);
test(getManyMacro, unsanitisedFileStorageFactory);
redisTest(getManyMacro, redisStorageFactory);

const getManyEmptyMacro: Macro<[TestStorageFactory]> = async (
Expand All @@ -314,6 +329,7 @@ getManyEmptyMacro.title = (providedTitle, { name }) =>
`${name}: getMany: returns nothing for empty keys`;
test(getManyEmptyMacro, memoryStorageFactory);
test(getManyEmptyMacro, fileStorageFactory);
test(getManyEmptyMacro, unsanitisedFileStorageFactory);
redisTest(getManyEmptyMacro, redisStorageFactory);

const getManySkipsMetadataMacro: Macro<[TestStorageFactory]> = async (
Expand Down Expand Up @@ -372,7 +388,6 @@ putNewDirectoryMacro.title = (providedTitle, { name }) =>
`${name}: put: puts new key in new directory`;
test(putNewDirectoryMacro, memoryStorageFactory);
test(putNewDirectoryMacro, fileStorageFactory);
test(putNewDirectoryMacro, unsanitisedFileStorageFactory);
redisTest(putNewDirectoryMacro, redisStorageFactory);

const putNewWithMetadataMacro: Macro<[TestStorageFactory]> = async (
Expand Down
4 changes: 2 additions & 2 deletions test/options/processor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,12 @@ test.serial(
"getPackageScript: logs error if cannot read script from custom file only",
async (t) => {
const tmp = await useTmp(t);
const log = new TestLog();
// Change dirs so we don't load Miniflare's own package.json file
const cwd = process.cwd();
process.chdir(tmp);
t.teardown(() => process.chdir(cwd));
const log = new TestLog();
let processor = new OptionsProcessor(log, {});
process.chdir(cwd);
let scriptPath = await processor.getPackageScript();
t.is(scriptPath, undefined);
t.deepEqual(log.errors, []);
Expand Down

0 comments on commit 65037a1

Please sign in to comment.