diff --git a/CHANGELOG.md b/CHANGELOG.md index 244c1dddf..1bf12da48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ incremented for features. * ts: Allow preloading instructions for state rpc transactions ([cf9c84](https://github.com/project-serum/anchor/commit/cf9c847e4144989b5bc1936149d171e90204777b)). * cli: Specify programs to embed into local validator genesis via Anchor.toml while testing. +* cli: Allow skipping the creation of a local validator when testing against localnet. ## Fixes diff --git a/cli/src/main.rs b/cli/src/main.rs index 0fb91d6ab..a59a56260 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -46,8 +46,12 @@ pub enum Command { Test { /// Use this flag if you want to run tests against previously deployed /// programs. - #[clap(short, long)] + #[clap(long)] skip_deploy: bool, + /// Flag to skip starting a local validator, if the configured cluster + /// url is a localnet. + #[clap(long)] + skip_local_validator: bool, }, /// Creates a new program. New { name: String }, @@ -158,7 +162,10 @@ fn main() -> Result<()> { Command::Idl { subcmd } => idl(subcmd), Command::Migrate { url } => migrate(url), Command::Launch { url, keypair } => launch(url, keypair), - Command::Test { skip_deploy } => test(skip_deploy), + Command::Test { + skip_deploy, + skip_local_validator, + } => test(skip_deploy, skip_local_validator), Command::Airdrop { url } => airdrop(url), } } @@ -583,7 +590,7 @@ enum OutFile { } // Builds, deploys, and tests all workspace programs in a single command. -fn test(skip_deploy: bool) -> Result<()> { +fn test(skip_deploy: bool, skip_local_validator: bool) -> Result<()> { with_workspace(|cfg, _path, _cargo| { // Bootup validator, if needed. let validator_handle = match cfg.cluster.url() { @@ -593,7 +600,10 @@ fn test(skip_deploy: bool) -> Result<()> { true => None, false => Some(genesis_flags(cfg)?), }; - Some(start_test_validator(flags)?) + match skip_local_validator { + true => None, + false => Some(start_test_validator(flags)?), + } } _ => { if !skip_deploy {