From 2c621f5894b727cff4f2b0e7d045d9b579add3ed Mon Sep 17 00:00:00 2001 From: Matt Mastracci Date: Mon, 5 Feb 2024 13:26:59 -0700 Subject: refactor(cli): Move op descriptions into Rust and prepare for op import (#22271) This moves the op sanitizer descriptions into Rust code and prepares for eventual op import from `ext:core/ops`. We cannot import these ops from `ext:core/ops` as the testing infrastructure ops are not always present. Changes: - Op descriptions live in `cli` code and are currently accessible via an op for the older sanitizer code - `phf` dep moved to workspace root so we can use it here - `ops.op_XXX` changed to to `op_XXX` to prepare for op imports later on. --- cli/ops/testing.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'cli/ops') diff --git a/cli/ops/testing.rs b/cli/ops/testing.rs index 4a2f48181..7bf0b37a3 100644 --- a/cli/ops/testing.rs +++ b/cli/ops/testing.rs @@ -1,5 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +use crate::tools::test::fmt::OP_DETAILS; use crate::tools::test::TestDescription; use crate::tools::test::TestEvent; use crate::tools::test::TestEventSender; @@ -47,6 +48,7 @@ deno_core::extension!(deno_test, op_test_op_sanitizer_collect, op_test_op_sanitizer_finish, op_test_op_sanitizer_report, + op_test_op_sanitizer_get_async_message, ], options = { sender: TestEventSender, @@ -420,3 +422,15 @@ fn op_test_op_sanitizer_report( ))), } } + +#[op2] +#[serde] +fn op_test_op_sanitizer_get_async_message( + #[string] op_name: &str, +) -> (String, Option) { + if let Some(output) = OP_DETAILS.get(op_name) { + (output[0].to_string(), Some(output[1].to_string())) + } else { + (op_name.to_string(), None) + } +} -- cgit v1.2.3