diff options
-rw-r--r-- | cli/standalone/binary.rs | 2 | ||||
-rw-r--r-- | cli/standalone/mod.rs | 5 | ||||
-rw-r--r-- | cli/tests/integration/compile_tests.rs | 26 | ||||
-rw-r--r-- | cli/tests/testdata/compile/unstable_features.ts | 2 |
4 files changed, 35 insertions, 0 deletions
diff --git a/cli/standalone/binary.rs b/cli/standalone/binary.rs index 91cb09fb7..18880b7a1 100644 --- a/cli/standalone/binary.rs +++ b/cli/standalone/binary.rs @@ -138,6 +138,7 @@ pub enum NodeModules { pub struct Metadata { pub argv: Vec<String>, pub unstable: bool, + pub unstable_features: Vec<String>, pub seed: Option<u64>, pub permissions: PermissionsOptions, pub location: Option<Url>, @@ -542,6 +543,7 @@ impl<'a> DenoCompileBinaryWriter<'a> { let metadata = Metadata { argv: compile_flags.args.clone(), unstable: cli_options.unstable(), + unstable_features: cli_options.unstable_features(), seed: cli_options.seed(), location: cli_options.location_flag().clone(), permissions: cli_options.permissions_options(), diff --git a/cli/standalone/mod.rs b/cli/standalone/mod.rs index 32ae771c1..47a660fe1 100644 --- a/cli/standalone/mod.rs +++ b/cli/standalone/mod.rs @@ -488,6 +488,11 @@ pub async fn run( if metadata.unstable { checker.enable_legacy_unstable(); } + for feature in metadata.unstable_features { + // `metadata` is valid for the whole lifetime of the program, so we + // can leak the string here. + checker.enable_feature(feature.leak()); + } checker }); let worker_factory = CliMainWorkerFactory::new( diff --git a/cli/tests/integration/compile_tests.rs b/cli/tests/integration/compile_tests.rs index 788a7cda9..d6c7febd5 100644 --- a/cli/tests/integration/compile_tests.rs +++ b/cli/tests/integration/compile_tests.rs @@ -1123,3 +1123,29 @@ fn dynamic_imports_tmp_lit() { let output = context.new_command().name(&exe).run(); output.assert_matches_text("a\nb\n{ data: 5 }\n{ data: 1 }\n"); } + +#[test] +fn granular_unstable_features() { + let context = TestContextBuilder::new().build(); + let dir = context.temp_dir(); + let exe = if cfg!(windows) { + dir.path().join("app.exe") + } else { + dir.path().join("app") + }; + let output = context + .new_command() + .args_vec([ + "compile", + "--output", + &exe.to_string_lossy(), + "--unstable-kv", + "./compile/unstable_features.ts", + ]) + .run(); + output.assert_exit_code(0); + output.skip_output_check(); + let output = context.new_command().name(&exe).run(); + output.assert_exit_code(0); + output.assert_matches_text("Kv {}\n"); +} diff --git a/cli/tests/testdata/compile/unstable_features.ts b/cli/tests/testdata/compile/unstable_features.ts new file mode 100644 index 000000000..819a3d187 --- /dev/null +++ b/cli/tests/testdata/compile/unstable_features.ts @@ -0,0 +1,2 @@ +const db = await Deno.openKv(); +console.log(db); |