-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for crashing neovim with linebuffering
- Loading branch information
1 parent
c5cfcc9
commit 7ea91dc
Showing
5 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
use nvim_rs::{ | ||
create::tokio as create, | ||
rpc::handler::Dummy as DummyHandler | ||
}; | ||
|
||
|
||
#[tokio::main] | ||
async fn main() { | ||
let handler = DummyHandler::new(); | ||
let (nvim, _io_handler) = create::new_parent(handler).await.unwrap(); | ||
let curbuf = nvim.get_current_buf().await.unwrap(); | ||
|
||
// If our Stdout is linebuffered, this has a high chance of crashing neovim | ||
// Should probably befixed in neovim itself, but for now, let's just make | ||
// sure we're not using linebuffering, or at least don't crash neovim with | ||
// this. | ||
for i in 0..20 { | ||
curbuf.set_name(&format!("a{i}")).await.unwrap(); | ||
} | ||
|
||
let _ = nvim.command("quit!").await; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
use nvim_rs::{ | ||
create::async_std as create, | ||
rpc::handler::Dummy as DummyHandler | ||
}; | ||
|
||
|
||
#[async_std::main] | ||
async fn main() { | ||
let handler = DummyHandler::new(); | ||
let (nvim, _io_handler) = create::new_parent(handler).await.unwrap(); | ||
let curbuf = nvim.get_current_buf().await.unwrap(); | ||
|
||
// If our Stdout is linebuffered, this has a high chance of crashing neovim | ||
// Should probably befixed in neovim itself, but for now, let's just make | ||
// sure we're not using linebuffering, or at least don't crash neovim with | ||
// this. | ||
for i in 0..20 { | ||
curbuf.set_name(&format!("a{i}")).await.unwrap(); | ||
} | ||
|
||
let _ = nvim.command("quit!").await; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#[path = "../common/mod.rs"] | ||
mod common; | ||
use common::*; | ||
|
||
use std::{path::PathBuf, process::Command}; | ||
|
||
fn viml_escape(in_str: &str) -> String { | ||
in_str.replace('\\', r"\\") | ||
} | ||
|
||
fn linebuffercrashbin() -> &'static str { | ||
#[cfg(feature = "use_tokio")] | ||
return "linebuffercrash"; | ||
#[cfg(feature = "use_async-std")] | ||
return "linebuffercrash_as"; | ||
} | ||
|
||
#[test] | ||
fn linebuffer_crash() { | ||
let c1 = format!( | ||
"let jobid = jobstart([\"{}\"], {{\"rpc\": v:true}})", | ||
viml_escape( | ||
PathBuf::from(env!("CARGO_MANIFEST_DIR")) | ||
.join("target") | ||
.join("debug") | ||
.join(linebuffercrashbin()) | ||
.to_str() | ||
.unwrap() | ||
) | ||
); | ||
|
||
let status = Command::new(nvim_path()) | ||
.args(&[ | ||
"-u", | ||
"NONE", | ||
"--headless", | ||
"-c", | ||
&c1, | ||
]) | ||
.status() | ||
.unwrap(); | ||
|
||
assert!(status.success()); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#[cfg(feature = "use_tokio")] | ||
pub mod buffering; | ||
#[cfg(feature = "use_async-std")] | ||
pub mod buffering; |