diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2022-03-23 16:33:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-23 16:33:42 +0100 |
commit | b82ded84d341cda98821592556804a529638589c (patch) | |
tree | c36dae6ea227c21f0238cad05ce4315f5547eca3 /cli/ops/bench.rs | |
parent | 53dac7451bbdd527aa91e01653b678547624fc39 (diff) |
fix(bench): require --unstable flag in JavaScript (#14091)
Diffstat (limited to 'cli/ops/bench.rs')
-rw-r--r-- | cli/ops/bench.rs | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/cli/ops/bench.rs b/cli/ops/bench.rs index 4b7d6743f..ea040b4a5 100644 --- a/cli/ops/bench.rs +++ b/cli/ops/bench.rs @@ -12,7 +12,7 @@ use std::time; use tokio::sync::mpsc::UnboundedSender; use uuid::Uuid; -pub fn init(sender: UnboundedSender<BenchEvent>) -> Extension { +pub fn init(sender: UnboundedSender<BenchEvent>, unstable: bool) -> Extension { Extension::builder() .ops(vec![ op_pledge_test_permissions::decl(), @@ -20,14 +20,36 @@ pub fn init(sender: UnboundedSender<BenchEvent>) -> Extension { op_get_bench_origin::decl(), op_dispatch_bench_event::decl(), op_bench_now::decl(), + op_bench_check_unstable::decl(), ]) .state(move |state| { state.put(sender.clone()); + state.put(Unstable(unstable)); Ok(()) }) .build() } +pub struct Unstable(pub bool); + +fn check_unstable(state: &OpState, api_name: &str) { + let unstable = state.borrow::<Unstable>(); + + if !unstable.0 { + eprintln!( + "Unstable API '{}'. The --unstable flag must be provided.", + api_name + ); + std::process::exit(70); + } +} + +#[op] +fn op_bench_check_unstable(state: &mut OpState) -> Result<(), AnyError> { + check_unstable(state, "Deno.bench"); + Ok(()) +} + #[derive(Clone)] struct PermissionsHolder(Uuid, Permissions); |