From 1a3c2e2f1dc5add94b5b7ff4ba4c26df55c7a011 Mon Sep 17 00:00:00 2001 From: Nick Hanley Date: Thu, 16 Mar 2023 12:22:24 -0400 Subject: feat(repl): add `DENO_REPL_HISTORY` to change history file path (#18047) --- cli/tests/integration/repl_tests.rs | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'cli/tests') diff --git a/cli/tests/integration/repl_tests.rs b/cli/tests/integration/repl_tests.rs index aafb3bb48..52510a637 100644 --- a/cli/tests/integration/repl_tests.rs +++ b/cli/tests/integration/repl_tests.rs @@ -654,6 +654,52 @@ fn missing_deno_dir() { assert!(err.is_empty()); } +#[test] +fn custom_history_path() { + use std::fs::read; + let temp_dir = TempDir::new(); + let history_path = temp_dir.path().join("history.txt"); + let (out, err) = util::run_and_collect_output( + true, + "repl", + Some(vec!["1"]), + Some(vec![ + ( + "DENO_REPL_HISTORY".to_owned(), + history_path.to_str().unwrap().to_owned(), + ), + ("NO_COLOR".to_owned(), "1".to_owned()), + ]), + false, + ); + assert!(read(&history_path).is_ok()); + assert_ends_with!(out, "1\n"); + assert!(err.is_empty()); +} + +#[test] +fn disable_history_file() { + let deno_dir = util::new_deno_dir(); + let default_history_path = deno_dir.path().join("deno_history.txt"); + let (out, err) = util::run_and_collect_output( + true, + "repl", + Some(vec!["1"]), + Some(vec![ + ( + "DENO_DIR".to_owned(), + deno_dir.path().to_str().unwrap().to_owned(), + ), + ("DENO_REPL_HISTORY".to_owned(), "".to_owned()), + ("NO_COLOR".to_owned(), "1".to_owned()), + ]), + false, + ); + assert!(!default_history_path.try_exists().unwrap()); + assert_ends_with!(out, "1\n"); + assert!(err.is_empty()); +} + #[test] fn save_last_eval() { let (out, err) = util::run_and_collect_output( -- cgit v1.2.3