summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2022-11-25 06:47:21 -0800
committerGitHub <noreply@github.com>2022-11-25 20:17:21 +0530
commit8fc62f93bfeb63edf2ee875ee5d4f8b63728f838 (patch)
treee97e0931ac40bc4454a17b7b6717ed522e2fac9a
parentd80af8324d61ce6fa54f6c9c4a2658c18b9c2428 (diff)
fix(ops): circular dependency in deno_ops test (#16809)
-rw-r--r--Cargo.lock1
-rw-r--r--ops/Cargo.toml1
-rw-r--r--ops/deno.rs1
-rw-r--r--ops/fast_call.rs2
-rw-r--r--ops/lib.rs7
-rw-r--r--ops/tests/01_fast_callback_options.rs11
-rw-r--r--ops/tests/compile_fail/unsupported.rs29
-rw-r--r--ops/tests/compile_fail/unsupported.stderr22
-rw-r--r--ops/tests/mod.rs6
9 files changed, 6 insertions, 74 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 277f222a9..788716af1 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 4250ee427..a6448ce11 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 67af603e9..07f50489a 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 d6cdfab71..c6daa5339 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 4d0c89bd2..efd47f8e5 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 815d9262c..000000000
--- 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 5856d72ef..000000000
--- 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 85f745963..000000000
--- 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 699bcf9f4..000000000
--- 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");
-}