1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

Reland "test: run unit tests with DENO_FUTURE=1" (#25212)

Reverted in https://github.com/denoland/deno/pull/25060
This commit is contained in:
Bartek Iwańczuk 2024-08-26 22:58:28 +01:00 committed by GitHub
parent 631d931973
commit ba58628601
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 489 additions and 224 deletions

View file

@ -117,6 +117,10 @@ util::unit_test_factory!(
); );
fn js_unit_test(test: String) { fn js_unit_test(test: String) {
js_unit_test_inner(test, false);
}
pub fn js_unit_test_inner(test: String, future: bool) {
let _g = util::http_server(); let _g = util::http_server();
let deno = util::deno_cmd() let deno = util::deno_cmd()
@ -129,6 +133,12 @@ fn js_unit_test(test: String) {
.arg("--location=http://127.0.0.1:4545/") .arg("--location=http://127.0.0.1:4545/")
.arg("--no-prompt"); .arg("--no-prompt");
let deno = if future {
deno.env("DENO_FUTURE", "1")
} else {
deno
};
// TODO(mmastrac): it would be better to just load a test CA for all tests // TODO(mmastrac): it would be better to just load a test CA for all tests
let deno = if test == "websocket_test" || test == "tls_sni_test" { let deno = if test == "websocket_test" || test == "tls_sni_test" {
deno.arg("--unsafely-ignore-certificate-errors") deno.arg("--unsafely-ignore-certificate-errors")

View file

@ -0,0 +1,118 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
use super::js_unit_tests::js_unit_test_inner;
use test_util as util;
util::unit_test_factory!(
js_unit_test_future,
"../tests/unit",
"*.ts",
[
abort_controller_test,
blob_test,
body_test,
broadcast_channel_test,
buffer_test,
build_test,
cache_api_test,
chmod_test,
chown_test,
command_test,
console_test,
copy_file_test,
custom_event_test,
cron_test,
dir_test,
dom_exception_test,
error_stack_test,
error_test,
esnext_test,
event_source_test,
event_target_test,
event_test,
fetch_test,
ffi_test,
file_test,
filereader_test,
files_test,
flock_test,
fs_events_test,
get_random_values_test,
globals_test,
headers_test,
http_test,
image_bitmap_test,
image_data_test,
internals_test,
intl_test,
io_test,
jupyter_test,
kv_test,
kv_queue_test_no_db_close,
kv_queue_test,
kv_queue_undelivered_test,
link_test,
make_temp_test,
message_channel_test,
mkdir_test,
navigator_test,
net_test,
network_interfaces_test,
os_test,
ops_test,
path_from_url_test,
performance_test,
permissions_test,
process_test,
progressevent_test,
promise_hooks_test,
read_dir_test,
read_file_test,
read_link_test,
read_text_file_test,
real_path_test,
ref_unref_test,
remove_test,
rename_test,
request_test,
resources_test,
response_test,
serve_test,
signal_test,
stat_test,
stdio_test,
streams_test,
structured_clone_test,
symbol_test,
symlink_test,
sync_test,
test_util,
testing_test,
text_encoding_test,
timers_test,
tls_test,
tls_sni_test,
truncate_test,
tty_color_test,
tty_test,
umask_test,
url_search_params_test,
url_test,
urlpattern_test,
utime_test,
version_test,
wasm_test,
webcrypto_test,
webgpu_test,
websocket_test,
webstorage_test,
worker_permissions_test,
worker_test,
write_file_test,
write_text_file_test,
]
);
fn js_unit_test_future(test: String) {
js_unit_test_inner(test, true);
}

View file

@ -37,6 +37,8 @@ mod inspector;
mod install; mod install;
#[path = "js_unit_tests.rs"] #[path = "js_unit_tests.rs"]
mod js_unit_tests; mod js_unit_tests;
#[path = "js_unit_tests_future.rs"]
mod js_unit_tests_future;
#[path = "jsr_tests.rs"] #[path = "jsr_tests.rs"]
mod jsr; mod jsr;
#[path = "jupyter_tests.rs"] #[path = "jupyter_tests.rs"]

View file

@ -10,6 +10,7 @@ import {
assertEquals, assertEquals,
assertRejects, assertRejects,
assertThrows, assertThrows,
DENO_FUTURE,
} from "./test_util.ts"; } from "./test_util.ts";
import { writeAllSync } from "@std/io/write-all"; import { writeAllSync } from "@std/io/write-all";
@ -87,7 +88,7 @@ function repeat(c: string, bytes: number): Uint8Array {
return ui8; return ui8;
} }
Deno.test(function bufferNewBuffer() { Deno.test({ ignore: DENO_FUTURE }, function bufferNewBuffer() {
init(); init();
assert(testBytes); assert(testBytes);
assert(testString); assert(testString);
@ -95,7 +96,7 @@ Deno.test(function bufferNewBuffer() {
check(buf, testString); check(buf, testString);
}); });
Deno.test(async function bufferBasicOperations() { Deno.test({ ignore: DENO_FUTURE }, async function bufferBasicOperations() {
init(); init();
assert(testBytes); assert(testBytes);
assert(testString); assert(testString);
@ -135,7 +136,7 @@ Deno.test(async function bufferBasicOperations() {
} }
}); });
Deno.test(async function bufferReadEmptyAtEOF() { Deno.test({ ignore: DENO_FUTURE }, async function bufferReadEmptyAtEOF() {
// check that EOF of 'buf' is not reached (even though it's empty) if // check that EOF of 'buf' is not reached (even though it's empty) if
// results are written to buffer that has 0 length (ie. it can't store any data) // results are written to buffer that has 0 length (ie. it can't store any data)
const buf = new Deno.Buffer(); const buf = new Deno.Buffer();
@ -144,7 +145,7 @@ Deno.test(async function bufferReadEmptyAtEOF() {
assertEquals(result, 0); assertEquals(result, 0);
}); });
Deno.test(async function bufferLargeByteWrites() { Deno.test({ ignore: DENO_FUTURE }, async function bufferLargeByteWrites() {
init(); init();
const buf = new Deno.Buffer(); const buf = new Deno.Buffer();
const limit = 9; const limit = 9;
@ -155,7 +156,7 @@ Deno.test(async function bufferLargeByteWrites() {
check(buf, ""); check(buf, "");
}); });
Deno.test(async function bufferTooLargeByteWrites() { Deno.test({ ignore: DENO_FUTURE }, async function bufferTooLargeByteWrites() {
init(); init();
const tmp = new Uint8Array(72); const tmp = new Uint8Array(72);
const growLen = Number.MAX_VALUE; const growLen = Number.MAX_VALUE;
@ -173,7 +174,7 @@ Deno.test(async function bufferTooLargeByteWrites() {
}); });
Deno.test( Deno.test(
{ ignore: ignoreMaxSizeTests }, { ignore: ignoreMaxSizeTests || DENO_FUTURE },
function bufferGrowWriteMaxBuffer() { function bufferGrowWriteMaxBuffer() {
const bufSize = 16 * 1024; const bufSize = 16 * 1024;
const capacities = [MAX_SIZE, MAX_SIZE - 1]; const capacities = [MAX_SIZE, MAX_SIZE - 1];
@ -195,7 +196,7 @@ Deno.test(
); );
Deno.test( Deno.test(
{ ignore: ignoreMaxSizeTests }, { ignore: ignoreMaxSizeTests || DENO_FUTURE },
async function bufferGrowReadCloseMaxBufferPlus1() { async function bufferGrowReadCloseMaxBufferPlus1() {
const reader = new Deno.Buffer(new ArrayBuffer(MAX_SIZE + 1)); const reader = new Deno.Buffer(new ArrayBuffer(MAX_SIZE + 1));
const buf = new Deno.Buffer(); const buf = new Deno.Buffer();
@ -211,7 +212,7 @@ Deno.test(
); );
Deno.test( Deno.test(
{ ignore: ignoreMaxSizeTests }, { ignore: ignoreMaxSizeTests || DENO_FUTURE },
function bufferGrowReadSyncCloseMaxBufferPlus1() { function bufferGrowReadSyncCloseMaxBufferPlus1() {
const reader = new Deno.Buffer(new ArrayBuffer(MAX_SIZE + 1)); const reader = new Deno.Buffer(new ArrayBuffer(MAX_SIZE + 1));
const buf = new Deno.Buffer(); const buf = new Deno.Buffer();
@ -227,7 +228,7 @@ Deno.test(
); );
Deno.test( Deno.test(
{ ignore: ignoreMaxSizeTests }, { ignore: ignoreMaxSizeTests || DENO_FUTURE },
function bufferGrowReadSyncCloseToMaxBuffer() { function bufferGrowReadSyncCloseToMaxBuffer() {
const capacities = [MAX_SIZE, MAX_SIZE - 1]; const capacities = [MAX_SIZE, MAX_SIZE - 1];
for (const capacity of capacities) { for (const capacity of capacities) {
@ -241,7 +242,7 @@ Deno.test(
); );
Deno.test( Deno.test(
{ ignore: ignoreMaxSizeTests }, { ignore: ignoreMaxSizeTests || DENO_FUTURE },
async function bufferGrowReadCloseToMaxBuffer() { async function bufferGrowReadCloseToMaxBuffer() {
const capacities = [MAX_SIZE, MAX_SIZE - 1]; const capacities = [MAX_SIZE, MAX_SIZE - 1];
for (const capacity of capacities) { for (const capacity of capacities) {
@ -254,7 +255,7 @@ Deno.test(
); );
Deno.test( Deno.test(
{ ignore: ignoreMaxSizeTests }, { ignore: ignoreMaxSizeTests || DENO_FUTURE },
async function bufferReadCloseToMaxBufferWithInitialGrow() { async function bufferReadCloseToMaxBufferWithInitialGrow() {
const capacities = [MAX_SIZE, MAX_SIZE - 1, MAX_SIZE - 512]; const capacities = [MAX_SIZE, MAX_SIZE - 1, MAX_SIZE - 512];
for (const capacity of capacities) { for (const capacity of capacities) {
@ -267,7 +268,7 @@ Deno.test(
}, },
); );
Deno.test(async function bufferLargeByteReads() { Deno.test({ ignore: DENO_FUTURE }, async function bufferLargeByteReads() {
init(); init();
assert(testBytes); assert(testBytes);
assert(testString); assert(testString);
@ -280,12 +281,12 @@ Deno.test(async function bufferLargeByteReads() {
check(buf, ""); check(buf, "");
}); });
Deno.test(function bufferCapWithPreallocatedSlice() { Deno.test({ ignore: DENO_FUTURE }, function bufferCapWithPreallocatedSlice() {
const buf = new Deno.Buffer(new ArrayBuffer(10)); const buf = new Deno.Buffer(new ArrayBuffer(10));
assertEquals(buf.capacity, 10); assertEquals(buf.capacity, 10);
}); });
Deno.test(async function bufferReadFrom() { Deno.test({ ignore: DENO_FUTURE }, async function bufferReadFrom() {
init(); init();
assert(testBytes); assert(testBytes);
assert(testString); assert(testString);
@ -307,7 +308,7 @@ Deno.test(async function bufferReadFrom() {
}); });
}); });
Deno.test(async function bufferReadFromSync() { Deno.test({ ignore: DENO_FUTURE }, async function bufferReadFromSync() {
init(); init();
assert(testBytes); assert(testBytes);
assert(testString); assert(testString);
@ -329,7 +330,7 @@ Deno.test(async function bufferReadFromSync() {
}); });
}); });
Deno.test(async function bufferTestGrow() { Deno.test({ ignore: DENO_FUTURE }, async function bufferTestGrow() {
const tmp = new Uint8Array(72); const tmp = new Uint8Array(72);
for (const startLen of [0, 100, 1000, 10000]) { for (const startLen of [0, 100, 1000, 10000]) {
const xBytes = repeat("x", startLen); const xBytes = repeat("x", startLen);
@ -353,7 +354,7 @@ Deno.test(async function bufferTestGrow() {
} }
}); });
Deno.test(async function testReadAll() { Deno.test({ ignore: DENO_FUTURE }, async function testReadAll() {
init(); init();
assert(testBytes); assert(testBytes);
const reader = new Deno.Buffer(testBytes.buffer as ArrayBuffer); const reader = new Deno.Buffer(testBytes.buffer as ArrayBuffer);
@ -364,7 +365,7 @@ Deno.test(async function testReadAll() {
} }
}); });
Deno.test(function testReadAllSync() { Deno.test({ ignore: DENO_FUTURE }, function testReadAllSync() {
init(); init();
assert(testBytes); assert(testBytes);
const reader = new Deno.Buffer(testBytes.buffer as ArrayBuffer); const reader = new Deno.Buffer(testBytes.buffer as ArrayBuffer);
@ -375,7 +376,7 @@ Deno.test(function testReadAllSync() {
} }
}); });
Deno.test(async function testWriteAll() { Deno.test({ ignore: DENO_FUTURE }, async function testWriteAll() {
init(); init();
assert(testBytes); assert(testBytes);
const writer = new Deno.Buffer(); const writer = new Deno.Buffer();
@ -387,7 +388,7 @@ Deno.test(async function testWriteAll() {
} }
}); });
Deno.test(function testWriteAllSync() { Deno.test({ ignore: DENO_FUTURE }, function testWriteAllSync() {
init(); init();
assert(testBytes); assert(testBytes);
const writer = new Deno.Buffer(); const writer = new Deno.Buffer();
@ -399,7 +400,7 @@ Deno.test(function testWriteAllSync() {
} }
}); });
Deno.test(function testBufferBytesArrayBufferLength() { Deno.test({ ignore: DENO_FUTURE }, function testBufferBytesArrayBufferLength() {
// defaults to copy // defaults to copy
const args = [{}, { copy: undefined }, undefined, { copy: true }]; const args = [{}, { copy: undefined }, undefined, { copy: true }];
for (const arg of args) { for (const arg of args) {
@ -418,7 +419,7 @@ Deno.test(function testBufferBytesArrayBufferLength() {
} }
}); });
Deno.test(function testBufferBytesCopyFalse() { Deno.test({ ignore: DENO_FUTURE }, function testBufferBytesCopyFalse() {
const bufSize = 64 * 1024; const bufSize = 64 * 1024;
const bytes = new TextEncoder().encode("a".repeat(bufSize)); const bytes = new TextEncoder().encode("a".repeat(bufSize));
const reader = new Deno.Buffer(); const reader = new Deno.Buffer();
@ -433,7 +434,9 @@ Deno.test(function testBufferBytesCopyFalse() {
assert(actualBytes.buffer.byteLength > actualBytes.byteLength); assert(actualBytes.buffer.byteLength > actualBytes.byteLength);
}); });
Deno.test(function testBufferBytesCopyFalseGrowExactBytes() { Deno.test(
{ ignore: DENO_FUTURE },
function testBufferBytesCopyFalseGrowExactBytes() {
const bufSize = 64 * 1024; const bufSize = 64 * 1024;
const bytes = new TextEncoder().encode("a".repeat(bufSize)); const bytes = new TextEncoder().encode("a".repeat(bufSize));
const reader = new Deno.Buffer(); const reader = new Deno.Buffer();
@ -446,9 +449,12 @@ Deno.test(function testBufferBytesCopyFalseGrowExactBytes() {
assertEquals(actualBytes.byteLength, bufSize); assertEquals(actualBytes.byteLength, bufSize);
assertEquals(actualBytes.buffer.byteLength, actualBytes.byteLength); assertEquals(actualBytes.buffer.byteLength, actualBytes.byteLength);
}); },
);
Deno.test(function testThrowsErrorWhenBufferExceedsMaxLength() { Deno.test(
{ ignore: DENO_FUTURE },
function testThrowsErrorWhenBufferExceedsMaxLength() {
const kStringMaxLengthPlusOne = 536870888 + 1; const kStringMaxLengthPlusOne = 536870888 + 1;
const bytes = new Uint8Array(kStringMaxLengthPlusOne); const bytes = new Uint8Array(kStringMaxLengthPlusOne);
@ -459,4 +465,5 @@ Deno.test(function testThrowsErrorWhenBufferExceedsMaxLength() {
TypeError, TypeError,
"buffer exceeds maximum length", "buffer exceeds maximum length",
); );
}); },
);

View file

@ -9,6 +9,7 @@ import {
assertStringIncludes, assertStringIncludes,
assertThrows, assertThrows,
delay, delay,
DENO_FUTURE,
fail, fail,
unimplemented, unimplemented,
} from "./test_util.ts"; } from "./test_util.ts";
@ -1358,7 +1359,7 @@ Deno.test(
); );
Deno.test( Deno.test(
{ permissions: { read: true, net: true } }, { permissions: { read: true, net: true }, ignore: DENO_FUTURE },
async function fetchCustomClientPrivateKey(): Promise< async function fetchCustomClientPrivateKey(): Promise<
void void
> { > {

View file

@ -7,6 +7,7 @@ import {
assertEquals, assertEquals,
assertRejects, assertRejects,
assertThrows, assertThrows,
DENO_FUTURE,
} from "./test_util.ts"; } from "./test_util.ts";
import { copy } from "@std/io/copy"; import { copy } from "@std/io/copy";
@ -18,7 +19,9 @@ Deno.test(function filesStdioFileDescriptors() {
assertEquals(Deno.stderr.rid, 2); assertEquals(Deno.stderr.rid, 2);
}); });
Deno.test({ permissions: { read: true } }, async function filesCopyToStdout() { Deno.test(
{ ignore: DENO_FUTURE, permissions: { read: true } },
async function filesCopyToStdout() {
const filename = "tests/testdata/assets/fixture.json"; const filename = "tests/testdata/assets/fixture.json";
using file = await Deno.open(filename); using file = await Deno.open(filename);
assert(file instanceof Deno.File); assert(file instanceof Deno.File);
@ -27,9 +30,12 @@ Deno.test({ permissions: { read: true } }, async function filesCopyToStdout() {
const bytesWritten = await copy(file, Deno.stdout); const bytesWritten = await copy(file, Deno.stdout);
const fileSize = Deno.statSync(filename).size; const fileSize = Deno.statSync(filename).size;
assertEquals(bytesWritten, fileSize); assertEquals(bytesWritten, fileSize);
}); },
);
Deno.test({ permissions: { read: true } }, async function filesIter() { Deno.test(
{ ignore: DENO_FUTURE, permissions: { read: true } },
async function filesIter() {
const filename = "tests/testdata/assets/hello.txt"; const filename = "tests/testdata/assets/hello.txt";
using file = await Deno.open(filename); using file = await Deno.open(filename);
@ -39,10 +45,11 @@ Deno.test({ permissions: { read: true } }, async function filesIter() {
} }
assertEquals(totalSize, 12); assertEquals(totalSize, 12);
}); },
);
Deno.test( Deno.test(
{ permissions: { read: true } }, { ignore: DENO_FUTURE, permissions: { read: true } },
async function filesIterCustomBufSize() { async function filesIterCustomBufSize() {
const filename = "tests/testdata/assets/hello.txt"; const filename = "tests/testdata/assets/hello.txt";
using file = await Deno.open(filename); using file = await Deno.open(filename);
@ -59,7 +66,9 @@ Deno.test(
}, },
); );
Deno.test({ permissions: { read: true } }, function filesIterSync() { Deno.test(
{ ignore: DENO_FUTURE, permissions: { read: true } },
function filesIterSync() {
const filename = "tests/testdata/assets/hello.txt"; const filename = "tests/testdata/assets/hello.txt";
using file = Deno.openSync(filename); using file = Deno.openSync(filename);
@ -69,10 +78,11 @@ Deno.test({ permissions: { read: true } }, function filesIterSync() {
} }
assertEquals(totalSize, 12); assertEquals(totalSize, 12);
}); },
);
Deno.test( Deno.test(
{ permissions: { read: true } }, { ignore: DENO_FUTURE, permissions: { read: true } },
function filesIterSyncCustomBufSize() { function filesIterSyncCustomBufSize() {
const filename = "tests/testdata/assets/hello.txt"; const filename = "tests/testdata/assets/hello.txt";
using file = Deno.openSync(filename); using file = Deno.openSync(filename);
@ -89,7 +99,7 @@ Deno.test(
}, },
); );
Deno.test(async function readerIter() { Deno.test({ ignore: DENO_FUTURE }, async function readerIter() {
// ref: https://github.com/denoland/deno/issues/2330 // ref: https://github.com/denoland/deno/issues/2330
const encoder = new TextEncoder(); const encoder = new TextEncoder();
@ -124,7 +134,7 @@ Deno.test(async function readerIter() {
assertEquals(totalSize, 12); assertEquals(totalSize, 12);
}); });
Deno.test(async function readerIterSync() { Deno.test({ ignore: DENO_FUTURE }, async function readerIterSync() {
// ref: https://github.com/denoland/deno/issues/2330 // ref: https://github.com/denoland/deno/issues/2330
const encoder = new TextEncoder(); const encoder = new TextEncoder();

View file

@ -1,15 +1,15 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { assertEquals } from "./test_util.ts"; import { assertEquals, DENO_FUTURE } from "./test_util.ts";
Deno.test( Deno.test(
{ permissions: { read: true, run: true, hrtime: true } }, { ignore: DENO_FUTURE, permissions: { read: true, run: true, hrtime: true } },
async function flockFileSync() { async function flockFileSync() {
await runFlockTests({ sync: true }); await runFlockTests({ sync: true });
}, },
); );
Deno.test( Deno.test(
{ permissions: { read: true, run: true, hrtime: true } }, { ignore: DENO_FUTURE, permissions: { read: true, run: true, hrtime: true } },
async function flockFileAsync() { async function flockFileAsync() {
await runFlockTests({ sync: false }); await runFlockTests({ sync: false });
}, },

View file

@ -6,6 +6,7 @@ import {
assertEquals, assertEquals,
assertRejects, assertRejects,
assertThrows, assertThrows,
DENO_FUTURE,
} from "./test_util.ts"; } from "./test_util.ts";
Deno.test(function globalThisExists() { Deno.test(function globalThisExists() {
@ -19,7 +20,7 @@ Deno.test(function noInternalGlobals() {
} }
}); });
Deno.test(function windowExists() { Deno.test({ ignore: DENO_FUTURE }, function windowExists() {
assert(window != null); assert(window != null);
}); });
@ -27,15 +28,15 @@ Deno.test(function selfExists() {
assert(self != null); assert(self != null);
}); });
Deno.test(function windowWindowExists() { Deno.test({ ignore: DENO_FUTURE }, function windowWindowExists() {
assert(window.window === window); assert(window.window === window);
}); });
Deno.test(function windowSelfExists() { Deno.test({ ignore: DENO_FUTURE }, function windowSelfExists() {
assert(window.self === window); assert(window.self === window);
}); });
Deno.test(function globalThisEqualsWindow() { Deno.test({ ignore: DENO_FUTURE }, function globalThisEqualsWindow() {
assert(globalThis === window); assert(globalThis === window);
}); });
@ -43,7 +44,7 @@ Deno.test(function globalThisEqualsSelf() {
assert(globalThis === self); assert(globalThis === self);
}); });
Deno.test(function globalThisInstanceofWindow() { Deno.test({ ignore: DENO_FUTURE }, function globalThisInstanceofWindow() {
assert(globalThis instanceof Window); assert(globalThis instanceof Window);
}); });
@ -65,7 +66,7 @@ Deno.test(function DenoNamespaceExists() {
assert(Deno != null); assert(Deno != null);
}); });
Deno.test(function DenoNamespaceEqualsWindowDeno() { Deno.test({ ignore: DENO_FUTURE }, function DenoNamespaceEqualsWindowDeno() {
assert(Deno === window.Deno); assert(Deno === window.Deno);
}); });
@ -119,7 +120,11 @@ Deno.test(async function windowQueueMicrotask() {
res(); res();
}; };
}); });
if (DENO_FUTURE) {
globalThis.queueMicrotask(resolve1!);
} else {
window.queueMicrotask(resolve1!); window.queueMicrotask(resolve1!);
}
setTimeout(resolve2!, 0); setTimeout(resolve2!, 0);
await p1; await p1;
await p2; await p2;
@ -138,12 +143,18 @@ Deno.test(function webApiGlobalThis() {
Deno.test(function windowNameIsDefined() { Deno.test(function windowNameIsDefined() {
assertEquals(typeof globalThis.name, "string"); assertEquals(typeof globalThis.name, "string");
assertEquals(name, ""); assertEquals(name, "");
if (!DENO_FUTURE) {
assertEquals(window.name, name); assertEquals(window.name, name);
}
name = "foobar"; name = "foobar";
if (!DENO_FUTURE) {
assertEquals(window.name, "foobar"); assertEquals(window.name, "foobar");
}
assertEquals(name, "foobar"); assertEquals(name, "foobar");
name = ""; name = "";
if (!DENO_FUTURE) {
assertEquals(window.name, ""); assertEquals(window.name, "");
}
assertEquals(name, ""); assertEquals(name, "");
}); });

View file

@ -1,5 +1,5 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { assertEquals } from "./test_util.ts"; import { assertEquals, DENO_FUTURE } from "./test_util.ts";
import { Buffer } from "@std/io/buffer"; import { Buffer } from "@std/io/buffer";
const DEFAULT_BUF_SIZE = 32 * 1024; const DEFAULT_BUF_SIZE = 32 * 1024;
@ -28,7 +28,7 @@ function spyRead(obj: Buffer): Spy {
return spy; return spy;
} }
Deno.test(async function copyWithDefaultBufferSize() { Deno.test({ ignore: DENO_FUTURE }, async function copyWithDefaultBufferSize() {
const xBytes = repeat("b", DEFAULT_BUF_SIZE); const xBytes = repeat("b", DEFAULT_BUF_SIZE);
const reader = new Buffer(xBytes.buffer as ArrayBuffer); const reader = new Buffer(xBytes.buffer as ArrayBuffer);
const write = new Buffer(); const write = new Buffer();
@ -43,7 +43,7 @@ Deno.test(async function copyWithDefaultBufferSize() {
assertEquals(readSpy.calls, 2); // read with DEFAULT_BUF_SIZE bytes + read with 0 bytes assertEquals(readSpy.calls, 2); // read with DEFAULT_BUF_SIZE bytes + read with 0 bytes
}); });
Deno.test(async function copyWithCustomBufferSize() { Deno.test({ ignore: DENO_FUTURE }, async function copyWithCustomBufferSize() {
const bufSize = 1024; const bufSize = 1024;
const xBytes = repeat("b", DEFAULT_BUF_SIZE); const xBytes = repeat("b", DEFAULT_BUF_SIZE);
const reader = new Buffer(xBytes.buffer as ArrayBuffer); const reader = new Buffer(xBytes.buffer as ArrayBuffer);
@ -59,7 +59,9 @@ Deno.test(async function copyWithCustomBufferSize() {
assertEquals(readSpy.calls, DEFAULT_BUF_SIZE / bufSize + 1); assertEquals(readSpy.calls, DEFAULT_BUF_SIZE / bufSize + 1);
}); });
Deno.test({ permissions: { write: true } }, async function copyBufferToFile() { Deno.test(
{ ignore: DENO_FUTURE, permissions: { write: true } },
async function copyBufferToFile() {
const filePath = "test-file.txt"; const filePath = "test-file.txt";
// bigger than max File possible buffer 16kb // bigger than max File possible buffer 16kb
const bufSize = 32 * 1024; const bufSize = 32 * 1024;
@ -74,4 +76,5 @@ Deno.test({ permissions: { write: true } }, async function copyBufferToFile() {
write.close(); write.close();
await Deno.remove(filePath); await Deno.remove(filePath);
}); },
);

View file

@ -6,6 +6,7 @@ import {
assertRejects, assertRejects,
assertThrows, assertThrows,
delay, delay,
DENO_FUTURE,
execCode, execCode,
execCode2, execCode2,
tmpUnixSocketPath, tmpUnixSocketPath,
@ -27,7 +28,9 @@ Deno.test({ permissions: { net: true } }, function netTcpListenClose() {
assert(listener.addr.transport === "tcp"); assert(listener.addr.transport === "tcp");
assertEquals(listener.addr.hostname, "127.0.0.1"); assertEquals(listener.addr.hostname, "127.0.0.1");
assertEquals(listener.addr.port, listenPort); assertEquals(listener.addr.port, listenPort);
if (!DENO_FUTURE) {
assertNotEquals(listener.rid, 0); assertNotEquals(listener.rid, 0);
}
listener.close(); listener.close();
}); });
@ -233,7 +236,9 @@ Deno.test({ permissions: { net: true } }, async function netTcpDialListen() {
assertEquals(1, buf[0]); assertEquals(1, buf[0]);
assertEquals(2, buf[1]); assertEquals(2, buf[1]);
assertEquals(3, buf[2]); assertEquals(3, buf[2]);
if (!DENO_FUTURE) {
assert(conn.rid > 0); assert(conn.rid > 0);
}
assert(readResult !== null); assert(readResult !== null);
@ -269,7 +274,9 @@ Deno.test({ permissions: { net: true } }, async function netTcpSetNoDelay() {
assertEquals(1, buf[0]); assertEquals(1, buf[0]);
assertEquals(2, buf[1]); assertEquals(2, buf[1]);
assertEquals(3, buf[2]); assertEquals(3, buf[2]);
if (!DENO_FUTURE) {
assert(conn.rid > 0); assert(conn.rid > 0);
}
assert(readResult !== null); assert(readResult !== null);
@ -305,7 +312,9 @@ Deno.test({ permissions: { net: true } }, async function netTcpSetKeepAlive() {
assertEquals(1, buf[0]); assertEquals(1, buf[0]);
assertEquals(2, buf[1]); assertEquals(2, buf[1]);
assertEquals(3, buf[2]); assertEquals(3, buf[2]);
if (!DENO_FUTURE) {
assert(conn.rid > 0); assert(conn.rid > 0);
}
assert(readResult !== null); assert(readResult !== null);
@ -343,7 +352,9 @@ Deno.test(
assertEquals(1, buf[0]); assertEquals(1, buf[0]);
assertEquals(2, buf[1]); assertEquals(2, buf[1]);
assertEquals(3, buf[2]); assertEquals(3, buf[2]);
if (!DENO_FUTURE) {
assert(conn.rid > 0); assert(conn.rid > 0);
}
assert(readResult !== null); assert(readResult !== null);
@ -839,7 +850,9 @@ Deno.test(
assertEquals(1, buf[0]); assertEquals(1, buf[0]);
assertEquals(2, buf[1]); assertEquals(2, buf[1]);
assertEquals(3, buf[2]); assertEquals(3, buf[2]);
if (!DENO_FUTURE) {
assert(conn.rid > 0); assert(conn.rid > 0);
}
assert(readResult !== null); assert(readResult !== null);

View file

@ -5,6 +5,7 @@ import {
assertStrictEquals, assertStrictEquals,
assertStringIncludes, assertStringIncludes,
assertThrows, assertThrows,
DENO_FUTURE,
} from "./test_util.ts"; } from "./test_util.ts";
Deno.test( Deno.test(
@ -363,7 +364,11 @@ Deno.test(
); );
Deno.test( Deno.test(
{ permissions: { run: true, write: true, read: true } }, {
// Ignoring because uses `file.rid`
ignore: DENO_FUTURE,
permissions: { run: true, write: true, read: true },
},
async function runRedirectStdoutStderr() { async function runRedirectStdoutStderr() {
const tempDir = await Deno.makeTempDir(); const tempDir = await Deno.makeTempDir();
const fileName = tempDir + "/redirected_stdio.txt"; const fileName = tempDir + "/redirected_stdio.txt";
@ -392,11 +397,16 @@ Deno.test(
assertStringIncludes(text, "error"); assertStringIncludes(text, "error");
assertStringIncludes(text, "output"); assertStringIncludes(text, "output");
console.log("finished tgis test");
}, },
); );
Deno.test( Deno.test(
{ permissions: { run: true, write: true, read: true } }, {
// Ignoring because uses `file.rid`
ignore: DENO_FUTURE,
permissions: { run: true, write: true, read: true },
},
async function runRedirectStdin() { async function runRedirectStdin() {
const tempDir = await Deno.makeTempDir(); const tempDir = await Deno.makeTempDir();
const fileName = tempDir + "/redirected_stdio.txt"; const fileName = tempDir + "/redirected_stdio.txt";

View file

@ -2,7 +2,12 @@
// deno-lint-ignore-file no-deprecated-deno-api // deno-lint-ignore-file no-deprecated-deno-api
import { assert, assertEquals, assertThrows } from "./test_util.ts"; import {
assert,
assertEquals,
assertThrows,
DENO_FUTURE,
} from "./test_util.ts";
const listenPort = 4505; const listenPort = 4505;
@ -12,7 +17,7 @@ Deno.test(function resourcesCloseBadArgs() {
}, TypeError); }, TypeError);
}); });
Deno.test(function resourcesStdio() { Deno.test({ ignore: DENO_FUTURE }, function resourcesStdio() {
const res = Deno.resources(); const res = Deno.resources();
assertEquals(res[0], "stdin"); assertEquals(res[0], "stdin");
@ -20,7 +25,9 @@ Deno.test(function resourcesStdio() {
assertEquals(res[2], "stderr"); assertEquals(res[2], "stderr");
}); });
Deno.test({ permissions: { net: true } }, async function resourcesNet() { Deno.test(
{ ignore: DENO_FUTURE, permissions: { net: true } },
async function resourcesNet() {
const listener = Deno.listen({ port: listenPort }); const listener = Deno.listen({ port: listenPort });
const dialerConn = await Deno.connect({ port: listenPort }); const dialerConn = await Deno.connect({ port: listenPort });
const listenerConn = await listener.accept(); const listenerConn = await listener.accept();
@ -38,9 +45,12 @@ Deno.test({ permissions: { net: true } }, async function resourcesNet() {
listenerConn.close(); listenerConn.close();
dialerConn.close(); dialerConn.close();
listener.close(); listener.close();
}); },
);
Deno.test({ permissions: { read: true } }, async function resourcesFile() { Deno.test(
{ ignore: DENO_FUTURE, permissions: { read: true } },
async function resourcesFile() {
const resourcesBefore = Deno.resources(); const resourcesBefore = Deno.resources();
const f = await Deno.open("tests/testdata/assets/hello.txt"); const f = await Deno.open("tests/testdata/assets/hello.txt");
const resourcesAfter = Deno.resources(); const resourcesAfter = Deno.resources();
@ -55,4 +65,5 @@ Deno.test({ permissions: { read: true } }, async function resourcesFile() {
return !Object.prototype.hasOwnProperty.call(resourcesBefore, rid); return !Object.prototype.hasOwnProperty.call(resourcesBefore, rid);
})!; })!;
assertEquals(resourcesAfter[newRid], "fsFile"); assertEquals(resourcesAfter[newRid], "fsFile");
}); },
);

View file

@ -12,6 +12,7 @@ import {
assertThrows, assertThrows,
curlRequest, curlRequest,
curlRequestWithStdErr, curlRequestWithStdErr,
DENO_FUTURE,
execCode, execCode,
execCode3, execCode3,
fail, fail,
@ -19,7 +20,7 @@ import {
} from "./test_util.ts"; } from "./test_util.ts";
// Since these tests may run in parallel, ensure this port is unique to this file // Since these tests may run in parallel, ensure this port is unique to this file
const servePort = 4502; const servePort = DENO_FUTURE ? 4511 : 4502;
const { const {
upgradeHttpRaw, upgradeHttpRaw,

View file

@ -7,10 +7,13 @@ import {
assertEquals, assertEquals,
assertRejects, assertRejects,
assertThrows, assertThrows,
DENO_FUTURE,
pathToAbsoluteFileUrl, pathToAbsoluteFileUrl,
} from "./test_util.ts"; } from "./test_util.ts";
Deno.test({ permissions: { read: true } }, function fstatSyncSuccess() { Deno.test(
{ ignore: DENO_FUTURE, permissions: { read: true } },
function fstatSyncSuccess() {
using file = Deno.openSync("README.md"); using file = Deno.openSync("README.md");
const fileInfo = Deno.fstatSync(file.rid); const fileInfo = Deno.fstatSync(file.rid);
assert(fileInfo.isFile); assert(fileInfo.isFile);
@ -21,9 +24,12 @@ Deno.test({ permissions: { read: true } }, function fstatSyncSuccess() {
assert(fileInfo.mtime); assert(fileInfo.mtime);
// The `birthtime` field is not available on Linux before kernel version 4.11. // The `birthtime` field is not available on Linux before kernel version 4.11.
assert(fileInfo.birthtime || Deno.build.os === "linux"); assert(fileInfo.birthtime || Deno.build.os === "linux");
}); },
);
Deno.test({ permissions: { read: true } }, async function fstatSuccess() { Deno.test(
{ ignore: DENO_FUTURE, permissions: { read: true } },
async function fstatSuccess() {
using file = await Deno.open("README.md"); using file = await Deno.open("README.md");
const fileInfo = await Deno.fstat(file.rid); const fileInfo = await Deno.fstat(file.rid);
assert(fileInfo.isFile); assert(fileInfo.isFile);
@ -34,7 +40,8 @@ Deno.test({ permissions: { read: true } }, async function fstatSuccess() {
assert(fileInfo.mtime); assert(fileInfo.mtime);
// The `birthtime` field is not available on Linux before kernel version 4.11. // The `birthtime` field is not available on Linux before kernel version 4.11.
assert(fileInfo.birthtime || Deno.build.os === "linux"); assert(fileInfo.birthtime || Deno.build.os === "linux");
}); },
);
Deno.test( Deno.test(
{ permissions: { read: true, write: true } }, { permissions: { read: true, write: true } },

View file

@ -1,8 +1,8 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { assertEquals } from "./test_util.ts"; import { assertEquals, DENO_FUTURE } from "./test_util.ts";
Deno.test( Deno.test(
{ permissions: { read: true, write: true } }, { ignore: DENO_FUTURE, permissions: { read: true, write: true } },
function fdatasyncSyncSuccess() { function fdatasyncSyncSuccess() {
const filename = Deno.makeTempDirSync() + "/test_fdatasyncSync.txt"; const filename = Deno.makeTempDirSync() + "/test_fdatasyncSync.txt";
using file = Deno.openSync(filename, { using file = Deno.openSync(filename, {
@ -18,7 +18,7 @@ Deno.test(
); );
Deno.test( Deno.test(
{ permissions: { read: true, write: true } }, { ignore: DENO_FUTURE, permissions: { read: true, write: true } },
async function fdatasyncSuccess() { async function fdatasyncSuccess() {
const filename = (await Deno.makeTempDir()) + "/test_fdatasync.txt"; const filename = (await Deno.makeTempDir()) + "/test_fdatasync.txt";
using file = await Deno.open(filename, { using file = await Deno.open(filename, {
@ -35,7 +35,7 @@ Deno.test(
); );
Deno.test( Deno.test(
{ permissions: { read: true, write: true } }, { ignore: DENO_FUTURE, permissions: { read: true, write: true } },
function fsyncSyncSuccess() { function fsyncSyncSuccess() {
const filename = Deno.makeTempDirSync() + "/test_fsyncSync.txt"; const filename = Deno.makeTempDirSync() + "/test_fsyncSync.txt";
using file = Deno.openSync(filename, { using file = Deno.openSync(filename, {
@ -52,7 +52,7 @@ Deno.test(
); );
Deno.test( Deno.test(
{ permissions: { read: true, write: true } }, { ignore: DENO_FUTURE, permissions: { read: true, write: true } },
async function fsyncSuccess() { async function fsyncSuccess() {
const filename = (await Deno.makeTempDir()) + "/test_fsync.txt"; const filename = (await Deno.makeTempDir()) + "/test_fsync.txt";
using file = await Deno.open(filename, { using file = await Deno.open(filename, {

View file

@ -25,6 +25,8 @@ export { delay } from "@std/async/delay";
export { readLines } from "@std/io/read-lines"; export { readLines } from "@std/io/read-lines";
export { parseArgs } from "@std/cli/parse-args"; export { parseArgs } from "@std/cli/parse-args";
export const DENO_FUTURE = Deno.env.get("DENO_FUTURE") === "1";
export function pathToAbsoluteFileUrl(path: string): URL { export function pathToAbsoluteFileUrl(path: string): URL {
path = resolve(path); path = resolve(path);

View file

@ -7,6 +7,7 @@ import {
assertEquals, assertEquals,
assertNotEquals, assertNotEquals,
delay, delay,
DENO_FUTURE,
execCode, execCode,
unreachable, unreachable,
} from "./test_util.ts"; } from "./test_util.ts";
@ -311,11 +312,63 @@ Deno.test(async function timeoutCallbackThis() {
}; };
setTimeout(obj.foo, 1); setTimeout(obj.foo, 1);
await promise; await promise;
if (!DENO_FUTURE) {
assertEquals(capturedThis, window); assertEquals(capturedThis, window);
} else {
assertEquals(capturedThis, globalThis);
}
}); });
Deno.test(async function timeoutBindThis() { Deno.test({ ignore: DENO_FUTURE }, async function timeoutBindThis() {
const thisCheckPassed = [null, undefined, window, globalThis]; const thisCheckPassed = [null, undefined, globalThis, window];
const thisCheckFailed = [
0,
"",
true,
false,
{},
[],
"foo",
() => {},
Object.prototype,
];
for (const thisArg of thisCheckPassed) {
const { promise, resolve } = Promise.withResolvers<void>();
let hasThrown = 0;
try {
setTimeout.call(thisArg, () => resolve(), 1);
hasThrown = 1;
} catch (err) {
if (err instanceof TypeError) {
hasThrown = 2;
} else {
hasThrown = 3;
}
}
await promise;
assertEquals(hasThrown, 1);
}
for (const thisArg of thisCheckFailed) {
let hasThrown = 0;
try {
setTimeout.call(thisArg, () => {}, 1);
hasThrown = 1;
} catch (err) {
if (err instanceof TypeError) {
hasThrown = 2;
} else {
hasThrown = 3;
}
}
assertEquals(hasThrown, 2);
}
});
Deno.test({ ignore: !DENO_FUTURE }, async function timeoutBindThis() {
const thisCheckPassed = [null, undefined, globalThis];
const thisCheckFailed = [ const thisCheckFailed = [
0, 0,

View file

@ -6,6 +6,7 @@ import {
assertRejects, assertRejects,
assertStrictEquals, assertStrictEquals,
assertThrows, assertThrows,
DENO_FUTURE,
} from "./test_util.ts"; } from "./test_util.ts";
import { BufReader, BufWriter } from "@std/io"; import { BufReader, BufWriter } from "@std/io";
import { readAll } from "@std/io/read-all"; import { readAll } from "@std/io/read-all";
@ -67,7 +68,7 @@ Deno.test(
); );
Deno.test( Deno.test(
{ permissions: { net: true, read: false } }, { permissions: { net: true, read: false }, ignore: DENO_FUTURE },
async function connectTLSCertFileNoReadPerm() { async function connectTLSCertFileNoReadPerm() {
await assertRejects(async () => { await assertRejects(async () => {
await Deno.connectTls({ await Deno.connectTls({
@ -80,7 +81,7 @@ Deno.test(
); );
Deno.test( Deno.test(
{ permissions: { read: true, net: true } }, { permissions: { read: true, net: true }, ignore: DENO_FUTURE },
function listenTLSNonExistentCertKeyFiles() { function listenTLSNonExistentCertKeyFiles() {
const options = { const options = {
hostname: "localhost", hostname: "localhost",
@ -106,7 +107,7 @@ Deno.test(
); );
Deno.test( Deno.test(
{ permissions: { net: true, read: false } }, { permissions: { net: true, read: false }, ignore: DENO_FUTURE },
function listenTLSNoReadPerm() { function listenTLSNoReadPerm() {
assertThrows(() => { assertThrows(() => {
Deno.listenTls({ Deno.listenTls({
@ -122,6 +123,7 @@ Deno.test(
Deno.test( Deno.test(
{ {
permissions: { read: true, write: true, net: true }, permissions: { read: true, write: true, net: true },
ignore: DENO_FUTURE,
}, },
function listenTLSEmptyKeyFile() { function listenTLSEmptyKeyFile() {
const options = { const options = {
@ -219,7 +221,7 @@ Deno.test(
); );
const conn = await Deno.connectTls({ hostname, port, caCerts }); const conn = await Deno.connectTls({ hostname, port, caCerts });
assert(conn.rid > 0); assert(DENO_FUTURE || conn.rid > 0);
const w = new BufWriter(conn); const w = new BufWriter(conn);
const r = new BufReader(conn); const r = new BufReader(conn);
const body = `GET / HTTP/1.1\r\nHost: ${hostname}:${port}\r\n\r\n`; const body = `GET / HTTP/1.1\r\nHost: ${hostname}:${port}\r\n\r\n`;
@ -271,7 +273,7 @@ Deno.test(
); );
const conn = await Deno.connectTls({ hostname, port, caCerts }); const conn = await Deno.connectTls({ hostname, port, caCerts });
assert(conn.rid > 0); assert(DENO_FUTURE || conn.rid > 0);
const w = new BufWriter(conn); const w = new BufWriter(conn);
const r = new BufReader(conn); const r = new BufReader(conn);
const body = `GET / HTTP/1.1\r\nHost: ${hostname}:${port}\r\n\r\n`; const body = `GET / HTTP/1.1\r\nHost: ${hostname}:${port}\r\n\r\n`;
@ -1146,7 +1148,7 @@ Deno.test(
); );
Deno.test( Deno.test(
{ permissions: { read: true, net: true } }, { permissions: { read: true, net: true }, ignore: DENO_FUTURE },
async function connectTLSBadClientCertPrivateKey(): Promise<void> { async function connectTLSBadClientCertPrivateKey(): Promise<void> {
await assertRejects(async () => { await assertRejects(async () => {
await Deno.connectTls({ await Deno.connectTls({
@ -1162,7 +1164,7 @@ Deno.test(
); );
Deno.test( Deno.test(
{ permissions: { read: true, net: true } }, { permissions: { read: true, net: true }, ignore: DENO_FUTURE },
async function connectTLSBadCertKey(): Promise<void> { async function connectTLSBadCertKey(): Promise<void> {
await assertRejects(async () => { await assertRejects(async () => {
await Deno.connectTls({ await Deno.connectTls({
@ -1178,7 +1180,7 @@ Deno.test(
); );
Deno.test( Deno.test(
{ permissions: { read: true, net: true } }, { permissions: { read: true, net: true }, ignore: DENO_FUTURE },
async function connectTLSBadPrivateKey(): Promise<void> { async function connectTLSBadPrivateKey(): Promise<void> {
await assertRejects(async () => { await assertRejects(async () => {
await Deno.connectTls({ await Deno.connectTls({
@ -1210,7 +1212,7 @@ Deno.test(
); );
Deno.test( Deno.test(
{ permissions: { read: true, net: true } }, { permissions: { read: true, net: true }, ignore: DENO_FUTURE },
async function connectTLSNotPrivateKey(): Promise<void> { async function connectTLSNotPrivateKey(): Promise<void> {
await assertRejects(async () => { await assertRejects(async () => {
await Deno.connectTls({ await Deno.connectTls({
@ -1226,7 +1228,7 @@ Deno.test(
); );
Deno.test( Deno.test(
{ permissions: { read: true, net: true } }, { permissions: { read: true, net: true }, ignore: DENO_FUTURE },
async function connectTLSNotKey(): Promise<void> { async function connectTLSNotKey(): Promise<void> {
await assertRejects(async () => { await assertRejects(async () => {
await Deno.connectTls({ await Deno.connectTls({
@ -1242,7 +1244,7 @@ Deno.test(
); );
Deno.test( Deno.test(
{ permissions: { read: true, net: true } }, { permissions: { read: true, net: true }, ignore: DENO_FUTURE },
async function connectWithClientCert() { async function connectWithClientCert() {
// The test_server running on port 4552 responds with 'PASS' if client // The test_server running on port 4552 responds with 'PASS' if client
// authentication was successful. Try it by running test_server and // authentication was successful. Try it by running test_server and
@ -1292,7 +1294,7 @@ Deno.test(
); );
Deno.test( Deno.test(
{ permissions: { read: true, net: true } }, { permissions: { read: true, net: true }, ignore: DENO_FUTURE },
async function connectTlsConflictingCertOptions(): Promise<void> { async function connectTlsConflictingCertOptions(): Promise<void> {
await assertRejects( await assertRejects(
async () => { async () => {
@ -1317,7 +1319,7 @@ Deno.test(
); );
Deno.test( Deno.test(
{ permissions: { read: true, net: true } }, { permissions: { read: true, net: true }, ignore: DENO_FUTURE },
async function connectTlsConflictingKeyOptions(): Promise<void> { async function connectTlsConflictingKeyOptions(): Promise<void> {
await assertRejects( await assertRejects(
async () => { async () => {
@ -1635,7 +1637,7 @@ Deno.test(
); );
Deno.test( Deno.test(
{ permissions: { net: true, read: true } }, { ignore: DENO_FUTURE, permissions: { net: true, read: true } },
function listenTLSEcKey() { function listenTLSEcKey() {
const listener = Deno.listenTls({ const listener = Deno.listenTls({
hostname: "localhost", hostname: "localhost",

View file

@ -2,7 +2,7 @@
// deno-lint-ignore-file no-deprecated-deno-api // deno-lint-ignore-file no-deprecated-deno-api
import { assert } from "./test_util.ts"; import { assert, DENO_FUTURE } from "./test_util.ts";
// Note tests for Deno.stdin.setRaw is in integration tests. // Note tests for Deno.stdin.setRaw is in integration tests.
@ -15,12 +15,15 @@ Deno.test(function consoleSize() {
assert(typeof result.rows !== "undefined"); assert(typeof result.rows !== "undefined");
}); });
Deno.test({ permissions: { read: true } }, function isatty() { Deno.test(
{ ignore: DENO_FUTURE, permissions: { read: true } },
function isatty() {
// CI not under TTY, so cannot test stdin/stdout/stderr. // CI not under TTY, so cannot test stdin/stdout/stderr.
const f = Deno.openSync("tests/testdata/assets/hello.txt"); const f = Deno.openSync("tests/testdata/assets/hello.txt");
assert(!Deno.isatty(f.rid)); assert(!Deno.isatty(f.rid));
f.close(); f.close();
}); },
);
Deno.test(function isattyError() { Deno.test(function isattyError() {
let caught = false; let caught = false;

View file

@ -6,11 +6,12 @@ import {
assertEquals, assertEquals,
assertRejects, assertRejects,
assertThrows, assertThrows,
DENO_FUTURE,
pathToAbsoluteFileUrl, pathToAbsoluteFileUrl,
} from "./test_util.ts"; } from "./test_util.ts";
Deno.test( Deno.test(
{ permissions: { read: true, write: true } }, { ignore: DENO_FUTURE, permissions: { read: true, write: true } },
async function futimeSyncSuccess() { async function futimeSyncSuccess() {
const testDir = await Deno.makeTempDir(); const testDir = await Deno.makeTempDir();
const filename = testDir + "/file.txt"; const filename = testDir + "/file.txt";
@ -52,7 +53,7 @@ Deno.test(
); );
Deno.test( Deno.test(
{ permissions: { read: true, write: true } }, { ignore: DENO_FUTURE, permissions: { read: true, write: true } },
function futimeSyncSuccess() { function futimeSyncSuccess() {
const testDir = Deno.makeTempDirSync(); const testDir = Deno.makeTempDirSync();
const filename = testDir + "/file.txt"; const filename = testDir + "/file.txt";

View file

@ -9,7 +9,7 @@ import {
// https://github.com/denoland/deno/issues/11664 // https://github.com/denoland/deno/issues/11664
Deno.test(async function testImportArrayBufferKey() { Deno.test(async function testImportArrayBufferKey() {
const subtle = window.crypto.subtle; const subtle = globalThis.crypto.subtle;
assert(subtle); assert(subtle);
// deno-fmt-ignore // deno-fmt-ignore
@ -29,7 +29,7 @@ Deno.test(async function testImportArrayBufferKey() {
}); });
Deno.test(async function testSignVerify() { Deno.test(async function testSignVerify() {
const subtle = window.crypto.subtle; const subtle = globalThis.crypto.subtle;
assert(subtle); assert(subtle);
for (const algorithm of ["RSA-PSS", "RSASSA-PKCS1-v1_5"]) { for (const algorithm of ["RSA-PSS", "RSASSA-PKCS1-v1_5"]) {
for ( for (
@ -101,7 +101,7 @@ const hashPlainTextVector = [
]; ];
Deno.test(async function testEncryptDecrypt() { Deno.test(async function testEncryptDecrypt() {
const subtle = window.crypto.subtle; const subtle = globalThis.crypto.subtle;
assert(subtle); assert(subtle);
for ( for (
const { hash, plainText } of hashPlainTextVector const { hash, plainText } of hashPlainTextVector
@ -154,7 +154,7 @@ Deno.test(async function testEncryptDecrypt() {
}); });
Deno.test(async function testGenerateRSAKey() { Deno.test(async function testGenerateRSAKey() {
const subtle = window.crypto.subtle; const subtle = globalThis.crypto.subtle;
assert(subtle); assert(subtle);
const keyPair = await subtle.generateKey( const keyPair = await subtle.generateKey(
@ -175,7 +175,7 @@ Deno.test(async function testGenerateRSAKey() {
}); });
Deno.test(async function testGenerateHMACKey() { Deno.test(async function testGenerateHMACKey() {
const key = await window.crypto.subtle.generateKey( const key = await globalThis.crypto.subtle.generateKey(
{ {
name: "HMAC", name: "HMAC",
hash: "SHA-512", hash: "SHA-512",
@ -190,7 +190,7 @@ Deno.test(async function testGenerateHMACKey() {
}); });
Deno.test(async function testECDSASignVerify() { Deno.test(async function testECDSASignVerify() {
const key = await window.crypto.subtle.generateKey( const key = await globalThis.crypto.subtle.generateKey(
{ {
name: "ECDSA", name: "ECDSA",
namedCurve: "P-384", namedCurve: "P-384",
@ -201,7 +201,7 @@ Deno.test(async function testECDSASignVerify() {
const encoder = new TextEncoder(); const encoder = new TextEncoder();
const encoded = encoder.encode("Hello, World!"); const encoded = encoder.encode("Hello, World!");
const signature = await window.crypto.subtle.sign( const signature = await globalThis.crypto.subtle.sign(
{ name: "ECDSA", hash: "SHA-384" }, { name: "ECDSA", hash: "SHA-384" },
key.privateKey, key.privateKey,
encoded, encoded,
@ -210,7 +210,7 @@ Deno.test(async function testECDSASignVerify() {
assert(signature); assert(signature);
assert(signature instanceof ArrayBuffer); assert(signature instanceof ArrayBuffer);
const verified = await window.crypto.subtle.verify( const verified = await globalThis.crypto.subtle.verify(
{ hash: { name: "SHA-384" }, name: "ECDSA" }, { hash: { name: "SHA-384" }, name: "ECDSA" },
key.publicKey, key.publicKey,
signature, signature,
@ -221,7 +221,7 @@ Deno.test(async function testECDSASignVerify() {
// Tests the "bad paths" as a temporary replacement for sign_verify/ecdsa WPT. // Tests the "bad paths" as a temporary replacement for sign_verify/ecdsa WPT.
Deno.test(async function testECDSASignVerifyFail() { Deno.test(async function testECDSASignVerifyFail() {
const key = await window.crypto.subtle.generateKey( const key = await globalThis.crypto.subtle.generateKey(
{ {
name: "ECDSA", name: "ECDSA",
namedCurve: "P-384", namedCurve: "P-384",
@ -233,7 +233,7 @@ Deno.test(async function testECDSASignVerifyFail() {
const encoded = new Uint8Array([1]); const encoded = new Uint8Array([1]);
// Signing with a public key (InvalidAccessError) // Signing with a public key (InvalidAccessError)
await assertRejects(async () => { await assertRejects(async () => {
await window.crypto.subtle.sign( await globalThis.crypto.subtle.sign(
{ name: "ECDSA", hash: "SHA-384" }, { name: "ECDSA", hash: "SHA-384" },
key.publicKey, key.publicKey,
new Uint8Array([1]), new Uint8Array([1]),
@ -242,7 +242,7 @@ Deno.test(async function testECDSASignVerifyFail() {
}, DOMException); }, DOMException);
// Do a valid sign for later verifying. // Do a valid sign for later verifying.
const signature = await window.crypto.subtle.sign( const signature = await globalThis.crypto.subtle.sign(
{ name: "ECDSA", hash: "SHA-384" }, { name: "ECDSA", hash: "SHA-384" },
key.privateKey, key.privateKey,
encoded, encoded,
@ -250,7 +250,7 @@ Deno.test(async function testECDSASignVerifyFail() {
// Verifying with a private key (InvalidAccessError) // Verifying with a private key (InvalidAccessError)
await assertRejects(async () => { await assertRejects(async () => {
await window.crypto.subtle.verify( await globalThis.crypto.subtle.verify(
{ hash: { name: "SHA-384" }, name: "ECDSA" }, { hash: { name: "SHA-384" }, name: "ECDSA" },
key.privateKey, key.privateKey,
signature, signature,
@ -262,7 +262,7 @@ Deno.test(async function testECDSASignVerifyFail() {
// https://github.com/denoland/deno/issues/11313 // https://github.com/denoland/deno/issues/11313
Deno.test(async function testSignRSASSAKey() { Deno.test(async function testSignRSASSAKey() {
const subtle = window.crypto.subtle; const subtle = globalThis.crypto.subtle;
assert(subtle); assert(subtle);
const keyPair = await subtle.generateKey( const keyPair = await subtle.generateKey(
@ -284,7 +284,7 @@ Deno.test(async function testSignRSASSAKey() {
const encoder = new TextEncoder(); const encoder = new TextEncoder();
const encoded = encoder.encode("Hello, World!"); const encoded = encoder.encode("Hello, World!");
const signature = await window.crypto.subtle.sign( const signature = await globalThis.crypto.subtle.sign(
{ name: "RSASSA-PKCS1-v1_5" }, { name: "RSASSA-PKCS1-v1_5" },
keyPair.privateKey, keyPair.privateKey,
encoded, encoded,
@ -1056,7 +1056,7 @@ const jwtRSAKeys = {
}; };
Deno.test(async function testImportRsaJwk() { Deno.test(async function testImportRsaJwk() {
const subtle = window.crypto.subtle; const subtle = globalThis.crypto.subtle;
assert(subtle); assert(subtle);
for (const [_key, jwkData] of Object.entries(jwtRSAKeys)) { for (const [_key, jwkData] of Object.entries(jwtRSAKeys)) {
@ -1496,7 +1496,7 @@ const ecTestKeys = [
]; ];
Deno.test(async function testImportEcSpkiPkcs8() { Deno.test(async function testImportEcSpkiPkcs8() {
const subtle = window.crypto.subtle; const subtle = globalThis.crypto.subtle;
assert(subtle); assert(subtle);
for ( for (