Skip to content

Commit

Permalink
BREAKING: Use LLVM target triple for Deno.build (denoland/deno#4948)
Browse files Browse the repository at this point in the history
Deno.build.os values have changed to correspond to standard LLVM target triples
"win" -> "windows"
"mac" -> "darwin"
  • Loading branch information
ry authored and caspervonb committed Jan 24, 2021
1 parent 5ce9aca commit a9626e8
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 30 deletions.
2 changes: 1 addition & 1 deletion examples/chat/server_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async function startServer(): Promise<Deno.Process> {
}

// TODO: https://github.com/denoland/deno/issues/4108
const ignore = build.os == "win";
const ignore = build.os == "windows";

test({
ignore,
Expand Down
2 changes: 1 addition & 1 deletion fs/copy_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>): void {
Deno.test({
Expand Down
2 changes: 1 addition & 1 deletion fs/ensure_symlink_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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("ensureSymlinkIfItNotExist", async function (): Promise<void> {
const testDir = path.join(testdataDir, "link_file_1");
Expand Down
6 changes: 2 additions & 4 deletions fs/walk_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>,
t: () => void | Promise<void>,
Expand Down Expand Up @@ -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<void> {
// symlink is not yet implemented on Windows.
if (isWindows) {
if (Deno.build.os == "windows") {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions http/file_server_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ test("serveDirectory", async function (): Promise<void> {
// `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(/<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(page.includes(`<a href="/README.md">README.md</a>`));
} finally {
Expand Down
4 changes: 2 additions & 2 deletions node/_fs/_fs_chmod_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions node/_fs/_fs_chown_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions node/_fs/_fs_readlink_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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) => {
Expand All @@ -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");
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions node/os.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
5 changes: 1 addition & 4 deletions node/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" : Deno.build.os;

const { arch } = Deno.build;

Expand Down
2 changes: 1 addition & 1 deletion path/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ? /[\\/]+/ : /\/+/;
2 changes: 1 addition & 1 deletion path/globrex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ? `\\` : `/`;
Expand Down
2 changes: 1 addition & 1 deletion path/globrex_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions signal/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
() => {
Expand All @@ -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<void> => {
// This prevents the program from exiting.
const t = setInterval(() => {}, 1000);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit a9626e8

Please sign in to comment.