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

Improvements to has_backtrace_depending_on_env #277

Merged
merged 3 commits into from
Dec 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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