2021-05-16 00:33:41 -05:00
..
2021-05-10 03:35:35 +00:00
2021-05-10 03:35:35 +00:00
2021-03-30 17:59:15 -07:00
2020-09-17 19:43:04 -07:00
2021-03-28 22:38:07 -07:00
2019-11-20 01:35:29 -06:00
2021-05-11 12:21:49 -07:00
2021-03-28 22:38:07 -07:00

use std::{fs, process::Command};

use executable_path::executable_path;
use test_utilities::{assert_success, tempdir};

#[test]
fn readme() {
  let mut justfiles = vec![];
  let mut current = None;

  for line in fs::read_to_string("README.adoc").unwrap().lines() {
    if let Some(mut justfile) = current {
      if line == "```" {
        justfiles.push(justfile);
        current = None;
      } else {
        justfile += line;
        justfile += "\n";
        current = Some(justfile);
      }
    } else if line == "```make" {
      current = Some(String::new());
    }
  }

  for justfile in justfiles {
    let tmp = tempdir();

    let path = tmp.path().join("justfile");

    fs::write(&path, &justfile).unwrap();

    let output = Command::new(executable_path("just"))
      .current_dir(tmp.path())
      .arg("--dump")
      .output()
      .unwrap();

    assert_success(&output);
  }
}