diff --git a/http/etag_test.ts b/http/etag_test.ts index fef8096b7546..deb19eb448ef 100644 --- a/http/etag_test.ts +++ b/http/etag_test.ts @@ -42,13 +42,14 @@ Deno.test({ Deno.test({ name: "eTag() handles Deno.FileInfo", async fn() { - const fixture: Deno.FileInfo = { + const fixture = { isFile: true, isDirectory: false, isSymlink: false, size: 1024, mtime: new Date(Date.UTC(96, 1, 2, 3, 4, 5, 6)), atime: null, + ctime: null, birthtime: null, dev: 0, ino: null, diff --git a/http/file_server_test.ts b/http/file_server_test.ts index 55f5d564ee7a..27fa7ec40f69 100644 --- a/http/file_server_test.ts +++ b/http/file_server_test.ts @@ -22,6 +22,7 @@ import denoConfig from "./deno.json" with { type: "json" }; import { MINUTE } from "@std/datetime/constants"; import { getAvailablePort } from "@std/net/get-available-port"; import { concat } from "@std/bytes/concat"; +import { lessThan, parse as parseSemver } from "@std/semver"; const moduleDir = dirname(fromFileUrl(import.meta.url)); const testdataDir = resolve(moduleDir, "testdata"); @@ -32,6 +33,11 @@ const serveDirOptions: ServeDirOptions = { showDotfiles: true, enableCors: true, }; +const denoVersion = parseSemver(Deno.version.deno); +const isCanary = denoVersion.build ? denoVersion.build.length > 0 : false; +// FileInfo.mode is not available on Windows before Deno 2.1.0 +const fsModeUnavailable = Deno.build.os === "windows" && + lessThan(denoVersion, parseSemver("2.1.0")) && !isCanary; const TEST_FILE_PATH = join(testdataDir, "test_file.txt"); const TEST_FILE_STAT = await Deno.stat(TEST_FILE_PATH); @@ -188,10 +194,7 @@ Deno.test("serveDir() serves directory index", async () => { assertStringIncludes(page, 'hello.html'); assertStringIncludes(page, 'tls/'); assertStringIncludes(page, "%2525A.txt"); - // `Deno.FileInfo` is not completely compatible with Windows yet - // TODO(bartlomieju): `mode` should work correctly in the future. - // Correct this test case accordingly. - if (Deno.build.os === "windows") { + if (fsModeUnavailable) { assertMatch(page, /