cli: Flag to skip starting a local validator (#93)

This commit is contained in:
Armani Ferrante 2021-02-26 22:16:19 +08:00 committed by GitHub
parent 0354bab56f
commit 4d562b0a82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 4 deletions

View File

@ -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

View File

@ -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 {