mirror of
https://github.com/Noratrieb/haesli.git
synced 2026-01-14 19:55:03 +01:00
improve integration tests
This commit is contained in:
parent
800ccae604
commit
05f08aa9db
1 changed files with 15 additions and 5 deletions
|
|
@ -1,25 +1,35 @@
|
||||||
use crate::project_root;
|
use crate::project_root;
|
||||||
use anyhow::{ensure, Context, Result};
|
use anyhow::{ensure, Context, Result};
|
||||||
use std::{path::Path, process::Command};
|
use std::{path::Path, process::Command, thread::sleep, time::Duration};
|
||||||
|
|
||||||
pub fn main() -> Result<()> {
|
pub fn main() -> Result<()> {
|
||||||
let project_root = project_root();
|
let project_root = project_root();
|
||||||
let test_js_root = project_root.join("test-js");
|
let test_js_root = project_root.join("test-js");
|
||||||
|
|
||||||
let mut amqp_server = Command::new("cargo")
|
println!("$ cargo build");
|
||||||
.arg("run")
|
let status = Command::new("cargo")
|
||||||
|
.arg("build")
|
||||||
|
.status()
|
||||||
|
.context("cargo build")?;
|
||||||
|
ensure!(status.success(), "cargo build failed");
|
||||||
|
|
||||||
|
let mut amqp_server = Command::new("target/debug/amqp")
|
||||||
.env("RUST_LOG", "trace")
|
.env("RUST_LOG", "trace")
|
||||||
.spawn()
|
.spawn()
|
||||||
.context("`cargo run` amqp")?;
|
.context("target/debug/amqp run")?;
|
||||||
|
|
||||||
|
// give it time for startup
|
||||||
|
sleep(Duration::from_secs(1));
|
||||||
|
|
||||||
let test_result = run_js(&test_js_root);
|
let test_result = run_js(&test_js_root);
|
||||||
|
|
||||||
amqp_server.kill()?;
|
amqp_server.kill().context("killing amqp server")?;
|
||||||
|
|
||||||
test_result
|
test_result
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_js(test_js_root: &Path) -> Result<()> {
|
fn run_js(test_js_root: &Path) -> Result<()> {
|
||||||
|
println!("$ yarn");
|
||||||
let status = Command::new("yarn")
|
let status = Command::new("yarn")
|
||||||
.current_dir(&test_js_root)
|
.current_dir(&test_js_root)
|
||||||
.status()
|
.status()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue