Skip to content
This repository has been archived by the owner on Aug 16, 2021. It is now read-only.

Commit

Permalink
Improvements to has_backtrace_depending_on_env (#277)
Browse files Browse the repository at this point in the history
* Move has_backtrace out of test and into examples

* Fix has_backtrace_depending_on_env path for release builds
  • Loading branch information
palfrey authored and AndyGauge committed Dec 4, 2019
1 parent 8462495 commit d31288b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
6 changes: 6 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
extern crate version_check;

use std::env;
use version_check::is_min_version;

fn main() {
Expand All @@ -8,4 +9,9 @@ fn main() {
if is_min_version("1.30").unwrap_or(false) {
println!("cargo:rustc-cfg=has_error_source");
}

// So we can get the build profile for has_backtrace_depending_on_env test
if let Ok(profile) = env::var("PROFILE") {
println!("cargo:rustc-cfg=build={:?}", profile);
}
}
File renamed without changes.
14 changes: 11 additions & 3 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,21 @@ fn empty() {
#[test]
#[cfg(feature = "backtrace")]
fn has_backtrace_depending_on_env() {
use std::path::Path;
use std::path::PathBuf;
use std::process::Command;

let cmd_folder = if cfg!(build="debug") {
"debug"
} else if cfg!(build="release") {
"release"
} else {
panic!("Unknown build config");
};

let cmd_path = if cfg!(windows) {
Path::new("./target/debug/has_backtrace.exe")
PathBuf::from(format!("./target/{}/examples/has_backtrace.exe", cmd_folder))
} else {
Path::new("./target/debug/has_backtrace")
PathBuf::from(format!("./target/{}/examples/has_backtrace", cmd_folder))
};
let mut cmd = Command::new(cmd_path);

Expand Down

0 comments on commit d31288b

Please sign in to comment.