use std::process::Command; use assert_cmd::prelude::*; use predicates::prelude::*; use tempfile::NamedTempFile; #[test] fn gen() -> Result<(), Box> { let mut cmd = Command::cargo_bin("treeedbgen-souffle-javascript")?; let tmp = NamedTempFile::new()?; cmd.arg("-o").arg(tmp.path()); cmd.arg("--prefix=javascript").arg("--printsize"); cmd.assert() .success() .stdout(predicate::str::is_empty()) .stderr(predicate::str::is_empty()); let mut cmd = Command::cargo_bin("treeedb-javascript")?; cmd.arg("tests/js/hello-world.js"); cmd.assert() .success() .stdout(predicate::str::is_empty()) .stderr(predicate::str::is_empty()); let mut souffle = Command::new("souffle"); souffle.arg(tmp.path()); souffle .assert() .success() .stdout(predicate::str::contains("javascript_node\t9")) .stderr(predicate::str::is_empty()); Ok(()) }