just/tests
Casey Rodarmor d0e813cd8b
Add flags to set and clear shell arguments (#551)
Add the `--shell-arg` and `--clear-shell-args` flags, which allow
setting and clearing arguments to the shell from the command line.

This allows full control over the shell from the command line. Additionally,
any shell-related arguments on the command line override
 `set shell := [...]` in the Justfile, which I think will be the behavior that most
people expect.
2019-11-22 13:33:56 -06:00
..
edit.rs Gargantuan refactor (#522) 2019-11-09 21:43:20 -08:00
init.rs Add missing --init test (#543) 2019-11-20 01:35:29 -06:00
integration.rs Add flags to set and clear shell arguments (#551) 2019-11-22 13:33:56 -06:00
interrupts.rs Gargantuan refactor (#522) 2019-11-09 21:43:20 -08:00
invocation_directory.rs Refactor lexer tests (#498) 2019-10-17 20:04:54 -07:00
readme.rs Reform positional argument parsing (#523) 2019-11-10 18:02:36 -08:00
search.rs Reform positional argument parsing (#523) 2019-11-10 18:02:36 -08:00
shell.rs Add shell setting (#525) 2019-11-10 23:17:47 -08:00
working_directory.rs Gargantuan refactor (#522) 2019-11-09 21:43:20 -08: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);
  }
}