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

Commit d31288b

Browse files
palfreyAndyGauge
authored andcommitted
Improvements to has_backtrace_depending_on_env (#277)
* Move has_backtrace out of test and into examples * Fix has_backtrace_depending_on_env path for release builds
1 parent 8462495 commit d31288b

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

build.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
extern crate version_check;
22

3+
use std::env;
34
use version_check::is_min_version;
45

56
fn main() {
@@ -8,4 +9,9 @@ fn main() {
89
if is_min_version("1.30").unwrap_or(false) {
910
println!("cargo:rustc-cfg=has_error_source");
1011
}
12+
13+
// So we can get the build profile for has_backtrace_depending_on_env test
14+
if let Ok(profile) = env::var("PROFILE") {
15+
println!("cargo:rustc-cfg=build={:?}", profile);
16+
}
1117
}
File renamed without changes.

tests/tests.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -199,13 +199,21 @@ fn empty() {
199199
#[test]
200200
#[cfg(feature = "backtrace")]
201201
fn has_backtrace_depending_on_env() {
202-
use std::path::Path;
202+
use std::path::PathBuf;
203203
use std::process::Command;
204204

205+
let cmd_folder = if cfg!(build="debug") {
206+
"debug"
207+
} else if cfg!(build="release") {
208+
"release"
209+
} else {
210+
panic!("Unknown build config");
211+
};
212+
205213
let cmd_path = if cfg!(windows) {
206-
Path::new("./target/debug/has_backtrace.exe")
214+
PathBuf::from(format!("./target/{}/examples/has_backtrace.exe", cmd_folder))
207215
} else {
208-
Path::new("./target/debug/has_backtrace")
216+
PathBuf::from(format!("./target/{}/examples/has_backtrace", cmd_folder))
209217
};
210218
let mut cmd = Command::new(cmd_path);
211219

0 commit comments

Comments
 (0)