Skip to content

Commit

Permalink
Make integration tests asynchronous
Browse files Browse the repository at this point in the history
  • Loading branch information
pfoerster committed Jun 11, 2019
1 parent 781c350 commit 42a045e
Show file tree
Hide file tree
Showing 9 changed files with 615 additions and 482 deletions.
323 changes: 277 additions & 46 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ nom = "5.0.0-beta2"
path-clean = "0.1.0"
regex = "1.1.6"
reqwest = "0.9.16"
runtime = "0.3.0-alpha.4"
serde = { version = "1.0.90", features = ["derive", "rc"] }
serde_json = "1.0.39"
serde_repr = "0.1"
Expand Down
73 changes: 32 additions & 41 deletions tests/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![feature(async_await)]

use futures::executor::block_on;
use jsonrpc::server::ActionHandler;
use lsp_types::*;
use texlab::build::*;
Expand Down Expand Up @@ -28,50 +27,42 @@ async fn run(
(scenario, result)
}

#[test]
fn test_success() {
block_on(async move {
let (scenario, result) = run("latexmk", false, "bar.tex").await;
assert_eq!(result.status, BuildStatus::Success);
let path = scenario.directory.path().join("foo.pdf");
assert!(path.exists());
});
#[runtime::test]
async fn test_success() {
let (scenario, result) = run("latexmk", false, "bar.tex").await;
assert_eq!(result.status, BuildStatus::Success);
let path = scenario.directory.path().join("foo.pdf");
assert!(path.exists());
}

#[test]
fn test_error() {
block_on(async move {
let (_, result) = run("latexmk", false, "baz.tex").await;
assert_eq!(result.status, BuildStatus::Error);
})
#[runtime::test]
async fn test_error() {
let (_, result) = run("latexmk", false, "baz.tex").await;
assert_eq!(result.status, BuildStatus::Error);
}

#[test]
fn test_failure() {
block_on(async move {
let (_, result) = run("foobarbaz", false, "foo.tex").await;
assert_eq!(result.status, BuildStatus::Failure);
});
#[runtime::test]
async fn test_failure() {
let (_, result) = run("foobarbaz", false, "foo.tex").await;
assert_eq!(result.status, BuildStatus::Failure);
}

#[test]
fn test_on_save() {
block_on(async move {
let scenario = Scenario::new("build").await;
scenario.open("foo.tex").await;
let mut build_options = BuildOptions::default();
build_options.args.push("--view=none".to_owned());
build_options.on_save = true;
{
let mut options = scenario.client.options.lock().await;
options.latex_build = Some(build_options);
}
let text_document = TextDocumentIdentifier::new(scenario.uri("foo.tex"));
scenario
.server
.did_save(DidSaveTextDocumentParams { text_document });
scenario.server.execute_actions().await;
let path = scenario.directory.path().join("foo.pdf");
assert!(path.exists());
});
#[runtime::test]
async fn test_on_save() {
let scenario = Scenario::new("build").await;
scenario.open("foo.tex").await;
let mut build_options = BuildOptions::default();
build_options.args.push("--view=none".to_owned());
build_options.on_save = true;
{
let mut options = scenario.client.options.lock().await;
options.latex_build = Some(build_options);
}
let text_document = TextDocumentIdentifier::new(scenario.uri("foo.tex"));
scenario
.server
.did_save(DidSaveTextDocumentParams { text_document });
scenario.server.execute_actions().await;
let path = scenario.directory.path().join("foo.pdf");
assert!(path.exists());
}
Loading

0 comments on commit 42a045e

Please sign in to comment.