Skip to content

Commit 4d562b0

Browse files
cli: Flag to skip starting a local validator (#93)
1 parent 0354bab commit 4d562b0

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ incremented for features.
1515

1616
* ts: Allow preloading instructions for state rpc transactions ([cf9c84](https://github.com/project-serum/anchor/commit/cf9c847e4144989b5bc1936149d171e90204777b)).
1717
* cli: Specify programs to embed into local validator genesis via Anchor.toml while testing.
18+
* cli: Allow skipping the creation of a local validator when testing against localnet.
1819

1920
## Fixes
2021

cli/src/main.rs

+14-4
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,12 @@ pub enum Command {
4646
Test {
4747
/// Use this flag if you want to run tests against previously deployed
4848
/// programs.
49-
#[clap(short, long)]
49+
#[clap(long)]
5050
skip_deploy: bool,
51+
/// Flag to skip starting a local validator, if the configured cluster
52+
/// url is a localnet.
53+
#[clap(long)]
54+
skip_local_validator: bool,
5155
},
5256
/// Creates a new program.
5357
New { name: String },
@@ -158,7 +162,10 @@ fn main() -> Result<()> {
158162
Command::Idl { subcmd } => idl(subcmd),
159163
Command::Migrate { url } => migrate(url),
160164
Command::Launch { url, keypair } => launch(url, keypair),
161-
Command::Test { skip_deploy } => test(skip_deploy),
165+
Command::Test {
166+
skip_deploy,
167+
skip_local_validator,
168+
} => test(skip_deploy, skip_local_validator),
162169
Command::Airdrop { url } => airdrop(url),
163170
}
164171
}
@@ -583,7 +590,7 @@ enum OutFile {
583590
}
584591

585592
// Builds, deploys, and tests all workspace programs in a single command.
586-
fn test(skip_deploy: bool) -> Result<()> {
593+
fn test(skip_deploy: bool, skip_local_validator: bool) -> Result<()> {
587594
with_workspace(|cfg, _path, _cargo| {
588595
// Bootup validator, if needed.
589596
let validator_handle = match cfg.cluster.url() {
@@ -593,7 +600,10 @@ fn test(skip_deploy: bool) -> Result<()> {
593600
true => None,
594601
false => Some(genesis_flags(cfg)?),
595602
};
596-
Some(start_test_validator(flags)?)
603+
match skip_local_validator {
604+
true => None,
605+
false => Some(start_test_validator(flags)?),
606+
}
597607
}
598608
_ => {
599609
if !skip_deploy {

0 commit comments

Comments
 (0)