diff options
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/unit/dispatch_bin_test.ts | 48 | ||||
-rw-r--r-- | cli/tests/unit/dispatch_json_test.ts | 32 | ||||
-rw-r--r-- | cli/tests/unit/metrics_test.ts | 19 | ||||
-rw-r--r-- | cli/tests/unit/unit_tests.ts | 1 |
4 files changed, 14 insertions, 86 deletions
diff --git a/cli/tests/unit/dispatch_bin_test.ts b/cli/tests/unit/dispatch_bin_test.ts index b2d96f3b3..83053461d 100644 --- a/cli/tests/unit/dispatch_bin_test.ts +++ b/cli/tests/unit/dispatch_bin_test.ts @@ -8,9 +8,9 @@ import { const readErrorStackPattern = new RegExp( `^.* - at handleError \\(.*core\\.js:.*\\) - at binOpParseResult \\(.*core\\.js:.*\\) - at asyncHandle \\(.*core\\.js:.*\\).*$`, + at processErr \\(.*core\\.js:.*\\) + at opAsyncHandler \\(.*core\\.js:.*\\) + at handleAsyncMsgFromRust \\(.*core\\.js:.*\\).*$`, "ms", ); @@ -32,45 +32,3 @@ declare global { var core: any; // eslint-disable-line no-var } } - -unitTest(function binOpsHeaderTooShort(): void { - for (const op of ["op_read_sync", "op_read_async"]) { - const readOpId = Deno.core.ops()[op]; - const res = Deno.core.send( - readOpId, - new Uint8Array([ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - ]), - ); - - const headerByteLength = 4 * 4; - assert(res.byteLength > headerByteLength); - const view = new DataView( - res.buffer, - res.byteOffset + res.byteLength - headerByteLength, - headerByteLength, - ); - - const requestId = Number(view.getBigUint64(0, true)); - const status = view.getUint32(8, true); - const result = view.getUint32(12, true); - - assert(requestId === 0); - assert(status !== 0); - assertEquals(new TextDecoder().decode(res.slice(0, result)), "TypeError"); - assertEquals( - new TextDecoder().decode(res.slice(result, -headerByteLength)).trim(), - "Unparsable control buffer", - ); - } -}); diff --git a/cli/tests/unit/dispatch_json_test.ts b/cli/tests/unit/dispatch_json_test.ts deleted file mode 100644 index 3cb9506dd..000000000 --- a/cli/tests/unit/dispatch_json_test.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { assertMatch, assertStrictEquals, unitTest } from "./test_util.ts"; - -declare global { - // deno-lint-ignore no-namespace - namespace Deno { - // deno-lint-ignore no-explicit-any - var core: any; // eslint-disable-line no-var - } -} - -unitTest(function malformedJsonControlBuffer(): void { - const opId = Deno.core.ops()["op_open_sync"]; - const argsBuf = new Uint8Array([1, 2, 3, 4, 5]); - const resBuf = Deno.core.send(opId, argsBuf); - const resText = new TextDecoder().decode(resBuf); - const resObj = JSON.parse(resText); - assertStrictEquals(resObj.ok, undefined); - assertStrictEquals(resObj.err.className, "SyntaxError"); - assertMatch(resObj.err.message, /\bexpected value\b/); -}); - -unitTest(function invalidRequestId(): void { - const opId = Deno.core.ops()["op_open_async"]; - const reqBuf = new Uint8Array([0, 0, 0, 0, 0, 0, 0]); - const resBuf = Deno.core.send(opId, reqBuf); - const resText = new TextDecoder().decode(resBuf); - const resObj = JSON.parse(resText); - console.error(resText); - assertStrictEquals(resObj.ok, undefined); - assertStrictEquals(resObj.err.className, "TypeError"); - assertMatch(resObj.err.message, /\brequestId\b/); -}); diff --git a/cli/tests/unit/metrics_test.ts b/cli/tests/unit/metrics_test.ts index 525e5aae6..9fa37e99b 100644 --- a/cli/tests/unit/metrics_test.ts +++ b/cli/tests/unit/metrics_test.ts @@ -7,35 +7,38 @@ unitTest(async function metrics(): Promise<void> { const dataMsg = new Uint8Array([13, 13, 13]); // "\r\r\r", await Deno.stdout.write(dataMsg); + // WARNING: bytesReceived & bytesSentControl are now always zero + // following https://github.com/denoland/deno/pull/9843 + const m1 = Deno.metrics(); assert(m1.opsDispatched > 0); assert(m1.opsCompleted > 0); - assert(m1.bytesSentControl > 0); + assert(m1.bytesSentControl === 0); assert(m1.bytesSentData >= 0); - assert(m1.bytesReceived > 0); + assert(m1.bytesReceived === 0); const m1OpWrite = m1.ops["op_write_async"]; assert(m1OpWrite.opsDispatchedAsync > 0); assert(m1OpWrite.opsCompletedAsync > 0); - assert(m1OpWrite.bytesSentControl > 0); + assert(m1OpWrite.bytesSentControl === 0); assert(m1OpWrite.bytesSentData >= 0); - assert(m1OpWrite.bytesReceived > 0); + assert(m1OpWrite.bytesReceived === 0); await Deno.stdout.write(dataMsg); const m2 = Deno.metrics(); assert(m2.opsDispatchedAsync > m1.opsDispatchedAsync); assert(m2.opsCompletedAsync > m1.opsCompletedAsync); - assert(m2.bytesSentControl > m1.bytesSentControl); + assert(m2.bytesSentControl === m1.bytesSentControl); assert(m2.bytesSentData >= m1.bytesSentData + dataMsg.byteLength); - assert(m2.bytesReceived > m1.bytesReceived); + assert(m2.bytesReceived === m1.bytesReceived); const m2OpWrite = m2.ops["op_write_async"]; assert(m2OpWrite.opsDispatchedAsync > m1OpWrite.opsDispatchedAsync); assert(m2OpWrite.opsCompletedAsync > m1OpWrite.opsCompletedAsync); - assert(m2OpWrite.bytesSentControl > m1OpWrite.bytesSentControl); + assert(m2OpWrite.bytesSentControl === m1OpWrite.bytesSentControl); assert( m2OpWrite.bytesSentData >= m1OpWrite.bytesSentData + dataMsg.byteLength, ); - assert(m2OpWrite.bytesReceived > m1OpWrite.bytesReceived); + assert(m2OpWrite.bytesReceived === m1OpWrite.bytesReceived); }); unitTest( diff --git a/cli/tests/unit/unit_tests.ts b/cli/tests/unit/unit_tests.ts index d80403366..a736e97ca 100644 --- a/cli/tests/unit/unit_tests.ts +++ b/cli/tests/unit/unit_tests.ts @@ -16,7 +16,6 @@ import "./copy_file_test.ts"; import "./custom_event_test.ts"; import "./dir_test.ts"; import "./dispatch_bin_test.ts"; -import "./dispatch_json_test.ts"; import "./error_stack_test.ts"; import "./event_test.ts"; import "./event_target_test.ts"; |