From af132f2c9f15bd5af16df120667fdcf90a55bacc Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Mon, 27 Apr 2020 18:33:07 -0400 Subject: [PATCH 01/14] WIP llvm target triple for Deno.build --- cli/build.rs | 5 +++++ cli/js/build.ts | 37 +++++++++++++++++++------------------ cli/js/deno.ts | 2 +- cli/js/lib.deno.ns.d.ts | 23 ++++++++++++----------- cli/js/ops/runtime.ts | 5 ++--- cli/js/runtime.ts | 8 +++----- cli/ops/runtime.rs | 13 +------------ 7 files changed, 43 insertions(+), 50 deletions(-) diff --git a/cli/build.rs b/cli/build.rs index f49cde386c9131..2ea00a25d94bcf 100644 --- a/cli/build.rs +++ b/cli/build.rs @@ -20,6 +20,11 @@ fn main() { deno_typescript::ts_version() ); + println!( + "cargo:rustc-env=TARGET={}", + std::env::var("TARGET").unwrap() + ); + let extern_crate_modules = include_crate_modules![deno_core]; // The generation of snapshots is slow and often unnecessary. Until we figure diff --git a/cli/js/build.ts b/cli/js/build.ts index f00c5b463abf7f..ee9e3a1e4a5589 100644 --- a/cli/js/build.ts +++ b/cli/js/build.ts @@ -1,24 +1,25 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -export type OperatingSystem = "mac" | "win" | "linux"; +//@ts-ignore +export const build: { + target: string, + arch: string, + os: string, + vendor: string, + env?: string, +}= {}; -export type Arch = "x64" | "arm64"; - -// Do not add unsupported platforms. -export interface BuildInfo { - arch: Arch; - - os: OperatingSystem; -} - -export const build: BuildInfo = { - arch: "" as Arch, - os: "" as OperatingSystem, -}; - -export function setBuildInfo(os: OperatingSystem, arch: Arch): void { - build.os = os; +export function setBuildInfo(target: string): void { + const [arch, vendor, os, env] = target.split("-", 4); + //@ts-ignore + build.target = target; + //@ts-ignore build.arch = arch; - + //@ts-ignore + build.vendor = vendor; + //@ts-ignore + build.os = os; + //@ts-ignore + build.env = env; Object.freeze(build); } diff --git a/cli/js/deno.ts b/cli/js/deno.ts index caf98ac70f22cc..7203e346196606 100644 --- a/cli/js/deno.ts +++ b/cli/js/deno.ts @@ -8,7 +8,7 @@ export { writeAll, writeAllSync, } from "./buffer.ts"; -export { build, OperatingSystem, Arch } from "./build.ts"; +export { build } from "./build.ts"; export { chmodSync, chmod } from "./ops/fs/chmod.ts"; export { chownSync, chown } from "./ops/fs/chown.ts"; export { transpileOnly, compile, bundle } from "./compiler/api.ts"; diff --git a/cli/js/lib.deno.ns.d.ts b/cli/js/lib.deno.ns.d.ts index 7a04776822e75a..069826576602b8 100644 --- a/cli/js/lib.deno.ns.d.ts +++ b/cli/js/lib.deno.ns.d.ts @@ -2342,19 +2342,20 @@ declare namespace Deno { */ export function inspect(value: unknown, options?: InspectOptions): string; - export type OperatingSystem = "mac" | "win" | "linux"; - - export type Arch = "x64" | "arm64"; - - interface BuildInfo { - /** The CPU architecture. */ - arch: Arch; - /** The operating system. */ - os: OperatingSystem; - } /** Build related information. */ - export const build: BuildInfo; + export const build: { + /** The LLVM target triple */ + target: string, + /** Instruction set architecture */ + arch: "x86_64", + /** Operating system */ + os: "darwin" | "linux" | "windows", + /** Computer vendor */ + vendor: string, + /** Optional environment */ + env?: string, + }; interface Version { deno: string; diff --git a/cli/js/ops/runtime.ts b/cli/js/ops/runtime.ts index 262e46231909ac..ec5873d3198d63 100644 --- a/cli/js/ops/runtime.ts +++ b/cli/js/ops/runtime.ts @@ -21,11 +21,10 @@ export interface Start { v8Version: string; tsVersion: string; noColor: boolean; - os: OperatingSystem; - arch: Arch; + target: string; } -export function start(): Start { +export function opStart(): Start { return sendSync("op_start"); } diff --git a/cli/js/runtime.ts b/cli/js/runtime.ts index d586503af5ba33..e16cee2282fad7 100644 --- a/cli/js/runtime.ts +++ b/cli/js/runtime.ts @@ -6,7 +6,7 @@ import * as util from "./util.ts"; import { setBuildInfo } from "./build.ts"; import { setVersions } from "./version.ts"; import { setPrepareStackTrace } from "./error_stack.ts"; -import { Start, start as startOp } from "./ops/runtime.ts"; +import { Start, opStart } from "./ops/runtime.ts"; import { handleTimerMacrotask } from "./web/timers.ts"; export let OPS_CACHE: { [name: string]: number }; @@ -36,12 +36,10 @@ export function start(source?: string): Start { // First we send an empty `Start` message to let the privileged side know we // are ready. The response should be a `StartRes` message containing the CLI // args and other info. - const s = startOp(); - + const s = opStart(); setVersions(s.denoVersion, s.v8Version, s.tsVersion); - setBuildInfo(s.os, s.arch); + setBuildInfo(s.target); util.setLogDebug(s.debugFlag, source); - setPrepareStackTrace(Error); return s; } diff --git a/cli/ops/runtime.rs b/cli/ops/runtime.rs index 72555344ced5ae..96bf451ed48258 100644 --- a/cli/ops/runtime.rs +++ b/cli/ops/runtime.rs @@ -9,16 +9,6 @@ use deno_core::CoreIsolate; use deno_core::ZeroCopyBuf; use std::env; -/// BUILD_OS and BUILD_ARCH match the values in Deno.build. See js/build.ts. -#[cfg(target_os = "macos")] -static BUILD_OS: &str = "mac"; -#[cfg(target_os = "linux")] -static BUILD_OS: &str = "linux"; -#[cfg(target_os = "windows")] -static BUILD_OS: &str = "win"; -#[cfg(target_arch = "x86_64")] -static BUILD_ARCH: &str = "x64"; - pub fn init(i: &mut CoreIsolate, s: &State) { i.register_op("op_start", s.stateful_json_op(op_start)); i.register_op("op_metrics", s.stateful_json_op(op_metrics)); @@ -45,8 +35,7 @@ fn op_start( "denoVersion": version::DENO, "tsVersion": version::TYPESCRIPT, "noColor": !colors::use_color(), - "os": BUILD_OS, - "arch": BUILD_ARCH, + "target": env!("TARGET"), }))) } From ac4d8da97de07884e5f1cbc8dcb3a83b65f64b68 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Mon, 27 Apr 2020 18:36:31 -0400 Subject: [PATCH 02/14] format --- cli/js/build.ts | 12 ++++++------ cli/js/lib.deno.ns.d.ts | 11 +++++------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/cli/js/build.ts b/cli/js/build.ts index ee9e3a1e4a5589..ef3bb0037d2327 100644 --- a/cli/js/build.ts +++ b/cli/js/build.ts @@ -2,12 +2,12 @@ //@ts-ignore export const build: { - target: string, - arch: string, - os: string, - vendor: string, - env?: string, -}= {}; + target: string; + arch: string; + os: string; + vendor: string; + env?: string; +} = {}; export function setBuildInfo(target: string): void { const [arch, vendor, os, env] = target.split("-", 4); diff --git a/cli/js/lib.deno.ns.d.ts b/cli/js/lib.deno.ns.d.ts index 069826576602b8..26c9f893c451e2 100644 --- a/cli/js/lib.deno.ns.d.ts +++ b/cli/js/lib.deno.ns.d.ts @@ -2342,19 +2342,18 @@ declare namespace Deno { */ export function inspect(value: unknown, options?: InspectOptions): string; - /** Build related information. */ export const build: { /** The LLVM target triple */ - target: string, + target: string; /** Instruction set architecture */ - arch: "x86_64", + arch: "x86_64"; /** Operating system */ - os: "darwin" | "linux" | "windows", + os: "darwin" | "linux" | "windows"; /** Computer vendor */ - vendor: string, + vendor: string; /** Optional environment */ - env?: string, + env?: string; }; interface Version { From 2bdc8d7884b1cd0519c517f88e9b99bd25c55657 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Mon, 27 Apr 2020 18:54:43 -0400 Subject: [PATCH 03/14] fix --- cli/js/lib.deno.ns.d.ts | 2 +- std/fs/copy_test.ts | 2 +- std/fs/ensure_symlink_test.ts | 2 +- std/http/file_server_test.ts | 4 ++-- std/path/globrex.ts | 2 +- std/path/globrex_test.ts | 2 +- std/signal/test.ts | 6 +++--- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cli/js/lib.deno.ns.d.ts b/cli/js/lib.deno.ns.d.ts index 26c9f893c451e2..9c992bb7b9f3c6 100644 --- a/cli/js/lib.deno.ns.d.ts +++ b/cli/js/lib.deno.ns.d.ts @@ -35,7 +35,7 @@ declare namespace Deno { * * Deno.test({ * name: "example ignored test", - * ignore: Deno.build.os === "win" + * ignore: Deno.build.os === "windows" * fn(): void { * // This test is ignored only on Windows machines * }, diff --git a/std/fs/copy_test.ts b/std/fs/copy_test.ts index 5323ac9e4fbb60..1f3330226506a5 100644 --- a/std/fs/copy_test.ts +++ b/std/fs/copy_test.ts @@ -15,7 +15,7 @@ import { ensureSymlink, ensureSymlinkSync } from "./ensure_symlink.ts"; const testdataDir = path.resolve("fs", "testdata"); // TODO(axetroy): Add test for Windows once symlink is implemented for Windows. -const isWindows = Deno.build.os === "win"; +const isWindows = Deno.build.os === "windows"; function testCopy(name: string, cb: (tempDir: string) => Promise): void { Deno.test({ diff --git a/std/fs/ensure_symlink_test.ts b/std/fs/ensure_symlink_test.ts index bbd31ef24cad78..f34d4d65b71fc5 100644 --- a/std/fs/ensure_symlink_test.ts +++ b/std/fs/ensure_symlink_test.ts @@ -9,7 +9,7 @@ import * as path from "../path/mod.ts"; import { ensureSymlink, ensureSymlinkSync } from "./ensure_symlink.ts"; const testdataDir = path.resolve("fs", "testdata"); -const isWindows = Deno.build.os === "win"; +const isWindows = Deno.build.os === "windows"; Deno.test(async function ensureSymlinkIfItNotExist(): Promise { const testDir = path.join(testdataDir, "link_file_1"); diff --git a/std/http/file_server_test.ts b/std/http/file_server_test.ts index dc14d2c5744765..127c03e15f3f67 100644 --- a/std/http/file_server_test.ts +++ b/std/http/file_server_test.ts @@ -62,9 +62,9 @@ test(async function serveDirectory(): Promise { // `Deno.FileInfo` is not completely compatible with Windows yet // TODO: `mode` should work correctly in the future. // Correct this test case accordingly. - Deno.build.os !== "win" && + Deno.build.os !== "windows" && assert(/(\s)*\([a-zA-Z-]{10}\)(\s)*<\/td>/.test(page)); - Deno.build.os === "win" && + Deno.build.os === "windows" && assert(/(\s)*\(unknown mode\)(\s)*<\/td>/.test(page)); assert(page.includes(`README.md`)); } finally { diff --git a/std/path/globrex.ts b/std/path/globrex.ts index 0fe833a52ed10c..868df797ae56f0 100644 --- a/std/path/globrex.ts +++ b/std/path/globrex.ts @@ -2,7 +2,7 @@ // MIT License // Copyright (c) 2018 Terkel Gjervig Nielsen -const isWin = Deno.build.os === "win"; +const isWin = Deno.build.os === "windows"; const SEP = isWin ? `(?:\\\\|\\/)` : `\\/`; const SEP_ESC = isWin ? `\\\\` : `/`; const SEP_RAW = isWin ? `\\` : `/`; diff --git a/std/path/globrex_test.ts b/std/path/globrex_test.ts index 27541a5c8c6904..c52ed108e563b3 100644 --- a/std/path/globrex_test.ts +++ b/std/path/globrex_test.ts @@ -6,7 +6,7 @@ const { test } = Deno; import { assertEquals } from "../testing/asserts.ts"; import { GlobrexOptions, globrex } from "./globrex.ts"; -const isWin = Deno.build.os === "win"; +const isWin = Deno.build.os === "windows"; const t = { equal: assertEquals, is: assertEquals }; function match( diff --git a/std/signal/test.ts b/std/signal/test.ts index 95529a6e2a1638..c4d1bf3a779ebd 100644 --- a/std/signal/test.ts +++ b/std/signal/test.ts @@ -5,7 +5,7 @@ import { signal, onSignal } from "./mod.ts"; test({ name: "signal() throws when called with empty signals", - ignore: Deno.build.os === "win", + ignore: Deno.build.os === "windows", fn() { assertThrows( () => { @@ -20,7 +20,7 @@ test({ test({ name: "signal() iterates for multiple signals", - ignore: Deno.build.os === "win", + ignore: Deno.build.os === "windows", fn: async (): Promise => { // This prevents the program from exiting. const t = setInterval(() => {}, 1000); @@ -61,7 +61,7 @@ test({ test({ name: "onSignal() registers and disposes of event handler", - ignore: Deno.build.os === "win", + ignore: Deno.build.os === "windows", async fn() { // This prevents the program from exiting. const t = setInterval(() => {}, 1000); From 8926b6b000067e048a183e265f3814b9f1cca635 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Mon, 27 Apr 2020 21:28:40 -0400 Subject: [PATCH 04/14] fix typescript --- cli/js/build.ts | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/cli/js/build.ts b/cli/js/build.ts index ef3bb0037d2327..e41cbf22fce173 100644 --- a/cli/js/build.ts +++ b/cli/js/build.ts @@ -1,25 +1,19 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -//@ts-ignore -export const build: { - target: string; - arch: string; - os: string; - vendor: string; - env?: string; -} = {}; +export const build = { + target: "unknown", + arch: "unknown", + os: "unknown", + vendor: "unknown", + env: undefined as (string | undefined) +}; export function setBuildInfo(target: string): void { const [arch, vendor, os, env] = target.split("-", 4); - //@ts-ignore build.target = target; - //@ts-ignore build.arch = arch; - //@ts-ignore build.vendor = vendor; - //@ts-ignore build.os = os; - //@ts-ignore build.env = env; Object.freeze(build); } From e257bdf981f4672c48d298258c79857332e97dfc Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Mon, 27 Apr 2020 21:30:08 -0400 Subject: [PATCH 05/14] fix --- cli/js/signals.ts | 2 +- cli/js/write_file.ts | 4 ++-- std/path/constants.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cli/js/signals.ts b/cli/js/signals.ts index e7fd8c04d12bd3..599201df579881 100644 --- a/cli/js/signals.ts +++ b/cli/js/signals.ts @@ -83,7 +83,7 @@ export function setSignals(): void { } export function signal(signo: number): SignalStream { - if (build.os === "win") { + if (build.os === "windows") { throw new Error("not implemented!"); } return new SignalStream(signo); diff --git a/cli/js/write_file.ts b/cli/js/write_file.ts index af3f6725140cf8..6961b78eae1117 100644 --- a/cli/js/write_file.ts +++ b/cli/js/write_file.ts @@ -32,7 +32,7 @@ export function writeFileSync( if ( options.mode !== undefined && options.mode !== null && - build.os !== "win" + build.os !== "windows" ) { chmodSync(path, options.mode); } @@ -62,7 +62,7 @@ export async function writeFile( if ( options.mode !== undefined && options.mode !== null && - build.os !== "win" + build.os !== "windows" ) { await chmod(path, options.mode); } diff --git a/std/path/constants.ts b/std/path/constants.ts index 1e1eeeb493d454..97d3bcf58083a0 100644 --- a/std/path/constants.ts +++ b/std/path/constants.ts @@ -48,7 +48,7 @@ export const CHAR_EQUAL = 61; /* = */ export const CHAR_0 = 48; /* 0 */ export const CHAR_9 = 57; /* 9 */ -export const isWindows = build.os === "win"; +export const isWindows = build.os === "windows"; export const EOL = isWindows ? "\r\n" : "\n"; export const SEP = isWindows ? "\\" : "/"; export const SEP_PATTERN = isWindows ? /[\\/]+/ : /\/+/; From 2bbde66cb0e824aaeaa6eee2a7c706c87df21b67 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Mon, 27 Apr 2020 21:31:07 -0400 Subject: [PATCH 06/14] fixes --- cli/js/ops/process.ts | 2 +- cli/js/tests/blob_test.ts | 2 +- cli/js/tests/chmod_test.ts | 8 ++++---- cli/js/tests/chown_test.ts | 2 +- cli/js/tests/files_test.ts | 4 ++-- cli/js/tests/fs_events_test.ts | 2 +- cli/js/tests/make_temp_test.ts | 8 ++++---- cli/js/tests/mkdir_test.ts | 4 ++-- cli/js/tests/net_test.ts | 20 ++++++++++---------- cli/js/tests/os_test.ts | 2 +- cli/js/tests/process_test.ts | 4 ++-- cli/js/tests/read_link_test.ts | 4 ++-- cli/js/tests/realpath_test.ts | 8 ++++---- cli/js/tests/remove_test.ts | 8 ++++---- cli/js/tests/rename_test.ts | 6 +++--- cli/js/tests/signal_test.ts | 8 ++++---- cli/js/tests/stat_test.ts | 4 ++-- cli/js/tests/umask_test.ts | 2 +- cli/js/tests/write_file_test.ts | 4 ++-- 19 files changed, 51 insertions(+), 51 deletions(-) diff --git a/cli/js/ops/process.ts b/cli/js/ops/process.ts index fcfa7b9f5aa362..4fba4d2de50d72 100644 --- a/cli/js/ops/process.ts +++ b/cli/js/ops/process.ts @@ -4,7 +4,7 @@ import { assert } from "../util.ts"; import { build } from "../build.ts"; export function kill(pid: number, signo: number): void { - if (build.os === "win") { + if (build.os === "windows") { throw new Error("Not yet implemented"); } sendSync("op_kill", { pid, signo }); diff --git a/cli/js/tests/blob_test.ts b/cli/js/tests/blob_test.ts index af84c37a35f1a8..70f8fb3d5a2dc9 100644 --- a/cli/js/tests/blob_test.ts +++ b/cli/js/tests/blob_test.ts @@ -66,7 +66,7 @@ unitTest(function nativeEndLine(): void { }; const blob = new Blob(["Hello\nWorld"], options); - assertEquals(blob.size, Deno.build.os === "win" ? 12 : 11); + assertEquals(blob.size, Deno.build.os === "windows" ? 12 : 11); }); unitTest(async function blobText(): Promise { diff --git a/cli/js/tests/chmod_test.ts b/cli/js/tests/chmod_test.ts index 8a534c701236e2..d0d17629d09ccf 100644 --- a/cli/js/tests/chmod_test.ts +++ b/cli/js/tests/chmod_test.ts @@ -2,7 +2,7 @@ import { unitTest, assert, assertEquals } from "./test_util.ts"; unitTest( - { ignore: Deno.build.os === "win", perms: { read: true, write: true } }, + { ignore: Deno.build.os === "windows", perms: { read: true, write: true } }, function chmodSyncSuccess(): void { const enc = new TextEncoder(); const data = enc.encode("Hello"); @@ -21,7 +21,7 @@ unitTest( // Check symlink when not on windows unitTest( { - ignore: Deno.build.os === "win", + ignore: Deno.build.os === "windows", perms: { read: true, write: true }, }, function chmodSyncSymlinkSuccess(): void { @@ -73,7 +73,7 @@ unitTest({ perms: { write: false } }, function chmodSyncPerm(): void { }); unitTest( - { ignore: Deno.build.os === "win", perms: { read: true, write: true } }, + { ignore: Deno.build.os === "windows", perms: { read: true, write: true } }, async function chmodSuccess(): Promise { const enc = new TextEncoder(); const data = enc.encode("Hello"); @@ -93,7 +93,7 @@ unitTest( unitTest( { - ignore: Deno.build.os === "win", + ignore: Deno.build.os === "windows", perms: { read: true, write: true }, }, async function chmodSymlinkSuccess(): Promise { diff --git a/cli/js/tests/chown_test.ts b/cli/js/tests/chown_test.ts index 2d1dc7756a093b..eb3a75ba7eacdb 100644 --- a/cli/js/tests/chown_test.ts +++ b/cli/js/tests/chown_test.ts @@ -2,7 +2,7 @@ import { unitTest, assertEquals, assert } from "./test_util.ts"; // chown on Windows is noop for now, so ignore its testing on Windows -if (Deno.build.os !== "win") { +if (Deno.build.os !== "windows") { async function getUidAndGid(): Promise<{ uid: number; gid: number }> { // get the user ID and group ID of the current process const uidProc = Deno.run({ diff --git a/cli/js/tests/files_test.ts b/cli/js/tests/files_test.ts index 39f4d6ce269589..8480888127795c 100644 --- a/cli/js/tests/files_test.ts +++ b/cli/js/tests/files_test.ts @@ -172,7 +172,7 @@ unitTest( }); file.close(); const pathInfo = Deno.statSync(path); - if (Deno.build.os !== "win") { + if (Deno.build.os !== "windows") { assertEquals(pathInfo.mode! & 0o777, 0o626 & ~Deno.umask()); } } @@ -191,7 +191,7 @@ unitTest( }); file.close(); const pathInfo = Deno.statSync(path); - if (Deno.build.os !== "win") { + if (Deno.build.os !== "windows") { assertEquals(pathInfo.mode! & 0o777, 0o626 & ~Deno.umask()); } } diff --git a/cli/js/tests/fs_events_test.ts b/cli/js/tests/fs_events_test.ts index e31bb261924927..ad8ba8502c6b23 100644 --- a/cli/js/tests/fs_events_test.ts +++ b/cli/js/tests/fs_events_test.ts @@ -20,7 +20,7 @@ unitTest({ perms: { read: true } }, function watchFsInvalidPath() { Deno.watchFs("non-existant.file"); } catch (err) { console.error(err); - if (Deno.build.os === "win") { + if (Deno.build.os === "windows") { assert( err.message.includes( "Input watch path is neither a file nor a directory" diff --git a/cli/js/tests/make_temp_test.ts b/cli/js/tests/make_temp_test.ts index 70ba0108433e52..59fe8c5f526c61 100644 --- a/cli/js/tests/make_temp_test.ts +++ b/cli/js/tests/make_temp_test.ts @@ -31,7 +31,7 @@ unitTest( function makeTempDirSyncMode(): void { const path = Deno.makeTempDirSync(); const pathInfo = Deno.statSync(path); - if (Deno.build.os !== "win") { + if (Deno.build.os !== "windows") { assertEquals(pathInfo.mode! & 0o777, 0o700 & ~Deno.umask()); } } @@ -82,7 +82,7 @@ unitTest( async function makeTempDirMode(): Promise { const path = await Deno.makeTempDir(); const pathInfo = Deno.statSync(path); - if (Deno.build.os !== "win") { + if (Deno.build.os !== "windows") { assertEquals(pathInfo.mode! & 0o777, 0o700 & ~Deno.umask()); } } @@ -119,7 +119,7 @@ unitTest( function makeTempFileSyncMode(): void { const path = Deno.makeTempFileSync(); const pathInfo = Deno.statSync(path); - if (Deno.build.os !== "win") { + if (Deno.build.os !== "windows") { assertEquals(pathInfo.mode! & 0o777, 0o600 & ~Deno.umask()); } } @@ -171,7 +171,7 @@ unitTest( async function makeTempFileMode(): Promise { const path = await Deno.makeTempFile(); const pathInfo = Deno.statSync(path); - if (Deno.build.os !== "win") { + if (Deno.build.os !== "windows") { assertEquals(pathInfo.mode! & 0o777, 0o600 & ~Deno.umask()); } } diff --git a/cli/js/tests/mkdir_test.ts b/cli/js/tests/mkdir_test.ts index 20120f6b3dd93f..258a639b0a04d5 100644 --- a/cli/js/tests/mkdir_test.ts +++ b/cli/js/tests/mkdir_test.ts @@ -4,7 +4,7 @@ import { unitTest, assert, assertEquals, assertThrows } from "./test_util.ts"; function assertDirectory(path: string, mode?: number): void { const info = Deno.lstatSync(path); assert(info.isDirectory); - if (Deno.build.os !== "win" && mode !== undefined) { + if (Deno.build.os !== "windows" && mode !== undefined) { assertEquals(info.mode! & 0o777, mode & ~Deno.umask()); } } @@ -178,7 +178,7 @@ unitTest( Deno.mkdirSync(file, { recursive: true }); }, Deno.errors.AlreadyExists); - if (Deno.build.os !== "win") { + if (Deno.build.os !== "windows") { const fileLink = testDir + "/fileLink"; const dirLink = testDir + "/dirLink"; const danglingLink = testDir + "/danglingLink"; diff --git a/cli/js/tests/net_test.ts b/cli/js/tests/net_test.ts index 6eb0f0dc6f7c45..c8c9a893a2c174 100644 --- a/cli/js/tests/net_test.ts +++ b/cli/js/tests/net_test.ts @@ -18,7 +18,7 @@ unitTest( { perms: { net: true }, // TODO: - ignore: Deno.build.os === "win", + ignore: Deno.build.os === "windows", }, function netUdpListenClose(): void { const socket = Deno.listen({ @@ -34,7 +34,7 @@ unitTest( ); unitTest( - { ignore: Deno.build.os === "win", perms: { read: true, write: true } }, + { ignore: Deno.build.os === "windows", perms: { read: true, write: true } }, function netUnixListenClose(): void { const filePath = Deno.makeTempFileSync(); const socket = Deno.listen({ @@ -48,7 +48,7 @@ unitTest( ); unitTest( - { ignore: Deno.build.os === "win", perms: { read: true, write: true } }, + { ignore: Deno.build.os === "windows", perms: { read: true, write: true } }, function netUnixPacketListenClose(): void { const filePath = Deno.makeTempFileSync(); const socket = Deno.listen({ @@ -82,7 +82,7 @@ unitTest( ); unitTest( - { ignore: Deno.build.os === "win", perms: { read: true, write: true } }, + { ignore: Deno.build.os === "windows", perms: { read: true, write: true } }, async function netUnixCloseWhileAccept(): Promise { const filePath = await Deno.makeTempFile(); const listener = Deno.listen({ @@ -189,7 +189,7 @@ unitTest({ perms: { net: true } }, async function netTcpDialListen(): Promise< }); unitTest( - { ignore: Deno.build.os === "win", perms: { read: true, write: true } }, + { ignore: Deno.build.os === "windows", perms: { read: true, write: true } }, async function netUnixDialListen(): Promise { const filePath = await Deno.makeTempFile(); const listener = Deno.listen({ address: filePath, transport: "unix" }); @@ -225,7 +225,7 @@ unitTest( ); unitTest( - { ignore: Deno.build.os === "win", perms: { net: true } }, + { ignore: Deno.build.os === "windows", perms: { net: true } }, async function netUdpSendReceive(): Promise { const alice = Deno.listen({ port: 4500, transport: "udp" }); assert(alice.addr.transport === "udp"); @@ -253,7 +253,7 @@ unitTest( ); unitTest( - { ignore: Deno.build.os === "win", perms: { read: true, write: true } }, + { ignore: Deno.build.os === "windows", perms: { read: true, write: true } }, async function netUnixPacketSendReceive(): Promise { const filePath = await Deno.makeTempFile(); const alice = Deno.listen({ address: filePath, transport: "unixpacket" }); @@ -293,7 +293,7 @@ unitTest( ); unitTest( - { ignore: Deno.build.os === "win", perms: { net: true } }, + { ignore: Deno.build.os === "windows", perms: { net: true } }, async function netUdpListenCloseWhileIterating(): Promise { const socket = Deno.listen({ port: 8000, transport: "udp" }); const nextWhileClosing = socket[Symbol.asyncIterator]().next(); @@ -306,7 +306,7 @@ unitTest( ); unitTest( - { ignore: Deno.build.os === "win", perms: { read: true, write: true } }, + { ignore: Deno.build.os === "windows", perms: { read: true, write: true } }, async function netUnixListenCloseWhileIterating(): Promise { const filePath = Deno.makeTempFileSync(); const socket = Deno.listen({ address: filePath, transport: "unix" }); @@ -320,7 +320,7 @@ unitTest( ); unitTest( - { ignore: Deno.build.os === "win", perms: { read: true, write: true } }, + { ignore: Deno.build.os === "windows", perms: { read: true, write: true } }, async function netUnixPacketListenCloseWhileIterating(): Promise { const filePath = Deno.makeTempFileSync(); const socket = Deno.listen({ address: filePath, transport: "unixpacket" }); diff --git a/cli/js/tests/os_test.ts b/cli/js/tests/os_test.ts index 423cded501dab8..93a6d879729521 100644 --- a/cli/js/tests/os_test.ts +++ b/cli/js/tests/os_test.ts @@ -50,7 +50,7 @@ unitTest(function envPermissionDenied2(): void { // case-insensitive. Case normalization needs be done using the collation // that Windows uses, rather than naively using String.toLowerCase(). unitTest( - { ignore: Deno.build.os !== "win", perms: { env: true, run: true } }, + { ignore: Deno.build.os !== "windows", perms: { env: true, run: true } }, async function envCaseInsensitive() { // Utility function that runs a Deno subprocess with the environment // specified in `inputEnv`. The subprocess reads the environment variables diff --git a/cli/js/tests/process_test.ts b/cli/js/tests/process_test.ts index 1bcdf26da84bdb..88c35b20df8fd9 100644 --- a/cli/js/tests/process_test.ts +++ b/cli/js/tests/process_test.ts @@ -49,7 +49,7 @@ unitTest( unitTest( { // No signals on windows. - ignore: Deno.build.os === "win", + ignore: Deno.build.os === "windows", perms: { run: true }, }, async function runCommandFailedWithSignal(): Promise { @@ -326,7 +326,7 @@ unitTest(function signalNumbers(): void { }); // Ignore signal tests on windows for now... -if (Deno.build.os !== "win") { +if (Deno.build.os !== "windows") { unitTest(function killPermissions(): void { let caughtError = false; try { diff --git a/cli/js/tests/read_link_test.ts b/cli/js/tests/read_link_test.ts index 156b31070d860b..6e8c29a613fa78 100644 --- a/cli/js/tests/read_link_test.ts +++ b/cli/js/tests/read_link_test.ts @@ -10,7 +10,7 @@ unitTest( Deno.mkdirSync(target); // TODO Add test for Windows once symlink is implemented for Windows. // See https://github.com/denoland/deno/issues/815. - if (Deno.build.os !== "win") { + if (Deno.build.os !== "windows") { Deno.symlinkSync(target, symlink); const targetPath = Deno.readlinkSync(symlink); assertEquals(targetPath, target); @@ -51,7 +51,7 @@ unitTest( Deno.mkdirSync(target); // TODO Add test for Windows once symlink is implemented for Windows. // See https://github.com/denoland/deno/issues/815. - if (Deno.build.os !== "win") { + if (Deno.build.os !== "windows") { Deno.symlinkSync(target, symlink); const targetPath = await Deno.readlink(symlink); assertEquals(targetPath, target); diff --git a/cli/js/tests/realpath_test.ts b/cli/js/tests/realpath_test.ts index 7725a3aa84de33..d7609436626260 100644 --- a/cli/js/tests/realpath_test.ts +++ b/cli/js/tests/realpath_test.ts @@ -4,7 +4,7 @@ import { unitTest, assert } from "./test_util.ts"; unitTest({ perms: { read: true } }, function realpathSyncSuccess(): void { const incompletePath = "cli/tests/fixture.json"; const realPath = Deno.realpathSync(incompletePath); - if (Deno.build.os !== "win") { + if (Deno.build.os !== "windows") { assert(realPath.startsWith("/")); } else { assert(/^[A-Z]/.test(realPath)); @@ -14,7 +14,7 @@ unitTest({ perms: { read: true } }, function realpathSyncSuccess(): void { unitTest( { - ignore: Deno.build.os === "win", + ignore: Deno.build.os === "windows", perms: { read: true, write: true }, }, function realpathSyncSymlink(): void { @@ -56,7 +56,7 @@ unitTest({ perms: { read: true } }, async function realpathSuccess(): Promise< > { const incompletePath = "cli/tests/fixture.json"; const realPath = await Deno.realpath(incompletePath); - if (Deno.build.os !== "win") { + if (Deno.build.os !== "windows") { assert(realPath.startsWith("/")); } else { assert(/^[A-Z]/.test(realPath)); @@ -66,7 +66,7 @@ unitTest({ perms: { read: true } }, async function realpathSuccess(): Promise< unitTest( { - ignore: Deno.build.os === "win", + ignore: Deno.build.os === "windows", perms: { read: true, write: true }, }, async function realpathSymlink(): Promise { diff --git a/cli/js/tests/remove_test.ts b/cli/js/tests/remove_test.ts index b6f8aa320860ac..4c0bb6768e6954 100644 --- a/cli/js/tests/remove_test.ts +++ b/cli/js/tests/remove_test.ts @@ -90,7 +90,7 @@ unitTest( } catch (err) { errOnWindows = err; } - if (Deno.build.os === "win") { + if (Deno.build.os === "windows") { assertEquals(errOnWindows.message, "not implemented"); } else { const pathInfo = Deno.lstatSync(danglingSymlinkPath); @@ -123,7 +123,7 @@ unitTest( } catch (err) { errOnWindows = err; } - if (Deno.build.os === "win") { + if (Deno.build.os === "windows") { assertEquals(errOnWindows.message, "not implemented"); } else { const symlinkPathInfo = Deno.statSync(validSymlinkPath); @@ -326,7 +326,7 @@ unitTest( } catch (e) { errOnWindows = e; } - if (Deno.build.os === "win") { + if (Deno.build.os === "windows") { assertEquals(errOnWindows.message, "not implemented"); } else { const pathInfo = Deno.lstatSync(danglingSymlinkPath); @@ -359,7 +359,7 @@ unitTest( } catch (e) { errOnWindows = e; } - if (Deno.build.os === "win") { + if (Deno.build.os === "windows") { assertEquals(errOnWindows.message, "not implemented"); } else { const symlinkPathInfo = Deno.statSync(validSymlinkPath); diff --git a/cli/js/tests/rename_test.ts b/cli/js/tests/rename_test.ts index cbb3a55ce546ec..b4047f9062134c 100644 --- a/cli/js/tests/rename_test.ts +++ b/cli/js/tests/rename_test.ts @@ -22,7 +22,7 @@ function assertFile(path: string): void { function assertDirectory(path: string, mode?: number): void { const info = Deno.lstatSync(path); assert(info.isDirectory); - if (Deno.build.os !== "win" && mode !== undefined) { + if (Deno.build.os !== "windows" && mode !== undefined) { assertEquals(info.mode! & 0o777, mode & ~Deno.umask()); } } @@ -98,7 +98,7 @@ function writeFileString(filename: string, s: string): void { } unitTest( - { ignore: Deno.build.os === "win", perms: { read: true, write: true } }, + { ignore: Deno.build.os === "windows", perms: { read: true, write: true } }, function renameSyncErrorsUnix(): void { const testDir = Deno.makeTempDirSync(); const oldfile = testDir + "/oldfile"; @@ -173,7 +173,7 @@ unitTest( ); unitTest( - { ignore: Deno.build.os !== "win", perms: { read: true, write: true } }, + { ignore: Deno.build.os !== "windows", perms: { read: true, write: true } }, function renameSyncErrorsWin(): void { const testDir = Deno.makeTempDirSync(); const oldfile = testDir + "/oldfile"; diff --git a/cli/js/tests/signal_test.ts b/cli/js/tests/signal_test.ts index c2b4f878b7e83f..2f117f8d10539c 100644 --- a/cli/js/tests/signal_test.ts +++ b/cli/js/tests/signal_test.ts @@ -14,7 +14,7 @@ function defer(n: number): Promise { } unitTest( - { ignore: Deno.build.os !== "win" }, + { ignore: Deno.build.os !== "windows" }, function signalsNotImplemented(): void { assertThrows( () => { @@ -104,7 +104,7 @@ unitTest( ); unitTest( - { ignore: Deno.build.os === "win", perms: { run: true, net: true } }, + { ignore: Deno.build.os === "windows", perms: { run: true, net: true } }, async function signalStreamTest(): Promise { const resolvable = createResolvable(); // This prevents the program from exiting. @@ -135,7 +135,7 @@ unitTest( ); unitTest( - { ignore: Deno.build.os === "win", perms: { run: true } }, + { ignore: Deno.build.os === "windows", perms: { run: true } }, async function signalPromiseTest(): Promise { const resolvable = createResolvable(); // This prevents the program from exiting. @@ -155,7 +155,7 @@ unitTest( ); unitTest( - { ignore: Deno.build.os === "win", perms: { run: true } }, + { ignore: Deno.build.os === "windows", perms: { run: true } }, function signalShorthandsTest(): void { let s: Deno.SignalStream; s = Deno.signals.alarm(); // for SIGALRM diff --git a/cli/js/tests/stat_test.ts b/cli/js/tests/stat_test.ts index 70ec5dc2e7caef..7eaf73d5810a64 100644 --- a/cli/js/tests/stat_test.ts +++ b/cli/js/tests/stat_test.ts @@ -193,7 +193,7 @@ unitTest({ perms: { read: true } }, async function lstatNotFound(): Promise< }); unitTest( - { ignore: Deno.build.os !== "win", perms: { read: true, write: true } }, + { ignore: Deno.build.os !== "windows", perms: { read: true, write: true } }, function statNoUnixFields(): void { const enc = new TextEncoder(); const data = enc.encode("Hello"); @@ -214,7 +214,7 @@ unitTest( ); unitTest( - { ignore: Deno.build.os === "win", perms: { read: true, write: true } }, + { ignore: Deno.build.os === "windows", perms: { read: true, write: true } }, function statUnixFields(): void { const enc = new TextEncoder(); const data = enc.encode("Hello"); diff --git a/cli/js/tests/umask_test.ts b/cli/js/tests/umask_test.ts index e381749ea16efb..bfac65d52ebe09 100644 --- a/cli/js/tests/umask_test.ts +++ b/cli/js/tests/umask_test.ts @@ -3,7 +3,7 @@ import { unitTest, assertEquals } from "./test_util.ts"; unitTest( { - ignore: Deno.build.os === "win", + ignore: Deno.build.os === "windows", }, function umaskSuccess(): void { const prevMask = Deno.umask(0o020); diff --git a/cli/js/tests/write_file_test.ts b/cli/js/tests/write_file_test.ts index c06c5b33017723..80f711dbc74107 100644 --- a/cli/js/tests/write_file_test.ts +++ b/cli/js/tests/write_file_test.ts @@ -48,7 +48,7 @@ unitTest({ perms: { write: false } }, function writeFileSyncPerm(): void { unitTest( { perms: { read: true, write: true } }, function writeFileSyncUpdateMode(): void { - if (Deno.build.os !== "win") { + if (Deno.build.os !== "windows") { const enc = new TextEncoder(); const data = enc.encode("Hello"); const filename = Deno.makeTempDirSync() + "/test.txt"; @@ -164,7 +164,7 @@ unitTest( unitTest( { perms: { read: true, write: true } }, async function writeFileUpdateMode(): Promise { - if (Deno.build.os !== "win") { + if (Deno.build.os !== "windows") { const enc = new TextEncoder(); const data = enc.encode("Hello"); const filename = Deno.makeTempDirSync() + "/test.txt"; From b9c43addb50650b88ebf8aac36afbdfabb930fe1 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Mon, 27 Apr 2020 21:31:53 -0400 Subject: [PATCH 07/14] fmt --- cli/js/build.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/js/build.ts b/cli/js/build.ts index e41cbf22fce173..676e056eb9aee5 100644 --- a/cli/js/build.ts +++ b/cli/js/build.ts @@ -5,7 +5,7 @@ export const build = { arch: "unknown", os: "unknown", vendor: "unknown", - env: undefined as (string | undefined) + env: undefined as string | undefined, }; export function setBuildInfo(target: string): void { From 0e0ae58a65008bb5da1298394b83cbb8e4fbe5a8 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Mon, 27 Apr 2020 21:40:09 -0400 Subject: [PATCH 08/14] fix --- cli/js/signals.ts | 2 +- cli/js/tests/build_test.ts | 4 ++-- cli/js/tests/dir_test.ts | 2 +- cli/js/tests/process_test.ts | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cli/js/signals.ts b/cli/js/signals.ts index 599201df579881..2e29528e1741a6 100644 --- a/cli/js/signals.ts +++ b/cli/js/signals.ts @@ -75,7 +75,7 @@ enum MacOSSignal { export const Signal: { [key: string]: number } = {}; export function setSignals(): void { - if (build.os === "mac") { + if (build.os === "darwin") { Object.assign(Signal, MacOSSignal); } else { Object.assign(Signal, LinuxSignal); diff --git a/cli/js/tests/build_test.ts b/cli/js/tests/build_test.ts index 50c7b519ce3d49..987ed8d3922b27 100644 --- a/cli/js/tests/build_test.ts +++ b/cli/js/tests/build_test.ts @@ -5,6 +5,6 @@ unitTest(function buildInfo(): void { // Deno.build is injected by rollup at compile time. Here // we check it has been properly transformed. const { arch, os } = Deno.build; - assert(arch === "x64"); - assert(os === "mac" || os === "win" || os === "linux"); + assert(arch.length > 0); + assert(os === "darwin" || os === "windows" || os === "linux"); }); diff --git a/cli/js/tests/dir_test.ts b/cli/js/tests/dir_test.ts index 75184587bb679c..1b6c75ff25401b 100644 --- a/cli/js/tests/dir_test.ts +++ b/cli/js/tests/dir_test.ts @@ -10,7 +10,7 @@ unitTest({ perms: { write: true } }, function dirCwdChdirSuccess(): void { const path = Deno.makeTempDirSync(); Deno.chdir(path); const current = Deno.cwd(); - if (Deno.build.os === "mac") { + if (Deno.build.os === "darwin") { assertEquals(current, "/private" + path); } else { assertEquals(current, path); diff --git a/cli/js/tests/process_test.ts b/cli/js/tests/process_test.ts index 88c35b20df8fd9..f0615193bb5663 100644 --- a/cli/js/tests/process_test.ts +++ b/cli/js/tests/process_test.ts @@ -318,7 +318,7 @@ unitTest({ perms: { run: true } }, async function runClose(): Promise { }); unitTest(function signalNumbers(): void { - if (Deno.build.os === "mac") { + if (Deno.build.os === "darwin") { assertEquals(Deno.Signal.SIGSTOP, 17); } else if (Deno.build.os === "linux") { assertEquals(Deno.Signal.SIGSTOP, 19); From 8b2c0f97d5773f7340ff26860905f3bb3afbe170 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Mon, 27 Apr 2020 21:43:02 -0400 Subject: [PATCH 09/14] fix --- cli/js/tests/mkdir_test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/js/tests/mkdir_test.ts b/cli/js/tests/mkdir_test.ts index 258a639b0a04d5..68755ef4d1f056 100644 --- a/cli/js/tests/mkdir_test.ts +++ b/cli/js/tests/mkdir_test.ts @@ -126,7 +126,7 @@ unitTest( Deno.mkdirSync(path, { recursive: true }); Deno.mkdirSync(path, { recursive: true, mode: 0o731 }); assertDirectory(path, 0o737); - if (Deno.build.os != "win") { + if (Deno.build.os !== "windows") { const pathLink = path + "Link"; Deno.symlinkSync(path, pathLink); Deno.mkdirSync(pathLink, { recursive: true }); @@ -144,7 +144,7 @@ unitTest( await Deno.mkdir(path, { recursive: true }); await Deno.mkdir(path, { recursive: true, mode: 0o731 }); assertDirectory(path, 0o737); - if (Deno.build.os != "win") { + if (Deno.build.os !== "windows") { const pathLink = path + "Link"; Deno.symlinkSync(path, pathLink); await Deno.mkdir(pathLink, { recursive: true }); From 781042abcbf28e636ae2446b08b4ea460df0f104 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Mon, 27 Apr 2020 23:12:43 -0400 Subject: [PATCH 10/14] fix --- std/examples/chat/server_test.ts | 2 +- std/fs/walk_test.ts | 6 ++---- std/node/_fs/_fs_chmod_test.ts | 4 ++-- std/node/_fs/_fs_readlink_test.ts | 10 +++++----- std/node/os.ts | 4 ++-- std/node/process.ts | 5 +---- 6 files changed, 13 insertions(+), 18 deletions(-) diff --git a/std/examples/chat/server_test.ts b/std/examples/chat/server_test.ts index e1b1c0e1276f38..47e17314ba80ca 100644 --- a/std/examples/chat/server_test.ts +++ b/std/examples/chat/server_test.ts @@ -27,7 +27,7 @@ async function startServer(): Promise { } // TODO: https://github.com/denoland/deno/issues/4108 -const ignore = build.os == "win"; +const ignore = build.os == "windows"; test({ ignore, diff --git a/std/fs/walk_test.ts b/std/fs/walk_test.ts index b054db4cf0dbc8..ea9a33773bb26d 100644 --- a/std/fs/walk_test.ts +++ b/std/fs/walk_test.ts @@ -3,8 +3,6 @@ const { remove } = Deno; import { walk, walkSync, WalkOptions, WalkEntry } from "./walk.ts"; import { assert, assertEquals, assertThrowsAsync } from "../testing/asserts.ts"; -const isWindows = Deno.build.os == "win"; - export function testWalk( setup: (arg0: string) => void | Promise, t: () => void | Promise, @@ -254,13 +252,13 @@ testWalk( try { await symlink(d + "/b", d + "/a/bb"); } catch (err) { - assert(isWindows); + assert(Deno.build.os == "windows"); assertEquals(err.message, "Not implemented"); } }, async function symlink(): Promise { // symlink is not yet implemented on Windows. - if (isWindows) { + if (Deno.build.os == "windows") { return; } diff --git a/std/node/_fs/_fs_chmod_test.ts b/std/node/_fs/_fs_chmod_test.ts index a3d814b51d3b1e..e43f097881d6af 100644 --- a/std/node/_fs/_fs_chmod_test.ts +++ b/std/node/_fs/_fs_chmod_test.ts @@ -5,7 +5,7 @@ import { chmod, chmodSync } from "./_fs_chmod.ts"; test({ name: "ASYNC: Permissions are changed (non-Windows)", - ignore: Deno.build.os === "win", + ignore: Deno.build.os === "windows", async fn() { const tempFile: string = await Deno.makeTempFile(); const originalFileMode: number | null = (await Deno.lstat(tempFile)).mode; @@ -31,7 +31,7 @@ test({ test({ name: "SYNC: Permissions are changed (non-Windows)", - ignore: Deno.build.os === "win", + ignore: Deno.build.os === "windows", fn() { const tempFile: string = Deno.makeTempFileSync(); const originalFileMode: number | null = Deno.lstatSync(tempFile).mode; diff --git a/std/node/_fs/_fs_readlink_test.ts b/std/node/_fs/_fs_readlink_test.ts index 151d3f78269c8b..4b2165f8a8227f 100644 --- a/std/node/_fs/_fs_readlink_test.ts +++ b/std/node/_fs/_fs_readlink_test.ts @@ -6,13 +6,13 @@ const testDir = Deno.makeTempDirSync(); const oldname = testDir + "/oldname"; const newname = testDir + "/newname"; -if (Deno.build.os !== "win") { +if (Deno.build.os !== "windows") { Deno.symlinkSync(oldname, newname); } test({ name: "readlinkSuccess", - ignore: Deno.build.os === "win", + ignore: Deno.build.os === "windows", async fn() { const data = await new Promise((res, rej) => { readlink(newname, (err, data) => { @@ -30,7 +30,7 @@ test({ test({ name: "readlinkEncodeBufferSuccess", - ignore: Deno.build.os === "win", + ignore: Deno.build.os === "windows", async fn() { const data = await new Promise((res, rej) => { readlink(newname, { encoding: "buffer" }, (err, data) => { @@ -48,7 +48,7 @@ test({ test({ name: "readlinkSyncSuccess", - ignore: Deno.build.os === "win", + ignore: Deno.build.os === "windows", fn() { const data = readlinkSync(newname); assertEquals(typeof data, "string"); @@ -58,7 +58,7 @@ test({ test({ name: "readlinkEncodeBufferSuccess", - ignore: Deno.build.os === "win", + ignore: Deno.build.os === "windows", fn() { const data = readlinkSync(newname, { encoding: "buffer" }); assert(data instanceof Uint8Array); diff --git a/std/node/os.ts b/std/node/os.ts index 7c61e910b1f793..27b054f4def9a9 100644 --- a/std/node/os.ts +++ b/std/node/os.ts @@ -146,7 +146,7 @@ export function hostname(): string { /** Returns an array containing the 1, 5, and 15 minute load averages */ export function loadavg(): number[] { - if (Deno.build.os == "win") { + if (Deno.build.os === "windows") { return [0, 0, 0]; } return Deno.loadavg(); @@ -222,4 +222,4 @@ export const constants = { }, }; -export const EOL = Deno.build.os == "win" ? fsEOL.CRLF : fsEOL.LF; +export const EOL = Deno.build.os == "windows" ? fsEOL.CRLF : fsEOL.LF; diff --git a/std/node/process.ts b/std/node/process.ts index 89d383e8ef1fcb..a5566a7eac6597 100644 --- a/std/node/process.ts +++ b/std/node/process.ts @@ -7,10 +7,7 @@ const versions = { ...Deno.version, }; -const osToPlatform = (os: Deno.OperatingSystem): string => - os === "win" ? "win32" : os === "mac" ? "darwin" : os; - -const platform = osToPlatform(Deno.build.os); +const platform = Deno.build.os === "windows" ? "win32" : os; const { arch } = Deno.build; From 23d5512c09f0c17fbd51408918c4ca8e64d2de76 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Mon, 27 Apr 2020 23:13:42 -0400 Subject: [PATCH 11/14] fix --- std/node/_fs/_fs_chown_test.ts | 5 +++-- std/node/process.ts | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/std/node/_fs/_fs_chown_test.ts b/std/node/_fs/_fs_chown_test.ts index fd31a8c62e77c5..1c1393ac4a7786 100644 --- a/std/node/_fs/_fs_chown_test.ts +++ b/std/node/_fs/_fs_chown_test.ts @@ -3,8 +3,9 @@ const { test } = Deno; import { fail, assertEquals } from "../../testing/asserts.ts"; import { chown, chownSync } from "./_fs_chown.ts"; -//chown is difficult to test. Best we can do is set the existing user id/group id again -const ignore = Deno.build.os == "win"; +// chown is difficult to test. Best we can do is set the existing user id/group +// id again +const ignore = Deno.build.os == "windows"; test({ ignore, diff --git a/std/node/process.ts b/std/node/process.ts index a5566a7eac6597..310a7e81404266 100644 --- a/std/node/process.ts +++ b/std/node/process.ts @@ -7,7 +7,7 @@ const versions = { ...Deno.version, }; -const platform = Deno.build.os === "windows" ? "win32" : os; +const platform = Deno.build.os === "windows" ? "win32" : Deno.build.os; const { arch } = Deno.build; From e7e5d0caef5bb2f2fb590b012fcc964d2e10ab98 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Tue, 28 Apr 2020 10:18:36 -0400 Subject: [PATCH 12/14] fix --- cli/js/ops/fs/stat.ts | 2 +- cli/js/ops/runtime.ts | 5 ---- cli/js/tests/os_test.ts | 62 ++++++++++++++++++++--------------------- 3 files changed, 32 insertions(+), 37 deletions(-) diff --git a/cli/js/ops/fs/stat.ts b/cli/js/ops/fs/stat.ts index 7f28614d2419f6..c3563a8c4c38f8 100644 --- a/cli/js/ops/fs/stat.ts +++ b/cli/js/ops/fs/stat.ts @@ -45,7 +45,7 @@ export interface StatResponse { // @internal export function parseFileInfo(response: StatResponse): FileInfo { - const isUnix = build.os === "mac" || build.os === "linux"; + const isUnix = build.os === "darwin" || build.os === "linux"; return { isFile: response.isFile, isDirectory: response.isDirectory, diff --git a/cli/js/ops/runtime.ts b/cli/js/ops/runtime.ts index ec5873d3198d63..247f0576df8242 100644 --- a/cli/js/ops/runtime.ts +++ b/cli/js/ops/runtime.ts @@ -2,11 +2,6 @@ import { sendSync } from "./dispatch_json.ts"; -// TODO(bartlomieju): these two types are duplicated -// in `cli/js/build.ts` - deduplicate -export type OperatingSystem = "mac" | "win" | "linux"; -export type Arch = "x64" | "arm64"; - export interface Start { cwd: string; pid: number; diff --git a/cli/js/tests/os_test.ts b/cli/js/tests/os_test.ts index 93a6d879729521..58dcd1bc543bec 100644 --- a/cli/js/tests/os_test.ts +++ b/cli/js/tests/os_test.ts @@ -116,7 +116,7 @@ unitTest(function osPid(): void { }); unitTest({ perms: { env: true } }, function getDir(): void { - type supportOS = "mac" | "win" | "linux"; + type supportOS = "darwin" | "windows" | "linux"; interface Runtime { os: supportOS; @@ -132,120 +132,120 @@ unitTest({ perms: { env: true } }, function getDir(): void { { kind: "config", runtime: [ - { os: "mac", shouldHaveValue: true }, - { os: "win", shouldHaveValue: true }, + { os: "darwin", shouldHaveValue: true }, + { os: "windows", shouldHaveValue: true }, { os: "linux", shouldHaveValue: true }, ], }, { kind: "cache", runtime: [ - { os: "mac", shouldHaveValue: true }, - { os: "win", shouldHaveValue: true }, + { os: "darwin", shouldHaveValue: true }, + { os: "windows", shouldHaveValue: true }, { os: "linux", shouldHaveValue: true }, ], }, { kind: "executable", runtime: [ - { os: "mac", shouldHaveValue: false }, - { os: "win", shouldHaveValue: false }, + { os: "darwin", shouldHaveValue: false }, + { os: "windows", shouldHaveValue: false }, { os: "linux", shouldHaveValue: true }, ], }, { kind: "data", runtime: [ - { os: "mac", shouldHaveValue: true }, - { os: "win", shouldHaveValue: true }, + { os: "darwin", shouldHaveValue: true }, + { os: "windows", shouldHaveValue: true }, { os: "linux", shouldHaveValue: true }, ], }, { kind: "data_local", runtime: [ - { os: "mac", shouldHaveValue: true }, - { os: "win", shouldHaveValue: true }, + { os: "darwin", shouldHaveValue: true }, + { os: "windows", shouldHaveValue: true }, { os: "linux", shouldHaveValue: true }, ], }, { kind: "audio", runtime: [ - { os: "mac", shouldHaveValue: true }, - { os: "win", shouldHaveValue: true }, + { os: "darwin", shouldHaveValue: true }, + { os: "windows", shouldHaveValue: true }, { os: "linux", shouldHaveValue: false }, ], }, { kind: "desktop", runtime: [ - { os: "mac", shouldHaveValue: true }, - { os: "win", shouldHaveValue: true }, + { os: "darwin", shouldHaveValue: true }, + { os: "windows", shouldHaveValue: true }, { os: "linux", shouldHaveValue: false }, ], }, { kind: "document", runtime: [ - { os: "mac", shouldHaveValue: true }, - { os: "win", shouldHaveValue: true }, + { os: "darwin", shouldHaveValue: true }, + { os: "windows", shouldHaveValue: true }, { os: "linux", shouldHaveValue: false }, ], }, { kind: "download", runtime: [ - { os: "mac", shouldHaveValue: true }, - { os: "win", shouldHaveValue: true }, + { os: "darwin", shouldHaveValue: true }, + { os: "windows", shouldHaveValue: true }, { os: "linux", shouldHaveValue: false }, ], }, { kind: "font", runtime: [ - { os: "mac", shouldHaveValue: true }, - { os: "win", shouldHaveValue: false }, + { os: "darwin", shouldHaveValue: true }, + { os: "windows", shouldHaveValue: false }, { os: "linux", shouldHaveValue: true }, ], }, { kind: "picture", runtime: [ - { os: "mac", shouldHaveValue: true }, - { os: "win", shouldHaveValue: true }, + { os: "darwin", shouldHaveValue: true }, + { os: "windows", shouldHaveValue: true }, { os: "linux", shouldHaveValue: false }, ], }, { kind: "public", runtime: [ - { os: "mac", shouldHaveValue: true }, - { os: "win", shouldHaveValue: true }, + { os: "darwin", shouldHaveValue: true }, + { os: "windows", shouldHaveValue: true }, { os: "linux", shouldHaveValue: false }, ], }, { kind: "template", runtime: [ - { os: "mac", shouldHaveValue: false }, - { os: "win", shouldHaveValue: true }, + { os: "darwin", shouldHaveValue: false }, + { os: "windows", shouldHaveValue: true }, { os: "linux", shouldHaveValue: false }, ], }, { kind: "tmp", runtime: [ - { os: "mac", shouldHaveValue: true }, - { os: "win", shouldHaveValue: true }, + { os: "darwin", shouldHaveValue: true }, + { os: "windows", shouldHaveValue: true }, { os: "linux", shouldHaveValue: true }, ], }, { kind: "video", runtime: [ - { os: "mac", shouldHaveValue: true }, - { os: "win", shouldHaveValue: true }, + { os: "darwin", shouldHaveValue: true }, + { os: "windows", shouldHaveValue: true }, { os: "linux", shouldHaveValue: false }, ], }, From 9a2c0be75e8d8b11cb270c55a8c87a3a9bc7e536 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Tue, 28 Apr 2020 10:42:54 -0400 Subject: [PATCH 13/14] fix --- cli/js/ops/fs/symlink.ts | 4 ++-- cli/js/tests/README.md | 2 +- cli/js/tests/dir_test.ts | 2 +- cli/js/tests/symlink_test.ts | 4 ++-- cli/js/web/blob.ts | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cli/js/ops/fs/symlink.ts b/cli/js/ops/fs/symlink.ts index 4f9c85f7b02d7e..64074ec2d962f7 100644 --- a/cli/js/ops/fs/symlink.ts +++ b/cli/js/ops/fs/symlink.ts @@ -8,7 +8,7 @@ export function symlinkSync( newpath: string, type?: string ): void { - if (build.os === "win" && type) { + if (build.os === "windows" && type) { return util.notImplemented(); } sendSync("op_symlink", { oldpath, newpath }); @@ -19,7 +19,7 @@ export async function symlink( newpath: string, type?: string ): Promise { - if (build.os === "win" && type) { + if (build.os === "windows" && type) { return util.notImplemented(); } await sendAsync("op_symlink", { oldpath, newpath }); diff --git a/cli/js/tests/README.md b/cli/js/tests/README.md index ea8216d91d85a6..e48b03012b2bac 100644 --- a/cli/js/tests/README.md +++ b/cli/js/tests/README.md @@ -17,7 +17,7 @@ unitTest(function simpleTestFn(): void { }); unitTest({ - ignore: Deno.build.os === "win", + ignore: Deno.build.os === "windows", perms: { read: true, write: true }, }, function complexTestFn(): void { diff --git a/cli/js/tests/dir_test.ts b/cli/js/tests/dir_test.ts index 1b6c75ff25401b..09236fa22f1a07 100644 --- a/cli/js/tests/dir_test.ts +++ b/cli/js/tests/dir_test.ts @@ -20,7 +20,7 @@ unitTest({ perms: { write: true } }, function dirCwdChdirSuccess(): void { unitTest({ perms: { write: true } }, function dirCwdError(): void { // excluding windows since it throws resource busy, while removeSync - if (["linux", "mac"].includes(Deno.build.os)) { + if (["linux", "darwin"].includes(Deno.build.os)) { const initialdir = Deno.cwd(); const path = Deno.makeTempDirSync(); Deno.chdir(path); diff --git a/cli/js/tests/symlink_test.ts b/cli/js/tests/symlink_test.ts index 0dde4fbadc8cc1..681ace1db28156 100644 --- a/cli/js/tests/symlink_test.ts +++ b/cli/js/tests/symlink_test.ts @@ -16,7 +16,7 @@ unitTest( errOnWindows = e; } if (errOnWindows) { - assertEquals(Deno.build.os, "win"); + assertEquals(Deno.build.os, "windows"); assertEquals(errOnWindows.message, "not implemented"); } else { const newNameInfoLStat = Deno.lstatSync(newname); @@ -53,7 +53,7 @@ unitTest( err = e; } if (err) { - assertEquals(Deno.build.os, "win"); + assertEquals(Deno.build.os, "windows"); // from cli/js/util.ts:notImplemented assertEquals(err.message, "not implemented"); } diff --git a/cli/js/web/blob.ts b/cli/js/web/blob.ts index d30bb7e381e255..546ea7e8200382 100644 --- a/cli/js/web/blob.ts +++ b/cli/js/web/blob.ts @@ -13,7 +13,7 @@ export function containsOnlyASCII(str: string): boolean { } function convertLineEndingsToNative(s: string): string { - const nativeLineEnd = build.os == "win" ? "\r\n" : "\n"; + const nativeLineEnd = build.os == "windows" ? "\r\n" : "\n"; let position = 0; From bb4058f0cf5aed4bc244cd16a129b5de7aa77d10 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Tue, 28 Apr 2020 11:21:18 -0400 Subject: [PATCH 14/14] fix --- test_plugin/tests/test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test_plugin/tests/test.js b/test_plugin/tests/test.js index 3661e107849d47..8d6146902d5509 100644 --- a/test_plugin/tests/test.js +++ b/test_plugin/tests/test.js @@ -3,11 +3,11 @@ const filenameBase = "test_plugin"; let filenameSuffix = ".so"; let filenamePrefix = "lib"; -if (Deno.build.os === "win") { +if (Deno.build.os === "windows") { filenameSuffix = ".dll"; filenamePrefix = ""; } -if (Deno.build.os === "mac") { +if (Deno.build.os === "darwin") { filenameSuffix = ".dylib"; }