Skip to content

Commit

Permalink
fix(xtask): add support for end of flags and typechecking (#493)
Browse files Browse the repository at this point in the history
### Describe your change

Adds support for end of flags arguments to the `cargo x deno test/bench`
commands.

### Motivation and context

Fix an issue that preventing a updating snapshots as implemented in the
`dev/test.ts` script.
  • Loading branch information
Yohe-Am authored Nov 21, 2023
1 parent 7210129 commit 85b14af
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 17 deletions.
31 changes: 15 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion libs/deno/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ pub fn test_sync(
permissions: PermissionsOptions,
coverage_dir: Option<String>,
custom_extensions: Arc<worker::CustomExtensionsCb>,
argv: Vec<String>,
) {
new_thread_builder()
.spawn(|| {
Expand All @@ -105,6 +106,7 @@ pub fn test_sync(
permissions,
coverage_dir,
custom_extensions,
argv,
)
.await
.unwrap()
Expand All @@ -124,6 +126,7 @@ pub async fn test(
permissions: PermissionsOptions,
coverage_dir: Option<String>,
custom_extensions: Arc<worker::CustomExtensionsCb>,
argv: Vec<String>,
) -> anyhow::Result<()> {
use deno::tools::test::*;

Expand All @@ -133,7 +136,9 @@ pub async fn test(
);
let flags = args::Flags {
unstable: true,
type_check_mode: args::TypeCheckMode::Local,
config_flag: deno_config::ConfigFlag::Path(config_file.to_string_lossy().into()),
argv,
..Default::default()
};

Expand Down Expand Up @@ -230,12 +235,13 @@ pub fn bench_sync(
config_file: PathBuf,
permissions: PermissionsOptions,
custom_extensions: Arc<worker::CustomExtensionsCb>,
argv: Vec<String>,
) {
new_thread_builder()
.spawn(|| {
create_and_run_current_thread_with_maybe_metrics(async move {
spawn_subcommand(async move {
bench(files, config_file, permissions, custom_extensions)
bench(files, config_file, permissions, custom_extensions, argv)
.await
.unwrap()
})
Expand All @@ -253,6 +259,7 @@ pub async fn bench(
config_file: PathBuf,
permissions: PermissionsOptions,
custom_extensions: Arc<worker::CustomExtensionsCb>,
argv: Vec<String>,
) -> anyhow::Result<()> {
use deno::tools::bench::*;
use deno::tools::test::TestFilter;
Expand All @@ -263,7 +270,9 @@ pub async fn bench(
);
let flags = args::Flags {
unstable: true,
type_check_mode: args::TypeCheckMode::Local,
config_flag: deno_config::ConfigFlag::Path(config_file.to_string_lossy().into()),
argv,
..Default::default()
};

Expand Down
6 changes: 6 additions & 0 deletions libs/xtask/src/deno.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ pub struct Test {
/// The directory in which to put the coverage profiles
#[clap(long)]
coverage: Option<String>,
#[clap(last = true)]
argv: Vec<String>,
}

impl Test {
Expand Down Expand Up @@ -87,6 +89,7 @@ impl Test {
permissions,
self.coverage,
std::sync::Arc::new(move || typegate_engine::extensions(inj.clone())),
self.argv,
);
Ok(())
}
Expand All @@ -102,6 +105,8 @@ pub struct Bench {
/// Path to `deno.json`
#[clap(long)]
config: PathBuf,
#[clap(last = true)]
argv: Vec<String>,
}

impl Bench {
Expand Down Expand Up @@ -144,6 +149,7 @@ impl Bench {
self.config,
permissions,
std::sync::Arc::new(Vec::new),
self.argv,
);
Ok(())
}
Expand Down

0 comments on commit 85b14af

Please sign in to comment.