Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_tool: Let Cargo tell us where imageflow_tool resides #650

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
49 changes: 2 additions & 47 deletions imageflow_tool/tests/test_tool.rs
Original file line number Diff line number Diff line change
@@ -1,55 +1,10 @@
//#[cfg_attr(feature = "cargo-clippy", allow(useless_attribute))]
extern crate imageflow_tool_lib;
extern crate imageflow_types as s;
use std::io::Write;
use std::path::{Path,PathBuf};


fn build_dirs() -> Vec<PathBuf>{
let target_triple = crate::s::version::get_build_env_value("TARGET").expect("TARGET triple required");
let profile = crate::s::version::get_build_env_value("PROFILE").expect("PROFILE (debug/release) required");


let target_dir = Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap().join("target");

let a = target_dir.join(target_triple).join(profile);
let b = target_dir.join(profile);
vec![a,b]
}
#[cfg(windows)]
fn binary_ext() -> &'static str{
"exe"
}
#[cfg(not(windows))]
fn binary_ext() -> &'static str{
""
}

fn locate_binary(name: &str) -> Option<PathBuf> {
for dir in build_dirs() {
let file_path = dir.join(name).with_extension(binary_ext());

if file_path.exists() {
return Some(dir.join(name))
}
}
None
}


fn tool_path() -> PathBuf {
match locate_binary("imageflow_tool"){
Some(v) => v,
None => {
panic!("Failed to locate imageflow_tool binary in {:?}", build_dirs());
}
}
}

use std::path::PathBuf;

#[test]
fn run_imageflow_tool_self_test(){
let tool = tool_path();
let tool = PathBuf::from(env!("CARGO_BIN_EXE_imageflow_tool"));
let _ = writeln!(std::io::stdout(), "Testing binary {:?}", &tool);
imageflow_tool_lib::self_test::run(Some(tool.clone()));
imageflow_tool_lib::self_test::test_capture(Some(tool));
Expand Down
Loading