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.
This commit is contained in:
Matt Mastracci 2024-02-05 13:26:59 -07:00 committed by GitHub
parent 0a3d329dd8
commit 2c621f5894
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 130 additions and 98 deletions

View file

@ -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<String>) {
if let Some(output) = OP_DETAILS.get(op_name) {
(output[0].to_string(), Some(output[1].to_string()))
} else {
(op_name.to_string(), None)
}
}