Skip to content

Commit

Permalink
[rust] Improve SM tests (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
bonigarcia committed Aug 9, 2023
1 parent 889df2d commit 4fa3ceb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
8 changes: 8 additions & 0 deletions rust/src/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,16 @@ pub fn unzip(
.into());
}

log.debug(format!("**** Deleting {}", compressed_path.display()));
remove_file(compressed_path)?;
log.debug(format!(
"**** Copying {} to {} (single file {:?})",
tmp_path.display(),
final_path.display(),
single_file
));
copy_folder_content(tmp_path, final_path, single_file)?;
log.debug("**** Done");

Ok(())
}
Expand Down
17 changes: 16 additions & 1 deletion rust/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// specific language governing permissions and limitations
// under the License.

use std::error::Error;
use std::process::exit;

use clap::Parser;
Expand Down Expand Up @@ -206,12 +207,26 @@ fn main() {
log.warn(err.to_string());
flush_and_exit(OK, log);
} else {
log.error(err.to_string());
log_error(&log, err);
flush_and_exit(DATAERR, log);
}
});
}

fn log_error(log: &Logger, err: Box<dyn Error>) {
let error_message = err.to_string();
let source = err.source();
if source.is_some() {
log.error(format!(
"{}. Caused by: {}",
error_message,
source.unwrap().to_string()
));
} else {
log.error(error_message);
}
}

fn flush_and_exit(code: i32, log: &Logger) -> ! {
log.set_code(code);
log.flush();
Expand Down

0 comments on commit 4fa3ceb

Please sign in to comment.