Skip to content

Commit

Permalink
refact: use .schema.env
Browse files Browse the repository at this point in the history
fix: make clippy happy

Signed-off-by: dqhl76 <dqhl76@gmail.com>

rustfmt

Signed-off-by: dqhl76 <dqhl76@gmail.com>

refact: use .schema.env

Signed-off-by: dqhl76 <dqhl76@gmail.com>
  • Loading branch information
dqhl76 committed Aug 9, 2023
1 parent 0411096 commit 36e74a8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
2 changes: 0 additions & 2 deletions core/fuzz/fuzz_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,6 @@ async fn fuzz_reader(op: Operator, input: FuzzInput) -> Result<()> {
fuzz_target!(|input: FuzzInput| {
let _ = dotenvy::dotenv();

utils::apply_args_to_env();

let runtime = tokio::runtime::Runtime::new().expect("init runtime must succeed");

for op in utils::init_services() {
Expand Down
2 changes: 0 additions & 2 deletions core/fuzz/fuzz_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ async fn fuzz_writer(op: Operator, input: FuzzInput) -> Result<()> {
fuzz_target!(|input: FuzzInput| {
let _ = dotenvy::dotenv();

utils::apply_args_to_env();

let runtime = tokio::runtime::Runtime::new().expect("init runtime must succeed");

for op in utils::init_services() {
Expand Down
18 changes: 6 additions & 12 deletions core/fuzz/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,15 @@ use std::env;
use opendal::Operator;
use opendal::Scheme;

pub fn apply_args_to_env() {
// for oss-fuzz integration, set envs from args
// example: -opendal_fs_test=on -> OPENDAL_FS_TEST=on
let args: Vec<String> = env::args().collect();
fn service(scheme: Scheme) -> Option<Operator> {
let test_key = format!("opendal_{}_test", scheme).to_uppercase();

for arg in &args[1..] {
let parts: Vec<&str> = arg[1..].split('=').collect();
if parts.len() == 2 {
env::set_var(parts[0].to_uppercase(), parts[1]);
}
let args: Vec<String> = env::args().collect();
if args[0].ends_with(&scheme.to_string()) {
// if not exist, fallback to .env
let _ = dotenvy::from_filename_override(format!(".{scheme}.env"));
}
}

fn service(scheme: Scheme) -> Option<Operator> {
let test_key = format!("opendal_{}_test", scheme).to_uppercase();
if env::var(test_key).unwrap_or_default() != "on" {
return None;
}
Expand Down

0 comments on commit 36e74a8

Please sign in to comment.