From 8fc62f93bfeb63edf2ee875ee5d4f8b63728f838 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Fri, 25 Nov 2022 06:47:21 -0800 Subject: [PATCH] fix(ops): circular dependency in deno_ops test (#16809) --- Cargo.lock | 1 - ops/Cargo.toml | 1 - ops/deno.rs | 1 + ops/fast_call.rs | 2 +- ops/lib.rs | 7 +++--- ops/tests/01_fast_callback_options.rs | 11 --------- ops/tests/compile_fail/unsupported.rs | 29 ----------------------- ops/tests/compile_fail/unsupported.stderr | 22 ----------------- ops/tests/mod.rs | 6 ----- 9 files changed, 6 insertions(+), 74 deletions(-) delete mode 100644 ops/tests/01_fast_callback_options.rs delete mode 100644 ops/tests/compile_fail/unsupported.rs delete mode 100644 ops/tests/compile_fail/unsupported.stderr delete mode 100644 ops/tests/mod.rs diff --git a/Cargo.lock b/Cargo.lock index 277f222a9b..788716af16 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1160,7 +1160,6 @@ dependencies = [ name = "deno_ops" version = "0.39.0" dependencies = [ - "deno_core", "once_cell", "pmutil", "prettyplease", diff --git a/ops/Cargo.toml b/ops/Cargo.toml index 4250ee427a..a6448ce11b 100644 --- a/ops/Cargo.toml +++ b/ops/Cargo.toml @@ -24,7 +24,6 @@ regex.workspace = true syn.workspace = true [dev-dependencies] -deno_core.workspace = true prettyplease = "0.1.21" testing_macros = "0.2.7" trybuild = "1.0.71" diff --git a/ops/deno.rs b/ops/deno.rs index 67af603e99..07f50489a6 100644 --- a/ops/deno.rs +++ b/ops/deno.rs @@ -1,4 +1,5 @@ // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. +#![cfg(not(test))] use proc_macro2::{Span, TokenStream}; use proc_macro_crate::{crate_name, FoundCrate}; diff --git a/ops/fast_call.rs b/ops/fast_call.rs index d6cdfab717..c6daa5339a 100644 --- a/ops/fast_call.rs +++ b/ops/fast_call.rs @@ -432,7 +432,7 @@ mod tests { #[testing_macros::fixture("optimizer_tests/**/*.rs")] fn test_fast_call_codegen(input: PathBuf) { let update_expected = std::env::var("UPDATE_EXPECTED").is_ok(); - let core = crate::deno::import(); + let core = quote!(deno_core); let source = std::fs::read_to_string(&input).expect("Failed to read test file"); diff --git a/ops/lib.rs b/ops/lib.rs index 4d0c89bd2a..efd47f8e52 100644 --- a/ops/lib.rs +++ b/ops/lib.rs @@ -17,9 +17,6 @@ mod deno; mod fast_call; mod optimizer; -#[cfg(test)] -mod tests; - const SCOPE_LIFETIME: &str = "'scope"; /// Add the 'scope lifetime to the function signature. @@ -60,6 +57,10 @@ impl Op { let is_async = item.sig.asyncness.is_some() || is_future(&item.sig.output); let type_params = exclude_lifetime_params(&item.sig.generics.params); + + #[cfg(test)] + let core = quote!(deno_core); + #[cfg(not(test))] let core = deno::import(); Self { diff --git a/ops/tests/01_fast_callback_options.rs b/ops/tests/01_fast_callback_options.rs deleted file mode 100644 index 815d9262c8..0000000000 --- a/ops/tests/01_fast_callback_options.rs +++ /dev/null @@ -1,11 +0,0 @@ -use deno_core::v8::fast_api::FastApiCallbackOptions; -use deno_ops::op; - -#[op(fast)] -fn op_fallback(options: Option<&mut FastApiCallbackOptions>) { - if let Some(options) = options { - options.fallback = true; - } -} - -fn main() {} diff --git a/ops/tests/compile_fail/unsupported.rs b/ops/tests/compile_fail/unsupported.rs deleted file mode 100644 index 5856d72ef9..0000000000 --- a/ops/tests/compile_fail/unsupported.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2019-2020 the Deno authors. All rights reserved. MIT license. - -use deno_ops::op; - -#[op(fast)] -fn op_u8_arg(a: u8, b: u8) { - // -} - -#[op(fast)] -fn op_u16_arg(a: u16, b: u16) { - // -} - -use deno_core::v8::fast_api::FastApiCallbackOptions; - -#[op(fast)] -fn op_callback_options(options: &mut FastApiCallbackOptions) { - // fast callback options must be an Option. -} - -#[op(fast)] -async fn op_async_fn(a: i32, b: i32) -> i32 { - a + b -} - -fn main() { - // pass -} diff --git a/ops/tests/compile_fail/unsupported.stderr b/ops/tests/compile_fail/unsupported.stderr deleted file mode 100644 index 85f7459638..0000000000 --- a/ops/tests/compile_fail/unsupported.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error[E0277]: the trait bound `&mut FastApiCallbackOptions<'_>: Deserialize<'_>` is not satisfied - --> tests/compile_fail/unsupported.rs:17:1 - | -17 | #[op(fast)] - | ^^^^^^^^^^^ the trait `Deserialize<'_>` is not implemented for `&mut FastApiCallbackOptions<'_>` - | - = help: the following other types implement trait `Deserialize<'de>`: - &'a Path - &'a [u8] - &'a str - () - (T0, T1) - (T0, T1, T2) - (T0, T1, T2, T3) - (T0, T1, T2, T3, T4) - and 143 others -note: required by a bound in `from_v8` - --> $WORKSPACE/serde_v8/de.rs - | - | T: Deserialize<'de>, - | ^^^^^^^^^^^^^^^^ required by this bound in `from_v8` - = note: this error originates in the attribute macro `op` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/ops/tests/mod.rs b/ops/tests/mod.rs deleted file mode 100644 index 699bcf9f4c..0000000000 --- a/ops/tests/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -#[test] -fn op_macro() { - let t = trybuild::TestCases::new(); - t.compile_fail("tests/compile_fail/*.rs"); - t.pass("tests/01_fast_callback_options.rs"); -}