aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--helix-term/tests/integration/commands.rs2
-rw-r--r--helix-term/tests/integration/helpers.rs25
-rw-r--r--helix-term/tests/integration/movement.rs15
-rw-r--r--helix-term/tests/integration/write.rs5
4 files changed, 26 insertions, 21 deletions
diff --git a/helix-term/tests/integration/commands.rs b/helix-term/tests/integration/commands.rs
index 4ab87b9b..0d2e14fd 100644
--- a/helix-term/tests/integration/commands.rs
+++ b/helix-term/tests/integration/commands.rs
@@ -59,7 +59,7 @@ async fn test_buffer_close() -> anyhow::Result<()> {
.await?;
// verify if writes are queued up, it finishes them before closing the buffer
- let mut file = tempfile::NamedTempFile::new().unwrap();
+ let mut file = tempfile::NamedTempFile::new()?;
let mut command = String::new();
const RANGE: RangeInclusive<i32> = 1..=10;
diff --git a/helix-term/tests/integration/helpers.rs b/helix-term/tests/integration/helpers.rs
index 29cb8cd8..2a542404 100644
--- a/helix-term/tests/integration/helpers.rs
+++ b/helix-term/tests/integration/helpers.rs
@@ -81,8 +81,10 @@ pub async fn test_key_sequence_with_input_text<T: Into<TestCase>>(
test_fn: &dyn Fn(&Application),
) -> anyhow::Result<()> {
let test_case = test_case.into();
- let mut app =
- app.unwrap_or_else(|| Application::new(Args::default(), Config::default()).unwrap());
+ let mut app = match app {
+ Some(app) => app,
+ None => Application::new(Args::default(), Config::default())?,
+ };
let (view, doc) = helix_view::current!(app.editor);
let sel = doc.selection(view.id).clone();
@@ -108,7 +110,7 @@ pub async fn test_key_sequence_text_result<T: Into<TestCase>>(
test_case: T,
) -> anyhow::Result<()> {
let test_case = test_case.into();
- let app = Application::new(args, config).unwrap();
+ let app = Application::new(args, config)?;
test_key_sequence_with_input_text(Some(app), test_case.clone(), &|app| {
let doc = doc!(app.editor);
@@ -123,13 +125,16 @@ pub async fn test_key_sequence_text_result<T: Into<TestCase>>(
.await
}
-pub fn temp_file_with_contents<S: AsRef<str>>(content: S) -> tempfile::NamedTempFile {
- let mut temp_file = tempfile::NamedTempFile::new().unwrap();
+pub fn temp_file_with_contents<S: AsRef<str>>(
+ content: S,
+) -> anyhow::Result<tempfile::NamedTempFile> {
+ let mut temp_file = tempfile::NamedTempFile::new()?;
+
temp_file
.as_file_mut()
- .write_all(content.as_ref().as_bytes())
- .unwrap();
- temp_file.flush().unwrap();
- temp_file.as_file_mut().sync_all().unwrap();
- temp_file
+ .write_all(content.as_ref().as_bytes())?;
+
+ temp_file.flush()?;
+ temp_file.as_file_mut().sync_all()?;
+ Ok(temp_file)
}
diff --git a/helix-term/tests/integration/movement.rs b/helix-term/tests/integration/movement.rs
index cac10852..e0bfc3bf 100644
--- a/helix-term/tests/integration/movement.rs
+++ b/helix-term/tests/integration/movement.rs
@@ -109,8 +109,8 @@ async fn insert_to_normal_mode_cursor_position() -> anyhow::Result<()> {
/// the first grapheme
#[tokio::test]
async fn cursor_position_newly_opened_file() -> anyhow::Result<()> {
- let test = |content: &str, expected_sel: Selection| {
- let file = helpers::temp_file_with_contents(content);
+ let test = |content: &str, expected_sel: Selection| -> anyhow::Result<()> {
+ let file = helpers::temp_file_with_contents(content)?;
let mut app = Application::new(
Args {
@@ -118,17 +118,18 @@ async fn cursor_position_newly_opened_file() -> anyhow::Result<()> {
..Default::default()
},
Config::default(),
- )
- .unwrap();
+ )?;
let (view, doc) = helix_view::current!(app.editor);
let sel = doc.selection(view.id).clone();
assert_eq!(expected_sel, sel);
+
+ Ok(())
};
- test("foo", Selection::single(0, 1));
- test("๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ foo", Selection::single(0, 7));
- test("", Selection::single(0, 0));
+ test("foo", Selection::single(0, 1))?;
+ test("๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ foo", Selection::single(0, 7))?;
+ test("", Selection::single(0, 0))?;
Ok(())
}
diff --git a/helix-term/tests/integration/write.rs b/helix-term/tests/integration/write.rs
index 0cc41dbc..4f8f0eb5 100644
--- a/helix-term/tests/integration/write.rs
+++ b/helix-term/tests/integration/write.rs
@@ -11,7 +11,7 @@ use super::*;
#[tokio::test]
async fn test_write() -> anyhow::Result<()> {
- let mut file = tempfile::NamedTempFile::new().unwrap();
+ let mut file = tempfile::NamedTempFile::new()?;
test_key_sequence(
&mut Application::new(
@@ -38,7 +38,7 @@ async fn test_write() -> anyhow::Result<()> {
#[tokio::test]
async fn test_write_concurrent() -> anyhow::Result<()> {
- let mut file = tempfile::NamedTempFile::new().unwrap();
+ let mut file = tempfile::NamedTempFile::new()?;
let mut command = String::new();
const RANGE: RangeInclusive<i32> = 1..=5000;
@@ -112,7 +112,6 @@ async fn test_write_fail_mod_flag() -> anyhow::Result<()> {
}
#[tokio::test]
-#[ignore]
async fn test_write_fail_new_path() -> anyhow::Result<()> {
test_key_sequences(
&mut Application::new(Args::default(), Config::default())?,