Browse Source

cli: Add --skip-build flag to anchor test (#301)

nutchanon-pho 4 years ago
parent
commit
691a30ae06
2 changed files with 12 additions and 2 deletions
  1. 1 0
      CHANGELOG.md
  2. 11 2
      cli/src/main.rs

+ 1 - 0
CHANGELOG.md

@@ -15,6 +15,7 @@ incremented for features.
 
 
 * ts: Add `program.simulate` namespace ([#266](https://github.com/project-serum/anchor/pull/266)).
 * ts: Add `program.simulate` namespace ([#266](https://github.com/project-serum/anchor/pull/266)).
 * cli: Add yarn flag to test command ([#267](https://github.com/project-serum/anchor/pull/267)).
 * cli: Add yarn flag to test command ([#267](https://github.com/project-serum/anchor/pull/267)).
+* cli: Add `--skip-build` flag to test command ([301](https://github.com/project-serum/anchor/pull/301)).
 
 
 ## Breaking Changes
 ## Breaking Changes
 
 

+ 11 - 2
cli/src/main.rs

@@ -76,6 +76,10 @@ pub enum Command {
         /// url is a localnet.
         /// url is a localnet.
         #[clap(long)]
         #[clap(long)]
         skip_local_validator: bool,
         skip_local_validator: bool,
+        /// Flag to skip building the program in the workspace,
+        /// use this to save time when running test and the program code is not altered.
+        #[clap(long)]
+        skip_build: bool,
         /// Use this flag if you want to use yarn as your package manager.
         /// Use this flag if you want to use yarn as your package manager.
         #[clap(long)]
         #[clap(long)]
         yarn: bool,
         yarn: bool,
@@ -242,9 +246,10 @@ fn main() -> Result<()> {
         Command::Test {
         Command::Test {
             skip_deploy,
             skip_deploy,
             skip_local_validator,
             skip_local_validator,
+            skip_build,
             yarn,
             yarn,
             file,
             file,
-        } => test(skip_deploy, skip_local_validator, yarn, file),
+        } => test(skip_deploy, skip_local_validator, skip_build, yarn, file),
         #[cfg(feature = "dev")]
         #[cfg(feature = "dev")]
         Command::Airdrop { url } => airdrop(url),
         Command::Airdrop { url } => airdrop(url),
         Command::Cluster { subcmd } => cluster(subcmd),
         Command::Cluster { subcmd } => cluster(subcmd),
@@ -925,6 +930,7 @@ enum OutFile {
 fn test(
 fn test(
     skip_deploy: bool,
     skip_deploy: bool,
     skip_local_validator: bool,
     skip_local_validator: bool,
+    skip_build: bool,
     use_yarn: bool,
     use_yarn: bool,
     file: Option<String>,
     file: Option<String>,
 ) -> Result<()> {
 ) -> Result<()> {
@@ -932,7 +938,10 @@ fn test(
         // Bootup validator, if needed.
         // Bootup validator, if needed.
         let validator_handle = match cfg.cluster.url() {
         let validator_handle = match cfg.cluster.url() {
             "http://127.0.0.1:8899" => {
             "http://127.0.0.1:8899" => {
-                build(None, false)?;
+                match skip_build {
+                    true => None,
+                    false => Some(build(None, false)?),
+                };
                 let flags = match skip_deploy {
                 let flags = match skip_deploy {
                     true => None,
                     true => None,
                     false => Some(genesis_flags(cfg)?),
                     false => Some(genesis_flags(cfg)?),