1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-24 08:09:08 -05:00

BREAKING: Use LLVM target triple for Deno.build (#4948)

Deno.build.os values have changed to correspond to standard LLVM target triples
"win" -> "windows"
"mac" -> "darwin"
This commit is contained in:
Ryan Dahl 2020-04-28 12:35:23 -04:00 committed by GitHub
parent f7ab19b1b7
commit e0ca60e770
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
50 changed files with 165 additions and 188 deletions

View file

@ -20,6 +20,11 @@ fn main() {
deno_typescript::ts_version() deno_typescript::ts_version()
); );
println!(
"cargo:rustc-env=TARGET={}",
std::env::var("TARGET").unwrap()
);
let extern_crate_modules = include_crate_modules![deno_core]; let extern_crate_modules = include_crate_modules![deno_core];
// The generation of snapshots is slow and often unnecessary. Until we figure // The generation of snapshots is slow and often unnecessary. Until we figure

View file

@ -1,24 +1,19 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
export type OperatingSystem = "mac" | "win" | "linux"; export const build = {
target: "unknown",
export type Arch = "x64" | "arm64"; arch: "unknown",
os: "unknown",
// Do not add unsupported platforms. vendor: "unknown",
export interface BuildInfo { env: undefined as string | undefined,
arch: Arch;
os: OperatingSystem;
}
export const build: BuildInfo = {
arch: "" as Arch,
os: "" as OperatingSystem,
}; };
export function setBuildInfo(os: OperatingSystem, arch: Arch): void { export function setBuildInfo(target: string): void {
build.os = os; const [arch, vendor, os, env] = target.split("-", 4);
build.target = target;
build.arch = arch; build.arch = arch;
build.vendor = vendor;
build.os = os;
build.env = env;
Object.freeze(build); Object.freeze(build);
} }

View file

@ -8,7 +8,7 @@ export {
writeAll, writeAll,
writeAllSync, writeAllSync,
} from "./buffer.ts"; } from "./buffer.ts";
export { build, OperatingSystem, Arch } from "./build.ts"; export { build } from "./build.ts";
export { chmodSync, chmod } from "./ops/fs/chmod.ts"; export { chmodSync, chmod } from "./ops/fs/chmod.ts";
export { chownSync, chown } from "./ops/fs/chown.ts"; export { chownSync, chown } from "./ops/fs/chown.ts";
export { transpileOnly, compile, bundle } from "./compiler/api.ts"; export { transpileOnly, compile, bundle } from "./compiler/api.ts";

View file

