-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
69 additions
and
35 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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
pub mod bytecode; | ||
mod rpcio; | ||
pub mod rpcio; | ||
mod lsp_message; | ||
pub mod app; |
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,35 @@ | ||
use anyhow::Result; | ||
use tempfile; | ||
use env_logger; | ||
|
||
use emacs_lsp_booster::{app, rpcio}; | ||
|
||
#[test] | ||
fn test_app_with_echo_server() -> Result<()> { | ||
env_logger::init(); | ||
|
||
let (input_pair_in, input_pair_out) = std::os::unix::net::UnixStream::pair()?; | ||
let tmpdir = tempfile::tempdir()?; | ||
let output_file = std::fs::File::create(tmpdir.path().join("output.txt"))?; | ||
|
||
std::thread::spawn(move || { | ||
let mut input_bufwriter = std::io::BufWriter::new(input_pair_in); | ||
for _ in 0..10 { | ||
rpcio::rpc_write(&mut input_bufwriter, "{}").unwrap(); | ||
} | ||
loop { | ||
std::thread::park(); | ||
} | ||
}); | ||
|
||
let mut cmd = std::process::Command::new("timeout"); | ||
cmd.args(&["1", "cat"]); | ||
|
||
let exit_status = app::run_app_forever(input_pair_out, output_file, cmd)?; | ||
assert!(!exit_status.success()); // timeout kill | ||
|
||
let output = std::fs::read_to_string(tmpdir.path().join("output.txt"))?; | ||
assert_eq!(output.chars().filter(|x| *x == '#').count(), 10); | ||
|
||
Ok(()) | ||
} |