Skip to content

Commit

Permalink
feat: ✨ Fix issue with std test and optimise error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ddanier committed Oct 16, 2024
1 parent d9d604d commit af3c284
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
22 changes: 10 additions & 12 deletions src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ impl NurEngine {
} else {
if let Some(err) = working_set.parse_errors.first() {
report_parse_error(&working_set, err);
std::process::exit(1);
}

Err(NurError::ParseErrors(working_set.parse_errors))
Expand Down Expand Up @@ -467,17 +466,6 @@ mod tests {
assert!(engine_state.get_env_var("NU_VERSION").is_some());
}

#[test]
fn test_init_engine_state_will_add_std_lib() {
let temp_dir = tempdir().unwrap();
let temp_dir_path = temp_dir.path().to_path_buf();
let engine_state = init_engine_state(&temp_dir_path).unwrap();

assert!(engine_state
.find_module("std".as_bytes(), &[vec![]],)
.is_some());
}

#[test]
fn test_init_engine_state_will_set_flags() {
let temp_dir = tempdir().unwrap();
Expand Down Expand Up @@ -535,6 +523,16 @@ mod tests {
nur_engine.stack.get_var(*var_id, Span::unknown()).is_ok()
}

#[test]
fn test_nur_engine_will_include_std_lib() {
let temp_dir = tempdir().unwrap();
let mut nur_engine = _prepare_nur_engine(&temp_dir);

assert!(nur_engine.eval("use std", PipelineData::empty()).is_ok());

_cleanup_nur_engine(&temp_dir);
}

#[test]
fn test_nur_engine_will_set_nur_variable() {
let temp_dir = tempdir().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub enum NurError {
#[diagnostic()]
ShellError(#[from] ShellError),

#[error("Parse Error {0:?}")]
#[error("Parse Errors")]
#[diagnostic()]
ParseErrors(#[related] Vec<ParseError>),

Expand Down

0 comments on commit af3c284

Please sign in to comment.