Search BPF_OUT_DIR for programs
This commit is contained in:
parent
5a435a4342
commit
77d9d06a44
|
@ -354,17 +354,15 @@ pub struct ProgramTest {
|
||||||
impl Default for ProgramTest {
|
impl Default for ProgramTest {
|
||||||
/// Initialize a new ProgramTest
|
/// Initialize a new ProgramTest
|
||||||
///
|
///
|
||||||
/// The `bpf` environment variable controls how BPF programs are selected during operation:
|
/// If the `BPF_OUT_DIR` environment variable is defined, BPF programs will be preferred over
|
||||||
/// `export bpf=1` -- use BPF programs if present, otherwise fall back to the
|
/// over a native instruction processor. The `ProgramTest::prefer_bpf()` method may be
|
||||||
/// native instruction processors provided with the test
|
/// used to override this preference at runtime. `cargo test-bpf` will set `BPF_OUT_DIR`
|
||||||
/// `export bpf=0` -- use native instruction processor if present, otherwise fall back to
|
/// automatically.
|
||||||
/// the BPF program
|
|
||||||
/// (default)
|
|
||||||
/// and the `ProgramTest::prefer_bpf()` method may be used to override the selection at runtime
|
|
||||||
///
|
///
|
||||||
/// BPF program shared objects and account data files are searched for in
|
/// BPF program shared objects and account data files are searched for in
|
||||||
/// * the current working directory (the default output location for `cargo build-bpf),
|
/// * the value of the `BPF_OUT_DIR` environment variable
|
||||||
/// * the `tests/fixtures` sub-directory
|
/// * the `tests/fixtures` sub-directory
|
||||||
|
/// * the current working directory
|
||||||
///
|
///
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
solana_logger::setup_with_default(
|
solana_logger::setup_with_default(
|
||||||
|
@ -374,20 +372,18 @@ impl Default for ProgramTest {
|
||||||
solana_runtime::system_instruction_processor=trace,\
|
solana_runtime::system_instruction_processor=trace,\
|
||||||
solana_program_test=info",
|
solana_program_test=info",
|
||||||
);
|
);
|
||||||
let prefer_bpf = match std::env::var("bpf") {
|
let mut prefer_bpf = false;
|
||||||
Ok(val) => !matches!(val.as_str(), "0" | ""),
|
|
||||||
Err(_err) => false,
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut search_path = vec![];
|
let mut search_path = vec![];
|
||||||
if let Ok(dir) = std::env::var("CARGO_BUILD_TARGET_DIR") {
|
if let Ok(bpf_out_dir) = std::env::var("BPF_OUT_DIR") {
|
||||||
let deploy_dir = PathBuf::from(dir).join("deploy");
|
prefer_bpf = true;
|
||||||
search_path.push(deploy_dir);
|
search_path.push(PathBuf::from(bpf_out_dir));
|
||||||
};
|
}
|
||||||
|
search_path.push(PathBuf::from("tests/fixtures"));
|
||||||
if let Ok(dir) = std::env::current_dir() {
|
if let Ok(dir) = std::env::current_dir() {
|
||||||
search_path.push(dir);
|
search_path.push(dir);
|
||||||
}
|
}
|
||||||
search_path.push(PathBuf::from("tests/fixtures"));
|
debug!("search path: {:?}", search_path);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
accounts: vec![],
|
accounts: vec![],
|
||||||
|
|
|
@ -10,6 +10,7 @@ edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = "2.33.3"
|
clap = "2.33.3"
|
||||||
|
cargo_metadata = "0.12.0"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "cargo-test-bpf"
|
name = "cargo-test-bpf"
|
||||||
|
|
Loading…
Reference in New Issue