Skip to content

Commit

Permalink
feat: Add --no-test CLI option (#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelzw authored Nov 14, 2023
1 parent 8f477d5 commit c108bd5
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 14 deletions.
30 changes: 17 additions & 13 deletions src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,19 +266,23 @@ pub async fn run_build(

tracing::info!("{}", output);

tracing::info!("Running tests");

test::run_test(
&result,
&TestConfiguration {
test_prefix: test_dir.clone(),
target_platform: Some(output.build_configuration.target_platform),
keep_test_prefix: tool_configuration.no_clean,
channels,
},
)
.await
.into_diagnostic()?;
if tool_configuration.no_test {
tracing::info!("Skipping tests");
} else {
tracing::info!("Running tests");

test::run_test(
&result,
&TestConfiguration {
test_prefix: test_dir.clone(),
target_platform: Some(output.build_configuration.target_platform),
keep_test_prefix: tool_configuration.no_clean,
channels,
},
)
.await
.into_diagnostic()?;
}

if !tool_configuration.no_clean {
fs::remove_dir_all(&directories.build_dir).into_diagnostic()?;
Expand Down
10 changes: 10 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ struct BuildOpts {
#[arg(long)]
no_include_recipe: bool,

/// Do not run tests after building
#[arg(long, default_value = "false")]
no_test: bool,

#[clap(flatten)]
common: CommonOpts,
}
Expand All @@ -134,6 +138,10 @@ struct RebuildOpts {
#[arg(short, long)]
package_file: PathBuf,

/// Do not run tests after building
#[arg(long, default_value = "false")]
no_test: bool,

#[clap(flatten)]
common: CommonOpts,
}
Expand Down Expand Up @@ -279,6 +287,7 @@ async fn run_build_from_args(args: BuildOpts, multi_progress: MultiProgress) ->
client: AuthenticatedClient::default(),
multi_progress_indicator: multi_progress,
no_clean: args.keep_build,
no_test: args.no_test,
};

for (output, variants) in outputs_and_variants {
Expand Down Expand Up @@ -392,6 +401,7 @@ async fn rebuild_from_args(args: RebuildOpts) -> miette::Result<()> {
client: AuthenticatedClient::default(),
multi_progress_indicator: MultiProgress::new(),
no_clean: true,
no_test: args.no_test,
};

output
Expand Down
2 changes: 1 addition & 1 deletion src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ pub struct BuildConfiguration {
pub subpackages: BTreeMap<PackageName, PackageIdentifier>,
/// Package format (.tar.bz2 or .conda)
pub package_format: ArchiveType,
/// Wether to store the recipe and build instructions in the final package or not
/// Whether to store the recipe and build instructions in the final package or not
#[serde(skip_serializing, default = "default_true")]
pub store_recipe: bool,
}
Expand Down
1 change: 1 addition & 0 deletions src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ pub async fn run_test(package_file: &Path, config: &TestConfiguration) -> Result
client: AuthenticatedClient::default(),
multi_progress_indicator: MultiProgress::new(),
no_clean: config.keep_test_prefix,
no_test: false,
};

println!("Creating test environment in {:?}", prefix);
Expand Down
4 changes: 4 additions & 0 deletions src/tool_configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ pub struct Configuration {

/// Set this to true if you want to keep the build folder after the build is done
pub no_clean: bool,

/// Whether to skip the test phase
pub no_test: bool,
}

impl Default for Configuration {
Expand All @@ -33,6 +36,7 @@ impl Default for Configuration {
),
),
no_clean: false,
no_test: false,
}
}
}

0 comments on commit c108bd5

Please sign in to comment.