Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: Flag to skip starting a local validator #93

Merged
merged 1 commit into from
Feb 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 14 additions & 4 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -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),
}
}
Expand Down Expand Up @@ -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() {
Expand All @@ -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 {
Expand Down