diff options
author | Matt Mastracci <matthew@mastracci.com> | 2023-11-05 14:27:36 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-05 14:27:36 -0700 |
commit | 485fade0b6910e29557c6627d37985b47735bf8e (patch) | |
tree | 0f6c97c135c8a92226caecb363effe7eabf47936 /cli/tests | |
parent | 4530cd5f0d5e6acdbbb11a60eac711d47f274d3f (diff) |
chore: migrate to new deno_core and metrics (#21057)
- Uses the new OpMetrics system for sync and async calls
- Partial revert of #21048 as we moved Array.fromAsync upstream to
deno_core
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/integration/js_unit_tests.rs | 1 | ||||
-rw-r--r-- | cli/tests/integration/run_tests.rs | 5 | ||||
-rw-r--r-- | cli/tests/testdata/run/future_check.ts | 1 | ||||
-rw-r--r-- | cli/tests/testdata/run/future_check2.out | 1 | ||||
-rw-r--r-- | cli/tests/unit/metrics_test.ts | 93 | ||||
-rw-r--r-- | cli/tests/unit/timers_test.ts | 13 |
6 files changed, 0 insertions, 114 deletions
diff --git a/cli/tests/integration/js_unit_tests.rs b/cli/tests/integration/js_unit_tests.rs index 863776aa2..33d79236c 100644 --- a/cli/tests/integration/js_unit_tests.rs +++ b/cli/tests/integration/js_unit_tests.rs @@ -53,7 +53,6 @@ util::unit_test_factory!( link_test, make_temp_test, message_channel_test, - metrics_test, mkdir_test, navigator_test, net_test, diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs index 61749f751..153b35dc5 100644 --- a/cli/tests/integration/run_tests.rs +++ b/cli/tests/integration/run_tests.rs @@ -3425,11 +3425,6 @@ itest!(unstable_ffi_19 { exit_code: 70, }); -itest!(future_check2 { - args: "run --check run/future_check.ts", - output: "run/future_check2.out", -}); - itest!(event_listener_error { args: "run --quiet run/event_listener_error.ts", output: "run/event_listener_error.ts.out", diff --git a/cli/tests/testdata/run/future_check.ts b/cli/tests/testdata/run/future_check.ts deleted file mode 100644 index 4d41fe06a..000000000 --- a/cli/tests/testdata/run/future_check.ts +++ /dev/null @@ -1 +0,0 @@ -Deno.metrics(); diff --git a/cli/tests/testdata/run/future_check2.out b/cli/tests/testdata/run/future_check2.out deleted file mode 100644 index c626a5485..000000000 --- a/cli/tests/testdata/run/future_check2.out +++ /dev/null @@ -1 +0,0 @@ -Check [WILDCARD]/future_check.ts diff --git a/cli/tests/unit/metrics_test.ts b/cli/tests/unit/metrics_test.ts deleted file mode 100644 index 6f8c3b46d..000000000 --- a/cli/tests/unit/metrics_test.ts +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -import { assert, assertEquals } from "./test_util.ts"; - -Deno.test(async function metrics() { - // Write to stdout to ensure a "data" message gets sent instead of just - // control messages. - 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.bytesSentData === 0); - assert(m1.bytesReceived === 0); - const m1OpWrite = m1.ops["op_write"]; - assert(m1OpWrite.opsDispatchedAsync > 0); - assert(m1OpWrite.opsCompletedAsync > 0); - assert(m1OpWrite.bytesSentControl === 0); - assert(m1OpWrite.bytesSentData >= 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.bytesSentData === 0); - assert(m2.bytesReceived === m1.bytesReceived); - const m2OpWrite = m2.ops["op_write"]; - assert(m2OpWrite.opsDispatchedAsync > m1OpWrite.opsDispatchedAsync); - assert(m2OpWrite.opsCompletedAsync > m1OpWrite.opsCompletedAsync); - assert(m2OpWrite.bytesSentControl === m1OpWrite.bytesSentControl); - assert(m2OpWrite.bytesSentData === 0); - assert(m2OpWrite.bytesReceived === m1OpWrite.bytesReceived); -}); - -Deno.test( - { permissions: { write: true } }, - function metricsUpdatedIfNoResponseSync() { - const filename = Deno.makeTempDirSync() + "/test.txt"; - - const data = new Uint8Array([41, 42, 43]); - Deno.writeFileSync(filename, data, { mode: 0o666 }); - - const metrics = Deno.metrics(); - assert(metrics.opsDispatched === metrics.opsCompleted); - assert(metrics.opsDispatchedSync === metrics.opsCompletedSync); - }, -); - -Deno.test( - { permissions: { write: true } }, - async function metricsUpdatedIfNoResponseAsync() { - const filename = Deno.makeTempDirSync() + "/test.txt"; - - const data = new Uint8Array([41, 42, 43]); - await Deno.writeFile(filename, data, { mode: 0o666 }); - - const metrics = Deno.metrics(); - assert(metrics.opsDispatched === metrics.opsCompleted); - assert(metrics.opsDispatchedSync === metrics.opsCompletedSync); - assert(metrics.opsDispatchedAsync === metrics.opsCompletedAsync); - }, -); - -// Test that ops from extensions have metrics (via OpMiddleware) -Deno.test.ignore(function metricsForOpCrates() { - const _ = new URL("https://deno.land"); - - const m1 = Deno.metrics().ops["op_url_parse"]; - assert(m1.opsDispatched > 0); - assert(m1.opsCompleted > 0); -}); - -// Test that op_names == Objects.keys(Deno[Deno.internal].core.ops) -// since building the per-op metrics depends on op_names being complete -Deno.test(function opNamesMatch() { - // @ts-ignore: Deno[Deno.internal].core allowed - const ops = Object.keys(Deno[Deno.internal].core.ops); - // @ts-ignore: Deno[Deno.internal].core allowed - ops.concat(Object.keys(Deno[Deno.internal].core.asyncOps)); - - assertEquals( - // @ts-ignore: Deno[Deno.internal].core allowed - Deno[Deno.internal].core.opNames().sort(), - ops.sort().filter((name) => name !== "asyncOpsInfo"), - ); -}); diff --git a/cli/tests/unit/timers_test.ts b/cli/tests/unit/timers_test.ts index 6dedb04ed..f9beddabd 100644 --- a/cli/tests/unit/timers_test.ts +++ b/cli/tests/unit/timers_test.ts @@ -412,19 +412,6 @@ Deno.test(function clearTimeoutAndClearIntervalNotBeEquals() { assertNotEquals(clearTimeout, clearInterval); }); -Deno.test(async function timerMaxCpuBug() { - // There was a bug where clearing a timeout would cause Deno to use 100% CPU. - clearTimeout(setTimeout(() => {}, 1000)); - // We can check this by counting how many ops have triggered in the interim. - // Certainly less than 10 ops should have been dispatched in next 100 ms. - const { ops: pre } = Deno.metrics(); - await delay(100); - const { ops: post } = Deno.metrics(); - const before = pre.op_sleep.opsDispatched; - const after = post.op_sleep.opsDispatched; - assert(after - before < 10); -}); - Deno.test(async function timerOrdering() { const array: number[] = []; const donePromise = deferred(); |