Skip to content

Commit

Permalink
skip download if ELECTRSD_SKIP_DOWNLOAD is set
Browse files Browse the repository at this point in the history
  • Loading branch information
RCasatta committed Apr 4, 2024
1 parent 2676d03 commit f8be742
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ if let Ok(exe_path) = electrsd::exe_path() {

Startup options could be configured via the `Conf` struct using `electrsD::with_conf` or `electrsD::from_downloaded_with_conf`.

## Nix

For determinisim, in nix you cannot hit the internet within the `build.rs`. Moreover, some downstream crates cannot remove the auto-download feature from their dev-deps. In this case you can set the `ELECTRSD_SKIP_DOWNLOAD` env var and provide the electrs executable in the `PATH` (or skip the test execution).

## Issues with traditional approach

I used integration testing based on external bash script launching needed external processes, there are many issues with this approach like:
Expand Down
4 changes: 4 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ mod download {
}

pub fn download() {
if std::env::var_os("ELECTRSD_SKIP_DOWNLOAD").is_some() {
return;
}

if !HAS_FEATURE {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,9 @@ impl Drop for ElectrsD {
}
}

/// Provide the electrs executable path if a version feature has been specified
/// Provide the electrs executable path if a version feature has been specified and `ELECTRSD_SKIP_DOWNLOAD` is not set.
pub fn downloaded_exe_path() -> Option<String> {
if versions::HAS_FEATURE {
if versions::HAS_FEATURE && std::env::var_os("ELECTRSD_SKIP_DOWNLOAD").is_none() {
Some(format!(
"{}/electrs/{}/electrs",
env!("OUT_DIR"),
Expand Down

0 comments on commit f8be742

Please sign in to comment.