@ -40,7 +40,7 @@ declare namespace Deno {
* *
* Deno.test({ * Deno.test({
* name: "example ignored test", * name: "example ignored test",
* ignore: Deno.build.os === "win" * ignore: Deno.build.os === "windows"
* fn(): void { * fn(): void {
* // This test is ignored only on Windows machines * // This test is ignored only on Windows machines
* }, * },
@ -2365,19 +2365,19 @@ declare namespace Deno {
*/ */
export function inspect(value: unknown, options?: InspectOptions): string; 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. */ /** 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 { interface Version {
deno: string; deno: string;

View file

@ -45,7 +45,7 @@ export interface StatResponse {
// @internal // @internal
export function parseFileInfo(response: StatResponse): FileInfo { export function parseFileInfo(response: StatResponse): FileInfo {
const isUnix = build.os === "mac" || build.os === "linux"; const isUnix = build.os === "darwin" || build.os === "linux";
return { return {
isFile: response.isFile, isFile: response.isFile,
isDirectory: response.isDirectory, isDirectory: response.isDirectory,

View file

@ -8,7 +8,7 @@ export function symlinkSync(
newpath: string, newpath: string,
type?: string type?: string
): void { ): void {
if (build.os === "win" && type) { if (build.os === "windows" && type) {
return util.notImplemented(); return util.notImplemented();
} }
sendSync("op_symlink", { oldpath, newpath }); sendSync("op_symlink", { oldpath, newpath });
@ -19,7 +19,7 @@ export async function symlink(
newpath: string, newpath: string,
type?: string type?: string
): Promise<void> { ): Promise<void> {
if (build.os === "win" && type) { if (build.os === "windows" && type) {
return util.notImplemented(); return util.notImplemented();
} }
await sendAsync("op_symlink", { oldpath, newpath }); await sendAsync("op_symlink", { oldpath, newpath });

View file

@ -4,7 +4,7 @@ import { assert } from "../util.ts";
import { build } from "../build.ts"; import { build } from "../build.ts";
export function kill(pid: number, signo: number): void { export function kill(pid: number, signo: number): void {
if (build.os === "win") { if (build.os === "windows") {
throw new Error("Not yet implemented"); throw new Error("Not yet implemented");
} }
sendSync("op_kill", { pid, signo }); sendSync("op_kill", { pid, signo });

View file

@ -2,11 +2,6 @@
import { sendSync } from "./dispatch_json.ts"; 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 { export interface Start {
cwd: string; cwd: string;
pid: number; pid: number;
@ -21,11 +16,10 @@ export interface Start {
v8Version: string; v8Version: string;
tsVersion: string; tsVersion: string;
noColor: boolean; noColor: boolean;
os: OperatingSystem; target: string;
arch: Arch;
} }
export function start(): Start { export function opStart(): Start {
return sendSync("op_start"); return sendSync("op_start");
} }

View file

@ -6,7 +6,7 @@ import * as util from "./util.ts";
import { setBuildInfo } from "./build.ts"; import { setBuildInfo } from "./build.ts";
import { setVersions } from "./version.ts"; import { setVersions } from "./version.ts";
import { setPrepareStackTrace } from "./error_stack.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"; import { handleTimerMacrotask } from "./web/timers.ts";
export let OPS_CACHE: { [name: string]: number }; 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 // 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 // are ready. The response should be a `StartRes` message containing the CLI
// args and other info. // args and other info.
const s = startOp(); const s = opStart();
setVersions(s.denoVersion, s.v8Version, s.tsVersion); setVersions(s.denoVersion, s.v8Version, s.tsVersion);
setBuildInfo(s.os, s.arch); setBuildInfo(s.target);
util.setLogDebug(s.debugFlag, source); util.setLogDebug(s.debugFlag, source);
setPrepareStackTrace(Error); setPrepareStackTrace(Error);
return s; return s;
} }

View file

@ -75,7 +75,7 @@ enum MacOSSignal {
export const Signal: { [key: string]: number } = {}; export const Signal: { [key: string]: number } = {};
export function setSignals(): void { export function setSignals(): void {
if (build.os === "mac") { if (build.os === "darwin") {
Object.assign(Signal, MacOSSignal); Object.assign(Signal, MacOSSignal);
} else { } else {
Object.assign(Signal, LinuxSignal); Object.assign(Signal, LinuxSignal);
@ -83,7 +83,7 @@ export function setSignals(): void {
} }
export function signal(signo: number): SignalStream { export function signal(signo: number): SignalStream {
if (build.os === "win") { if (build.os === "windows") {
throw new Error("not implemented!"); throw new Error("not implemented!");
} }
return new SignalStream(signo); return new SignalStream(signo);

View file

@ -17,7 +17,7 @@ unitTest(function simpleTestFn(): void {
}); });
unitTest({ unitTest({
ignore: Deno.build.os === "win", ignore: Deno.build.os === "windows",
perms: { read: true, write: true }, perms: { read: true, write: true },
}, },
function complexTestFn(): void { function complexTestFn(): void {

View file

@ -66,7 +66,7 @@ unitTest(function nativeEndLine(): void {
}; };
const blob = new Blob(["Hello\nWorld"], options); 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<void> { unitTest(async function blobText(): Promise<void> {

View file

@ -5,6 +5,6 @@ unitTest(function buildInfo(): void {
// Deno.build is injected by rollup at compile time. Here // Deno.build is injected by rollup at compile time. Here
// we check it has been properly transformed. // we check it has been properly transformed.
const { arch, os } = Deno.build; const { arch, os } = Deno.build;
assert(arch === "x64"); assert(arch.length > 0);
assert(os === "mac" || os === "win" || os === "linux"); assert(os === "darwin" || os === "windows" || os === "linux");
}); });

View file

@ -2,7 +2,7 @@
import { unitTest, assert, assertEquals } from "./test_util.ts"; import { unitTest, assert, assertEquals } from "./test_util.ts";
unitTest( unitTest(
{ ignore: Deno.build.os === "win", perms: { read: true, write: true } }, { ignore: Deno.build.os === "windows", perms: { read: true, write: true } },
function chmodSyncSuccess(): void { function chmodSyncSuccess(): void {
const enc = new TextEncoder(); const enc = new TextEncoder();
const data = enc.encode("Hello"); const data = enc.encode("Hello");
@ -21,7 +21,7 @@ unitTest(
// Check symlink when not on windows // Check symlink when not on windows
unitTest( unitTest(
{ {
ignore: Deno.build.os === "win", ignore: Deno.build.os === "windows",
perms: { read: true, write: true }, perms: { read: true, write: true },
}, },
function chmodSyncSymlinkSuccess(): void { function chmodSyncSymlinkSuccess(): void {
@ -73,7 +73,7 @@ unitTest({ perms: { write: false } }, function chmodSyncPerm(): void {
}); });
unitTest( 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<void> { async function chmodSuccess(): Promise<void> {
const enc = new TextEncoder(); const enc = new TextEncoder();
const data = enc.encode("Hello"); const data = enc.encode("Hello");
@ -93,7 +93,7 @@ unitTest(
unitTest( unitTest(
{ {
ignore: Deno.build.os === "win", ignore: Deno.build.os === "windows",
perms: { read: true, write: true }, perms: { read: true, write: true },
}, },
async function chmodSymlinkSuccess(): Promise<void> { async function chmodSymlinkSuccess(): Promise<void> {

View file

@ -2,7 +2,7 @@
import { unitTest, assertEquals, assert } from "./test_util.ts"; import { unitTest, assertEquals, assert } from "./test_util.ts";
// chown on Windows is noop for now, so ignore its testing on Windows // 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 }> { async function getUidAndGid(): Promise<{ uid: number; gid: number }> {
// get the user ID and group ID of the current process // get the user ID and group ID of the current process
const uidProc = Deno.run({ const uidProc = Deno.run({

View file

@ -10,7 +10,7 @@ unitTest({ perms: { write: true } }, function dirCwdChdirSuccess(): void {
const path = Deno.makeTempDirSync(); const path = Deno.makeTempDirSync();
Deno.chdir(path); Deno.chdir(path);
const current = Deno.cwd(); const current = Deno.cwd();
if (Deno.build.os === "mac") { if (Deno.build.os === "darwin") {
assertEquals(current, "/private" + path); assertEquals(current, "/private" + path);
} else { } else {
assertEquals(current, path); assertEquals(current, path);
@ -20,7 +20,7 @@ unitTest({ perms: { write: true } }, function dirCwdChdirSuccess(): void {
unitTest({ perms: { write: true } }, function dirCwdError(): void { unitTest({ perms: { write: true } }, function dirCwdError(): void {
// excluding windows since it throws resource busy, while removeSync // 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 initialdir = Deno.cwd();
const path = Deno.makeTempDirSync(); const path = Deno.makeTempDirSync();
Deno.chdir(path); Deno.chdir(path);

View file

@ -172,7 +172,7 @@ unitTest(
}); });
file.close(); file.close();
const pathInfo = Deno.statSync(path); const pathInfo = Deno.statSync(path);
if (Deno.build.os !== "win") { if (Deno.build.os !== "windows") {
assertEquals(pathInfo.mode! & 0o777, 0o626 & ~Deno.umask()); assertEquals(pathInfo.mode! & 0o777, 0o626 & ~Deno.umask());
} }
} }
@ -191,7 +191,7 @@ unitTest(
}); });
file.close(); file.close();
const pathInfo = Deno.statSync(path); const pathInfo = Deno.statSync(path);
if (Deno.build.os !== "win") { if (Deno.build.os !== "windows") {
assertEquals(pathInfo.mode! & 0o777, 0o626 & ~Deno.umask()); assertEquals(pathInfo.mode! & 0o777, 0o626 & ~Deno.umask());
} }
} }

View file

@ -20,7 +20,7 @@ unitTest({ perms: { read: true } }, function watchFsInvalidPath() {
Deno.watchFs("non-existant.file"); Deno.watchFs("non-existant.file");
} catch (err) { } catch (err) {
console.error(err); console.error(err);
if (Deno.build.os === "win") { if (Deno.build.os === "windows") {
assert( assert(
err.message.includes( err.message.includes(
"Input watch path is neither a file nor a directory" "Input watch path is neither a file nor a directory"

View file

@ -31,7 +31,7 @@ unitTest(
function makeTempDirSyncMode(): void { function makeTempDirSyncMode(): void {
const path = Deno.makeTempDirSync(); const path = Deno.makeTempDirSync();
const pathInfo = Deno.statSync(path); const pathInfo = Deno.statSync(path);
if (Deno.build.os !== "win") { if (Deno.build.os !== "windows") {
assertEquals(pathInfo.mode! & 0o777, 0o700 & ~Deno.umask()); assertEquals(pathInfo.mode! & 0o777, 0o700 & ~Deno.umask());
} }
} }
@ -82,7 +82,7 @@ unitTest(
async function makeTempDirMode(): Promise<void> { async function makeTempDirMode(): Promise<void> {
const path = await Deno.makeTempDir(); const path = await Deno.makeTempDir();
const pathInfo = Deno.statSync(path); const pathInfo = Deno.statSync(path);
if (Deno.build.os !== "win") { if (Deno.build.os !== "windows") {
assertEquals(pathInfo.mode! & 0o777, 0o700 & ~Deno.umask()); assertEquals(pathInfo.mode! & 0o777, 0o700 & ~Deno.umask());
} }
} }
@ -119,7 +119,7 @@ unitTest(
function makeTempFileSyncMode(): void { function makeTempFileSyncMode(): void {
const path = Deno.makeTempFileSync(); const path = Deno.makeTempFileSync();
const pathInfo = Deno.statSync(path); const pathInfo = Deno.statSync(path);
if (Deno.build.os !== "win") { if (Deno.build.os !== "windows") {
assertEquals(pathInfo.mode! & 0o777, 0o600 & ~Deno.umask()); assertEquals(pathInfo.mode! & 0o777, 0o600 & ~Deno.umask());
} }
} }
@ -171,7 +171,7 @@ unitTest(
async function makeTempFileMode(): Promise<void> { async function makeTempFileMode(): Promise<void> {
const path = await Deno.makeTempFile(); const path = await Deno.makeTempFile();
const pathInfo = Deno.statSync(path); const pathInfo = Deno.statSync(path);
if (Deno.build.os !== "win") { if (Deno.build.os !== "windows") {
assertEquals(pathInfo.mode! & 0o777, 0o600 & ~Deno.umask()); assertEquals(pathInfo.mode! & 0o777, 0o600 & ~Deno.umask());
} }
} }

View file

@ -4,7 +4,7 @@ import { unitTest, assert, assertEquals, assertThrows } from "./test_util.ts";
function assertDirectory(path: string, mode?: number): void { function assertDirectory(path: string, mode?: number): void {
const info = Deno.lstatSync(path); const info = Deno.lstatSync(path);
assert(info.isDirectory); assert(info.isDirectory);
if (Deno.build.os !== "win" && mode !== undefined) { if (Deno.build.os !== "windows" && mode !== undefined) {
assertEquals(info.mode! & 0o777, mode & ~Deno.umask()); assertEquals(info.mode! & 0o777, mode & ~Deno.umask());
} }
} }
@ -126,7 +126,7 @@ unitTest(
Deno.mkdirSync(path, { recursive: true }); Deno.mkdirSync(path, { recursive: true });
Deno.mkdirSync(path, { recursive: true, mode: 0o731 }); Deno.mkdirSync(path, { recursive: true, mode: 0o731 });
assertDirectory(path, 0o737); assertDirectory(path, 0o737);
if (Deno.build.os != "win") { if (Deno.build.os !== "windows") {
const pathLink = path + "Link"; const pathLink = path + "Link";
Deno.symlinkSync(path, pathLink); Deno.symlinkSync(path, pathLink);
Deno.mkdirSync(pathLink, { recursive: true }); Deno.mkdirSync(pathLink, { recursive: true });
@ -144,7 +144,7 @@ unitTest(
await Deno.mkdir(path, { recursive: true }); await Deno.mkdir(path, { recursive: true });
await Deno.mkdir(path, { recursive: true, mode: 0o731 }); await Deno.mkdir(path, { recursive: true, mode: 0o731 });
assertDirectory(path, 0o737); assertDirectory(path, 0o737);
if (Deno.build.os != "win") { if (Deno.build.os !== "windows") {
const pathLink = path + "Link"; const pathLink = path + "Link";
Deno.symlinkSync(path, pathLink); Deno.symlinkSync(path, pathLink);
await Deno.mkdir(pathLink, { recursive: true }); await Deno.mkdir(pathLink, { recursive: true });
@ -178,7 +178,7 @@ unitTest(
Deno.mkdirSync(file, { recursive: true }); Deno.mkdirSync(file, { recursive: true });
}, Deno.errors.AlreadyExists); }, Deno.errors.AlreadyExists);
if (Deno.build.os !== "win") { if (Deno.build.os !== "windows") {
const fileLink = testDir + "/fileLink"; const fileLink = testDir + "/fileLink";
const dirLink = testDir + "/dirLink"; const dirLink = testDir + "/dirLink";
const danglingLink = testDir + "/danglingLink"; const danglingLink = testDir + "/danglingLink";

View file

@ -18,7 +18,7 @@ unitTest(
{ {
perms: { net: true }, perms: { net: true },
// TODO: // TODO:
ignore: Deno.build.os === "win", ignore: Deno.build.os === "windows",
}, },
function netUdpListenClose(): void { function netUdpListenClose(): void {
const socket = Deno.listen({ const socket = Deno.listen({
@ -34,7 +34,7 @@ unitTest(
); );
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 { function netUnixListenClose(): void {
const filePath = Deno.makeTempFileSync(); const filePath = Deno.makeTempFileSync();
const socket = Deno.listen({ const socket = Deno.listen({
@ -48,7 +48,7 @@ unitTest(
); );
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 { function netUnixPacketListenClose(): void {
const filePath = Deno.makeTempFileSync(); const filePath = Deno.makeTempFileSync();
const socket = Deno.listen({ const socket = Deno.listen({
@ -82,7 +82,7 @@ unitTest(
); );
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<void> { async function netUnixCloseWhileAccept(): Promise<void> {
const filePath = await Deno.makeTempFile(); const filePath = await Deno.makeTempFile();
const listener = Deno.listen({ const listener = Deno.listen({
@ -189,7 +189,7 @@ unitTest({ perms: { net: true } }, async function netTcpDialListen(): Promise<
}); });
unitTest( 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<void> { async function netUnixDialListen(): Promise<void> {
const filePath = await Deno.makeTempFile(); const filePath = await Deno.makeTempFile();
const listener = Deno.listen({ address: filePath, transport: "unix" }); const listener = Deno.listen({ address: filePath, transport: "unix" });
@ -225,7 +225,7 @@ unitTest(
); );
unitTest( unitTest(
{ ignore: Deno.build.os === "win", perms: { net: true } }, { ignore: Deno.build.os === "windows", perms: { net: true } },
async function netUdpSendReceive(): Promise<void> { async function netUdpSendReceive(): Promise<void> {
const alice = Deno.listen({ port: 4500, transport: "udp" }); const alice = Deno.listen({ port: 4500, transport: "udp" });
assert(alice.addr.transport === "udp"); assert(alice.addr.transport === "udp");
@ -253,7 +253,7 @@ unitTest(
); );
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<void> { async function netUnixPacketSendReceive(): Promise<void> {
const filePath = await Deno.makeTempFile(); const filePath = await Deno.makeTempFile();
const alice = Deno.listen({ address: filePath, transport: "unixpacket" }); const alice = Deno.listen({ address: filePath, transport: "unixpacket" });
@ -293,7 +293,7 @@ unitTest(
); );
unitTest( unitTest(
{ ignore: Deno.build.os === "win", perms: { net: true } }, { ignore: Deno.build.os === "windows", perms: { net: true } },
async function netUdpListenCloseWhileIterating(): Promise<void> { async function netUdpListenCloseWhileIterating(): Promise<void> {
const socket = Deno.listen({ port: 8000, transport: "udp" }); const socket = Deno.listen({ port: 8000, transport: "udp" });
const nextWhileClosing = socket[Symbol.asyncIterator]().next(); const nextWhileClosing = socket[Symbol.asyncIterator]().next();
@ -306,7 +306,7 @@ unitTest(
); );
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<void> { async function netUnixListenCloseWhileIterating(): Promise<void> {
const filePath = Deno.makeTempFileSync(); const filePath = Deno.makeTempFileSync();
const socket = Deno.listen({ address: filePath, transport: "unix" }); const socket = Deno.listen({ address: filePath, transport: "unix" });
@ -320,7 +320,7 @@ unitTest(
); );
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<void> { async function netUnixPacketListenCloseWhileIterating(): Promise<void> {
const filePath = Deno.makeTempFileSync(); const filePath = Deno.makeTempFileSync();
const socket = Deno.listen({ address: filePath, transport: "unixpacket" }); const socket = Deno.listen({ address: filePath, transport: "unixpacket" });

View file

@ -50,7 +50,7 @@ unitTest(function envPermissionDenied2(): void {
// case-insensitive. Case normalization needs be done using the collation // case-insensitive. Case normalization needs be done using the collation
// that Windows uses, rather than naively using String.toLowerCase(). // that Windows uses, rather than naively using String.toLowerCase().
unitTest( unitTest(
{ ignore: Deno.build.os !== "win", perms: { env: true, run: true } }, { ignore: Deno.build.os !== "windows", perms: { env: true, run: true } },
async function envCaseInsensitive() { async function envCaseInsensitive() {
// Utility function that runs a Deno subprocess with the environment // Utility function that runs a Deno subprocess with the environment
// specified in `inputEnv`. The subprocess reads the environment variables // specified in `inputEnv`. The subprocess reads the environment variables
@ -116,7 +116,7 @@ unitTest(function osPid(): void {
}); });
unitTest({ perms: { env: true } }, function getDir(): void { unitTest({ perms: { env: true } }, function getDir(): void {
type supportOS = "mac" | "win" | "linux"; type supportOS = "darwin" | "windows" | "linux";
interface Runtime { interface Runtime {
os: supportOS; os: supportOS;
@ -132,120 +132,120 @@ unitTest({ perms: { env: true } }, function getDir(): void {
{ {
kind: "config", kind: "config",
runtime: [ runtime: [
{ os: "mac", shouldHaveValue: true }, { os: "darwin", shouldHaveValue: true },
{ os: "win", shouldHaveValue: true }, { os: "windows", shouldHaveValue: true },
{ os: "linux", shouldHaveValue: true }, { os: "linux", shouldHaveValue: true },
], ],
}, },
{ {
kind: "cache", kind: "cache",
runtime: [ runtime: [
{ os: "mac", shouldHaveValue: true }, { os: "darwin", shouldHaveValue: true },
{ os: "win", shouldHaveValue: true }, { os: "windows", shouldHaveValue: true },
{ os: "linux", shouldHaveValue: true }, { os: "linux", shouldHaveValue: true },
], ],
}, },
{ {
kind: "executable", kind: "executable",
runtime: [ runtime: [
{ os: "mac", shouldHaveValue: false }, { os: "darwin", shouldHaveValue: false },
{ os: "win", shouldHaveValue: false }, { os: "windows", shouldHaveValue: false },
{ os: "linux", shouldHaveValue: true }, { os: "linux", shouldHaveValue: true },
], ],
}, },
{ {
kind: "data", kind: "data",
runtime: [ runtime: [
{ os: "mac", shouldHaveValue: true }, { os: "darwin", shouldHaveValue: true },
{ os: "win", shouldHaveValue: true }, { os: "windows", shouldHaveValue: true },
{ os: "linux", shouldHaveValue: true }, { os: "linux", shouldHaveValue: true },
], ],
}, },
{ {
kind: "data_local", kind: "data_local",
runtime: [ runtime: [
{ os: "mac", shouldHaveValue: true }, { os: "darwin", shouldHaveValue: true },
{ os: "win", shouldHaveValue: true }, { os: "windows", shouldHaveValue: true },
{ os: "linux", shouldHaveValue: true }, { os: "linux", shouldHaveValue: true },
], ],
}, },
{ {
kind: "audio", kind: "audio",
runtime: [ runtime: [
{ os: "mac", shouldHaveValue: true }, { os: "darwin", shouldHaveValue: true },
{ os: "win", shouldHaveValue: true }, { os: "windows", shouldHaveValue: true },
{ os: "linux", shouldHaveValue: false }, { os: "linux", shouldHaveValue: false },
], ],
}, },
{ {
kind: "desktop", kind: "desktop",
runtime: [ runtime: [
{ os: "mac", shouldHaveValue: true }, { os: "darwin", shouldHaveValue: true },
{ os: "win", shouldHaveValue: true }, { os: "windows", shouldHaveValue: true },
{ os: "linux", shouldHaveValue: false }, { os: "linux", shouldHaveValue: false },
], ],
}, },
{ {
kind: "document", kind: "document",
runtime: [ runtime: [
{ os: "mac", shouldHaveValue: true }, { os: "darwin", shouldHaveValue: true },
{ os: "win", shouldHaveValue: true }, { os: "windows", shouldHaveValue: true },
{ os: "linux", shouldHaveValue: false }, { os: "linux", shouldHaveValue: false },
], ],
}, },
{ {
kind: "download", kind: "download",
runtime: [ runtime: [
{ os: "mac", shouldHaveValue: true }, { os: "darwin", shouldHaveValue: true },
{ os: "win", shouldHaveValue: true }, { os: "windows", shouldHaveValue: true },
{ os: "linux", shouldHaveValue: false }, { os: "linux", shouldHaveValue: false },
], ],
}, },
{ {
kind: "font", kind: "font",
runtime: [ runtime: [
{ os: "mac", shouldHaveValue: true }, { os: "darwin", shouldHaveValue: true },
{ os: "win", shouldHaveValue: false }, { os: "windows", shouldHaveValue: false },
{ os: "linux", shouldHaveValue: true }, { os: "linux", shouldHaveValue: true },
], ],
}, },
{ {
kind: "picture", kind: "picture",
runtime: [ runtime: [
{ os: "mac", shouldHaveValue: true }, { os: "darwin", shouldHaveValue: true },
{ os: "win", shouldHaveValue: true }, { os: "windows", shouldHaveValue: true },
{ os: "linux", shouldHaveValue: false }, { os: "linux", shouldHaveValue: false },
], ],
}, },
{ {
kind: "public", kind: "public",
runtime: [ runtime: [
{ os: "mac", shouldHaveValue: true }, { os: "darwin", shouldHaveValue: true },
{ os: "win", shouldHaveValue: true }, { os: "windows", shouldHaveValue: true },
{ os: "linux", shouldHaveValue: false }, { os: "linux", shouldHaveValue: false },
], ],
}, },
{ {
kind: "template", kind: "template",
runtime: [ runtime: [
{ os: "mac", shouldHaveValue: false }, { os: "darwin", shouldHaveValue: false },
{ os: "win", shouldHaveValue: true }, { os: "windows", shouldHaveValue: true },
{ os: "linux", shouldHaveValue: false }, { os: "linux", shouldHaveValue: false },
], ],
}, },
{ {
kind: "tmp", kind: "tmp",
runtime: [ runtime: [
{ os: "mac", shouldHaveValue: true }, { os: "darwin", shouldHaveValue: true },
{ os: "win", shouldHaveValue: true }, { os: "windows", shouldHaveValue: true },
{ os: "linux", shouldHaveValue: true }, { os: "linux", shouldHaveValue: true },
], ],
}, },
{ {
kind: "video", kind: "video",
runtime: [ runtime: [
{ os: "mac", shouldHaveValue: true }, { os: "darwin", shouldHaveValue: true },
{ os: "win", shouldHaveValue: true }, { os: "windows", shouldHaveValue: true },
{ os: "linux", shouldHaveValue: false }, { os: "linux", shouldHaveValue: false },
], ],
}, },

View file

@ -49,7 +49,7 @@ unitTest(
unitTest( unitTest(
{ {
// No signals on windows. // No signals on windows.
ignore: Deno.build.os === "win", ignore: Deno.build.os === "windows",
perms: { run: true }, perms: { run: true },
}, },
async function runCommandFailedWithSignal(): Promise<void> { async function runCommandFailedWithSignal(): Promise<void> {
@ -318,7 +318,7 @@ unitTest({ perms: { run: true } }, async function runClose(): Promise<void> {
}); });
unitTest(function signalNumbers(): void { unitTest(function signalNumbers(): void {
if (Deno.build.os === "mac") { if (Deno.build.os === "darwin") {
assertEquals(Deno.Signal.SIGSTOP, 17); assertEquals(Deno.Signal.SIGSTOP, 17);
} else if (Deno.build.os === "linux") { } else if (Deno.build.os === "linux") {
assertEquals(Deno.Signal.SIGSTOP, 19); assertEquals(Deno.Signal.SIGSTOP, 19);
@ -326,7 +326,7 @@ unitTest(function signalNumbers(): void {
}); });
// Ignore signal tests on windows for now... // Ignore signal tests on windows for now...
if (Deno.build.os !== "win") { if (Deno.build.os !== "windows") {
unitTest(function killPermissions(): void { unitTest(function killPermissions(): void {
let caughtError = false; let caughtError = false;
try { try {

View file

@ -10,7 +10,7 @@ unitTest(
Deno.mkdirSync(target); Deno.mkdirSync(target);
// TODO Add test for Windows once symlink is implemented for Windows. // TODO Add test for Windows once symlink is implemented for Windows.
// See https://github.com/denoland/deno/issues/815. // See https://github.com/denoland/deno/issues/815.
if (Deno.build.os !== "win") { if (Deno.build.os !== "windows") {
Deno.symlinkSync(target, symlink); Deno.symlinkSync(target, symlink);
const targetPath = Deno.readlinkSync(symlink); const targetPath = Deno.readlinkSync(symlink);
assertEquals(targetPath, target); assertEquals(targetPath, target);
@ -51,7 +51,7 @@ unitTest(
Deno.mkdirSync(target); Deno.mkdirSync(target);
// TODO Add test for Windows once symlink is implemented for Windows. // TODO Add test for Windows once symlink is implemented for Windows.
// See https://github.com/denoland/deno/issues/815. // See https://github.com/denoland/deno/issues/815.
if (Deno.build.os !== "win") { if (Deno.build.os !== "windows") {
Deno.symlinkSync(target, symlink); Deno.symlinkSync(target, symlink);
const targetPath = await Deno.readlink(symlink); const targetPath = await Deno.readlink(symlink);
assertEquals(targetPath, target); assertEquals(targetPath, target);

View file

@ -4,7 +4,7 @@ import { unitTest, assert } from "./test_util.ts";
unitTest({ perms: { read: true } }, function realpathSyncSuccess(): void { unitTest({ perms: { read: true } }, function realpathSyncSuccess(): void {
const incompletePath = "cli/tests/fixture.json"; const incompletePath = "cli/tests/fixture.json";
const realPath = Deno.realpathSync(incompletePath); const realPath = Deno.realpathSync(incompletePath);
if (Deno.build.os !== "win") { if (Deno.build.os !== "windows") {
assert(realPath.startsWith("/")); assert(realPath.startsWith("/"));
} else { } else {
assert(/^[A-Z]/.test(realPath)); assert(/^[A-Z]/.test(realPath));
@ -14,7 +14,7 @@ unitTest({ perms: { read: true } }, function realpathSyncSuccess(): void {
unitTest( unitTest(
{ {
ignore: Deno.build.os === "win", ignore: Deno.build.os === "windows",
perms: { read: true, write: true }, perms: { read: true, write: true },
}, },
function realpathSyncSymlink(): void { function realpathSyncSymlink(): void {
@ -56,7 +56,7 @@ unitTest({ perms: { read: true } }, async function realpathSuccess(): Promise<
> { > {
const incompletePath = "cli/tests/fixture.json"; const incompletePath = "cli/tests/fixture.json";
const realPath = await Deno.realpath(incompletePath); const realPath = await Deno.realpath(incompletePath);
if (Deno.build.os !== "win") { if (Deno.build.os !== "windows") {
assert(realPath.startsWith("/")); assert(realPath.startsWith("/"));
} else { } else {
assert(/^[A-Z]/.test(realPath)); assert(/^[A-Z]/.test(realPath));
@ -66,7 +66,7 @@ unitTest({ perms: { read: true } }, async function realpathSuccess(): Promise<
unitTest( unitTest(
{ {
ignore: Deno.build.os === "win", ignore: Deno.build.os === "windows",
perms: { read: true, write: true }, perms: { read: true, write: true },
}, },
async function realpathSymlink(): Promise<void> { async function realpathSymlink(): Promise<void> {

View file

@ -90,7 +90,7 @@ unitTest(
} catch (err) { } catch (err) {
errOnWindows = err; errOnWindows = err;
} }
if (Deno.build.os === "win") { if (Deno.build.os === "windows") {
assertEquals(errOnWindows.message, "not implemented"); assertEquals(errOnWindows.message, "not implemented");
} else { } else {
const pathInfo = Deno.lstatSync(danglingSymlinkPath); const pathInfo = Deno.lstatSync(danglingSymlinkPath);
@ -123,7 +123,7 @@ unitTest(
} catch (err) { } catch (err) {
errOnWindows = err; errOnWindows = err;
} }
if (Deno.build.os === "win") { if (Deno.build.os === "windows") {
assertEquals(errOnWindows.message, "not implemented"); assertEquals(errOnWindows.message, "not implemented");
} else { } else {
const symlinkPathInfo = Deno.statSync(validSymlinkPath); const symlinkPathInfo = Deno.statSync(validSymlinkPath);
@ -326,7 +326,7 @@ unitTest(
} catch (e) { } catch (e) {
errOnWindows = e; errOnWindows = e;
} }
if (Deno.build.os === "win") { if (Deno.build.os === "windows") {
assertEquals(errOnWindows.message, "not implemented"); assertEquals(errOnWindows.message, "not implemented");
} else { } else {
const pathInfo = Deno.lstatSync(danglingSymlinkPath); const pathInfo = Deno.lstatSync(danglingSymlinkPath);
@ -359,7 +359,7 @@ unitTest(
} catch (e) { } catch (e) {
errOnWindows = e; errOnWindows = e;
} }
if (Deno.build.os === "win") { if (Deno.build.os === "windows") {
assertEquals(errOnWindows.message, "not implemented"); assertEquals(errOnWindows.message, "not implemented");
} else { } else {
const symlinkPathInfo = Deno.statSync(validSymlinkPath); const symlinkPathInfo = Deno.statSync(validSymlinkPath);

View file

@ -22,7 +22,7 @@ function assertFile(path: string): void {
function assertDirectory(path: string, mode?: number): void { function assertDirectory(path: string, mode?: number): void {
const info = Deno.lstatSync(path); const info = Deno.lstatSync(path);
assert(info.isDirectory); assert(info.isDirectory);
if (Deno.build.os !== "win" && mode !== undefined) { if (Deno.build.os !== "windows" && mode !== undefined) {
assertEquals(info.mode! & 0o777, mode & ~Deno.umask()); assertEquals(info.mode! & 0o777, mode & ~Deno.umask());
} }
} }
@ -98,7 +98,7 @@ function writeFileString(filename: string, s: string): void {
} }
unitTest( unitTest(
{ ignore: Deno.build.os === "win", perms: { read: true, write: true } }, { ignore: Deno.build.os === "windows", perms: { read: true, write: true } },
function renameSyncErrorsUnix(): void { function renameSyncErrorsUnix(): void {
const testDir = Deno.makeTempDirSync(); const testDir = Deno.makeTempDirSync();
const oldfile = testDir + "/oldfile"; const oldfile = testDir + "/oldfile";
@ -173,7 +173,7 @@ unitTest(
); );
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 { function renameSyncErrorsWin(): void {
const testDir = Deno.makeTempDirSync(); const testDir = Deno.makeTempDirSync();
const oldfile = testDir + "/oldfile"; const oldfile = testDir + "/oldfile";

View file

@ -14,7 +14,7 @@ function defer(n: number): Promise<void> {
} }
unitTest( unitTest(
{ ignore: Deno.build.os !== "win" }, { ignore: Deno.build.os !== "windows" },
function signalsNotImplemented(): void { function signalsNotImplemented(): void {
assertThrows( assertThrows(
() => { () => {
@ -104,7 +104,7 @@ unitTest(
); );
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<void> { async function signalStreamTest(): Promise<void> {
const resolvable = createResolvable(); const resolvable = createResolvable();
// This prevents the program from exiting. // This prevents the program from exiting.
@ -135,7 +135,7 @@ unitTest(
); );
unitTest( unitTest(
{ ignore: Deno.build.os === "win", perms: { run: true } }, { ignore: Deno.build.os === "windows", perms: { run: true } },
async function signalPromiseTest(): Promise<void> { async function signalPromiseTest(): Promise<void> {
const resolvable = createResolvable(); const resolvable = createResolvable();
// This prevents the program from exiting. // This prevents the program from exiting.
@ -155,7 +155,7 @@ unitTest(
); );
unitTest( unitTest(
{ ignore: Deno.build.os === "win", perms: { run: true } }, { ignore: Deno.build.os === "windows", perms: { run: true } },
function signalShorthandsTest(): void { function signalShorthandsTest(): void {
let s: Deno.SignalStream; let s: Deno.SignalStream;
s = Deno.signals.alarm(); // for SIGALRM s = Deno.signals.alarm(); // for SIGALRM

View file

@ -193,7 +193,7 @@ unitTest({ perms: { read: true } }, async function lstatNotFound(): Promise<
}); });
unitTest( unitTest(
{ ignore: Deno.build.os !== "win", perms: { read: true, write: true } }, { ignore: Deno.build.os !== "windows", perms: { read: true, write: true } },
function statNoUnixFields(): void { function statNoUnixFields(): void {
const enc = new TextEncoder(); const enc = new TextEncoder();
const data = enc.encode("Hello"); const data = enc.encode("Hello");
@ -214,7 +214,7 @@ unitTest(
); );
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 { function statUnixFields(): void {
const enc = new TextEncoder(); const enc = new TextEncoder();
const data = enc.encode("Hello"); const data = enc.encode("Hello");

View file

@ -16,7 +16,7 @@ unitTest(
errOnWindows = e; errOnWindows = e;
} }
if (errOnWindows) { if (errOnWindows) {
assertEquals(Deno.build.os, "win"); assertEquals(Deno.build.os, "windows");
assertEquals(errOnWindows.message, "not implemented"); assertEquals(errOnWindows.message, "not implemented");
} else { } else {
const newNameInfoLStat = Deno.lstatSync(newname); const newNameInfoLStat = Deno.lstatSync(newname);
@ -53,7 +53,7 @@ unitTest(
err = e; err = e;
} }
if (err) { if (err) {
assertEquals(Deno.build.os, "win"); assertEquals(Deno.build.os, "windows");
// from cli/js/util.ts:notImplemented // from cli/js/util.ts:notImplemented
assertEquals(err.message, "not implemented"); assertEquals(err.message, "not implemented");
} }

View file

@ -3,7 +3,7 @@ import { unitTest, assertEquals } from "./test_util.ts";
unitTest( unitTest(
{ {
ignore: Deno.build.os === "win", ignore: Deno.build.os === "windows",
}, },
function umaskSuccess(): void { function umaskSuccess(): void {
const prevMask = Deno.umask(0o020); const prevMask = Deno.umask(0o020);

View file

@ -48,7 +48,7 @@ unitTest({ perms: { write: false } }, function writeFileSyncPerm(): void {
unitTest( unitTest(
{ perms: { read: true, write: true } }, { perms: { read: true, write: true } },
function writeFileSyncUpdateMode(): void { function writeFileSyncUpdateMode(): void {
if (Deno.build.os !== "win") { if (Deno.build.os !== "windows") {
const enc = new TextEncoder(); const enc = new TextEncoder();
const data = enc.encode("Hello"); const data = enc.encode("Hello");
const filename = Deno.makeTempDirSync() + "/test.txt"; const filename = Deno.makeTempDirSync() + "/test.txt";
@ -164,7 +164,7 @@ unitTest(
unitTest( unitTest(
{ perms: { read: true, write: true } }, { perms: { read: true, write: true } },
async function writeFileUpdateMode(): Promise<void> { async function writeFileUpdateMode(): Promise<void> {
if (Deno.build.os !== "win") { if (Deno.build.os !== "windows") {
const enc = new TextEncoder(); const enc = new TextEncoder();
const data = enc.encode("Hello"); const data = enc.encode("Hello");
const filename = Deno.makeTempDirSync() + "/test.txt"; const filename = Deno.makeTempDirSync() + "/test.txt";

View file

@ -13,7 +13,7 @@ export function containsOnlyASCII(str: string): boolean {
} }
function convertLineEndingsToNative(s: string): string { function convertLineEndingsToNative(s: string): string {
const nativeLineEnd = build.os == "win" ? "\r\n" : "\n"; const nativeLineEnd = build.os == "windows" ? "\r\n" : "\n";
let position = 0; let position = 0;

View file

@ -32,7 +32,7 @@ export function writeFileSync(
if ( if (
options.mode !== undefined && options.mode !== undefined &&
options.mode !== null && options.mode !== null &&
build.os !== "win" build.os !== "windows"
) { ) {
chmodSync(path, options.mode); chmodSync(path, options.mode);
} }
@ -62,7 +62,7 @@ export async function writeFile(
if ( if (
options.mode !== undefined && options.mode !== undefined &&
options.mode !== null && options.mode !== null &&
build.os !== "win" build.os !== "windows"
) { ) {
await chmod(path, options.mode); await chmod(path, options.mode);
} }

View file

@ -9,16 +9,6 @@ use deno_core::CoreIsolate;
use deno_core::ZeroCopyBuf; use deno_core::ZeroCopyBuf;
use std::env; 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) { pub fn init(i: &mut CoreIsolate, s: &State) {
i.register_op("op_start", s.stateful_json_op(op_start)); i.register_op("op_start", s.stateful_json_op(op_start));
i.register_op("op_metrics", s.stateful_json_op(op_metrics)); i.register_op("op_metrics", s.stateful_json_op(op_metrics));
@ -45,8 +35,7 @@ fn op_start(
"denoVersion": version::DENO, "denoVersion": version::DENO,
"tsVersion": version::TYPESCRIPT, "tsVersion": version::TYPESCRIPT,
"noColor": !colors::use_color(), "noColor": !colors::use_color(),
"os": BUILD_OS, "target": env!("TARGET"),
"arch": BUILD_ARCH,
}))) })))
} }

View file

@ -27,7 +27,7 @@ async function startServer(): Promise<Deno.Process> {
} }
// TODO: https://github.com/denoland/deno/issues/4108 // TODO: https://github.com/denoland/deno/issues/4108
const ignore = build.os == "win"; const ignore = build.os == "windows";
test({ test({
ignore, ignore,

View file

@ -15,7 +15,7 @@ import { ensureSymlink, ensureSymlinkSync } from "./ensure_symlink.ts";
const testdataDir = path.resolve("fs", "testdata"); const testdataDir = path.resolve("fs", "testdata");
// TODO(axetroy): Add test for Windows once symlink is implemented for Windows. // 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>): void { function testCopy(name: string, cb: (tempDir: string) => Promise<void>): void {
Deno.test({ Deno.test({

View file

@ -9,7 +9,7 @@ import * as path from "../path/mod.ts";
import { ensureSymlink, ensureSymlinkSync } from "./ensure_symlink.ts"; import { ensureSymlink, ensureSymlinkSync } from "./ensure_symlink.ts";
const testdataDir = path.resolve("fs", "testdata"); const testdataDir = path.resolve("fs", "testdata");
const isWindows = Deno.build.os === "win"; const isWindows = Deno.build.os === "windows";
Deno.test("ensureSymlinkIfItNotExist", async function (): Promise<void> { Deno.test("ensureSymlinkIfItNotExist", async function (): Promise<void> {
const testDir = path.join(testdataDir, "link_file_1"); const testDir = path.join(testdataDir, "link_file_1");

View file

@ -3,8 +3,6 @@ const { remove } = Deno;
import { walk, walkSync, WalkOptions, WalkEntry } from "./walk.ts"; import { walk, walkSync, WalkOptions, WalkEntry } from "./walk.ts";
import { assert, assertEquals, assertThrowsAsync } from "../testing/asserts.ts"; import { assert, assertEquals, assertThrowsAsync } from "../testing/asserts.ts";
const isWindows = Deno.build.os == "win";
export function testWalk( export function testWalk(
setup: (arg0: string) => void | Promise<void>, setup: (arg0: string) => void | Promise<void>,
t: () => void | Promise<void>, t: () => void | Promise<void>,
@ -254,13 +252,13 @@ testWalk(
try { try {
await symlink(d + "/b", d + "/a/bb"); await symlink(d + "/b", d + "/a/bb");
} catch (err) { } catch (err) {
assert(isWindows); assert(Deno.build.os == "windows");
assertEquals(err.message, "Not implemented"); assertEquals(err.message, "Not implemented");
} }
}, },
async function symlink(): Promise<void> { async function symlink(): Promise<void> {
// symlink is not yet implemented on Windows. // symlink is not yet implemented on Windows.
if (isWindows) { if (Deno.build.os == "windows") {
return; return;
} }

View file

@ -62,9 +62,9 @@ test("serveDirectory", async function (): Promise<void> {
// `Deno.FileInfo` is not completely compatible with Windows yet // `Deno.FileInfo` is not completely compatible with Windows yet
// TODO: `mode` should work correctly in the future. // TODO: `mode` should work correctly in the future.
// Correct this test case accordingly. // Correct this test case accordingly.
Deno.build.os !== "win" && Deno.build.os !== "windows" &&
assert(/<td class="mode">(\s)*\([a-zA-Z-]{10}\)(\s)*<\/td>/.test(page)); assert(/<td class="mode">(\s)*\([a-zA-Z-]{10}\)(\s)*<\/td>/.test(page));
Deno.build.os === "win" && Deno.build.os === "windows" &&
assert(/<td class="mode">(\s)*\(unknown mode\)(\s)*<\/td>/.test(page)); assert(/<td class="mode">(\s)*\(unknown mode\)(\s)*<\/td>/.test(page));
assert(page.includes(`<a href="/README.md">README.md</a>`)); assert(page.includes(`<a href="/README.md">README.md</a>`));
} finally { } finally {

View file

@ -5,7 +5,7 @@ import { chmod, chmodSync } from "./_fs_chmod.ts";
test({ test({
name: "ASYNC: Permissions are changed (non-Windows)", name: "ASYNC: Permissions are changed (non-Windows)",
ignore: Deno.build.os === "win", ignore: Deno.build.os === "windows",
async fn() { async fn() {
const tempFile: string = await Deno.makeTempFile(); const tempFile: string = await Deno.makeTempFile();
const originalFileMode: number | null = (await Deno.lstat(tempFile)).mode; const originalFileMode: number | null = (await Deno.lstat(tempFile)).mode;
@ -31,7 +31,7 @@ test({
test({ test({
name: "SYNC: Permissions are changed (non-Windows)", name: "SYNC: Permissions are changed (non-Windows)",
ignore: Deno.build.os === "win", ignore: Deno.build.os === "windows",
fn() { fn() {
const tempFile: string = Deno.makeTempFileSync(); const tempFile: string = Deno.makeTempFileSync();
const originalFileMode: number | null = Deno.lstatSync(tempFile).mode; const originalFileMode: number | null = Deno.lstatSync(tempFile).mode;

View file

@ -3,8 +3,9 @@ const { test } = Deno;
import { fail, assertEquals } from "../../testing/asserts.ts"; import { fail, assertEquals } from "../../testing/asserts.ts";
import { chown, chownSync } from "./_fs_chown.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 // chown is difficult to test. Best we can do is set the existing user id/group
const ignore = Deno.build.os == "win"; // id again
const ignore = Deno.build.os == "windows";
test({ test({
ignore, ignore,

View file

@ -6,13 +6,13 @@ const testDir = Deno.makeTempDirSync();
const oldname = testDir + "/oldname"; const oldname = testDir + "/oldname";
const newname = testDir + "/newname"; const newname = testDir + "/newname";
if (Deno.build.os !== "win") { if (Deno.build.os !== "windows") {
Deno.symlinkSync(oldname, newname); Deno.symlinkSync(oldname, newname);
} }
test({ test({
name: "readlinkSuccess", name: "readlinkSuccess",
ignore: Deno.build.os === "win", ignore: Deno.build.os === "windows",
async fn() { async fn() {
const data = await new Promise((res, rej) => { const data = await new Promise((res, rej) => {
readlink(newname, (err, data) => { readlink(newname, (err, data) => {
@ -30,7 +30,7 @@ test({
test({ test({
name: "readlinkEncodeBufferSuccess", name: "readlinkEncodeBufferSuccess",
ignore: Deno.build.os === "win", ignore: Deno.build.os === "windows",
async fn() { async fn() {
const data = await new Promise((res, rej) => { const data = await new Promise((res, rej) => {
readlink(newname, { encoding: "buffer" }, (err, data) => { readlink(newname, { encoding: "buffer" }, (err, data) => {
@ -48,7 +48,7 @@ test({
test({ test({
name: "readlinkSyncSuccess", name: "readlinkSyncSuccess",
ignore: Deno.build.os === "win", ignore: Deno.build.os === "windows",
fn() { fn() {
const data = readlinkSync(newname); const data = readlinkSync(newname);
assertEquals(typeof data, "string"); assertEquals(typeof data, "string");
@ -58,7 +58,7 @@ test({
test({ test({
name: "readlinkEncodeBufferSuccess", name: "readlinkEncodeBufferSuccess",
ignore: Deno.build.os === "win", ignore: Deno.build.os === "windows",
fn() { fn() {
const data = readlinkSync(newname, { encoding: "buffer" }); const data = readlinkSync(newname, { encoding: "buffer" });
assert(data instanceof Uint8Array); assert(data instanceof Uint8Array);

View file

@ -146,7 +146,7 @@ export function hostname(): string {
/** Returns an array containing the 1, 5, and 15 minute load averages */ /** Returns an array containing the 1, 5, and 15 minute load averages */
export function loadavg(): number[] { export function loadavg(): number[] {
if (Deno.build.os == "win") { if (Deno.build.os === "windows") {
return [0, 0, 0]; return [0, 0, 0];
} }
return Deno.loadavg(); 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;

View file

@ -7,10 +7,7 @@ const versions = {
...Deno.version, ...Deno.version,
}; };
const osToPlatform = (os: Deno.OperatingSystem): string => const platform = Deno.build.os === "windows" ? "win32" : Deno.build.os;
os === "win" ? "win32" : os === "mac" ? "darwin" : os;
const platform = osToPlatform(Deno.build.os);
const { arch } = Deno.build; const { arch } = Deno.build;

View file

@ -48,7 +48,7 @@ export const CHAR_EQUAL = 61; /* = */
export const CHAR_0 = 48; /* 0 */ export const CHAR_0 = 48; /* 0 */
export const CHAR_9 = 57; /* 9 */ 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 EOL = isWindows ? "\r\n" : "\n";
export const SEP = isWindows ? "\\" : "/"; export const SEP = isWindows ? "\\" : "/";
export const SEP_PATTERN = isWindows ? /[\\/]+/ : /\/+/; export const SEP_PATTERN = isWindows ? /[\\/]+/ : /\/+/;

View file

@ -2,7 +2,7 @@
// MIT License // MIT License
// Copyright (c) 2018 Terkel Gjervig Nielsen // Copyright (c) 2018 Terkel Gjervig Nielsen
const isWin = Deno.build.os === "win"; const isWin = Deno.build.os === "windows";
const SEP = isWin ? `(?:\\\\|\\/)` : `\\/`; const SEP = isWin ? `(?:\\\\|\\/)` : `\\/`;
const SEP_ESC = isWin ? `\\\\` : `/`; const SEP_ESC = isWin ? `\\\\` : `/`;
const SEP_RAW = isWin ? `\\` : `/`; const SEP_RAW = isWin ? `\\` : `/`;

View file

@ -6,7 +6,7 @@ const { test } = Deno;
import { assertEquals } from "../testing/asserts.ts"; import { assertEquals } from "../testing/asserts.ts";
import { GlobrexOptions, globrex } from "./globrex.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 }; const t = { equal: assertEquals, is: assertEquals };
function match( function match(

View file

@ -5,7 +5,7 @@ import { signal, onSignal } from "./mod.ts";
test({ test({
name: "signal() throws when called with empty signals", name: "signal() throws when called with empty signals",
ignore: Deno.build.os === "win", ignore: Deno.build.os === "windows",
fn() { fn() {
assertThrows( assertThrows(
() => { () => {
@ -20,7 +20,7 @@ test({
test({ test({
name: "signal() iterates for multiple signals", name: "signal() iterates for multiple signals",
ignore: Deno.build.os === "win", ignore: Deno.build.os === "windows",
fn: async (): Promise<void> => { fn: async (): Promise<void> => {
// This prevents the program from exiting. // This prevents the program from exiting.
const t = setInterval(() => {}, 1000); const t = setInterval(() => {}, 1000);
@ -61,7 +61,7 @@ test({
test({ test({
name: "onSignal() registers and disposes of event handler", name: "onSignal() registers and disposes of event handler",
ignore: Deno.build.os === "win", ignore: Deno.build.os === "windows",
async fn() { async fn() {
// This prevents the program from exiting. // This prevents the program from exiting.
const t = setInterval(() => {}, 1000); const t = setInterval(() => {}, 1000);

View file

@ -3,11 +3,11 @@ const filenameBase = "test_plugin";
let filenameSuffix = ".so"; let filenameSuffix = ".so";
let filenamePrefix = "lib"; let filenamePrefix = "lib";
if (Deno.build.os === "win") { if (Deno.build.os === "windows") {
filenameSuffix = ".dll"; filenameSuffix = ".dll";
filenamePrefix = ""; filenamePrefix = "";
} }
if (Deno.build.os === "mac") { if (Deno.build.os === "darwin") {
filenameSuffix = ".dylib"; filenameSuffix = ".dylib";
} }