You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. use eyre::ContextCompat;
  2. use std::path::{Path, PathBuf};
  3. use xshell::{cmd, Shell};
  4. #[tokio::main]
  5. async fn main() -> eyre::Result<()> {
  6. // create a new shell in this folder
  7. let sh = prepare_shell()?;
  8. // build the `dora` binary (you can skip this if you use `cargo install dora-cli`)
  9. let dora = prepare_dora(&sh)?;
  10. // build the dataflow using `dora build`
  11. cmd!(sh, "{dora} build dataflow.yml").run()?;
  12. // start up the dora daemon and coordinator
  13. cmd!(sh, "{dora} up").run()?;
  14. // start running the dataflow.yml -> outputs the UUID assigned to the dataflow
  15. let output = cmd!(sh, "{dora} start dataflow.yml --attach").read_stderr()?;
  16. let uuid = output.lines().next().context("no output")?;
  17. // stop the dora daemon and coordinator again
  18. cmd!(sh, "{dora} destroy").run()?;
  19. // verify that the node output was written to `out`
  20. sh.change_dir("out");
  21. sh.change_dir(uuid);
  22. let sink_output = sh.read_file("log_rust-node.txt")?;
  23. if !sink_output
  24. .lines()
  25. .any(|l| l.starts_with("received pose event: Ok("))
  26. {
  27. eyre::bail!("node did not receive any pose events")
  28. }
  29. Ok(())
  30. }
  31. /// Prepares a shell and set the working directory to the parent folder of this file.
  32. ///
  33. /// You can use your system shell instead (e.g. `bash`);
  34. fn prepare_shell() -> Result<Shell, eyre::Error> {
  35. let sh = Shell::new()?;
  36. let root = Path::new(env!("CARGO_MANIFEST_DIR"));
  37. sh.change_dir(root.join(file!()).parent().unwrap());
  38. Ok(sh)
  39. }
  40. /// Build the `dora` command-line executable from this repo.
  41. ///
  42. /// You can skip this step and run `cargo install dora-cli --locked` instead.
  43. fn prepare_dora(sh: &Shell) -> eyre::Result<PathBuf> {
  44. cmd!(sh, "cargo build --package dora-cli").run()?;
  45. let root = Path::new(env!("CARGO_MANIFEST_DIR"));
  46. let dora = root.join("target").join("debug").join("dora");
  47. Ok(dora)
  48. }