just/tests
Casey Rodarmor bdf1c92251
Automatically track expected tokens while parsing (#711)
Remove all manual tracking of which tokens would have been accepted by
the parser in favor of having the parser add tokens that it checks for
to a set of expected tokens, clearing them when it accepts a token, and
using the current contents of the set in error messages.

This is a massive improvement, and will make the parser easier to
modify going forward.

And, this actually solves my sole issue with hand-written parsers.

Thanks to matklad on reddit for suggesting this!
2020-10-25 19:37:26 -07:00
..
choose.rs Allow choosing multiple recipes to run (#700) 2020-10-10 17:54:58 -07:00
common.rs Add the --choose subcommand (#680) 2020-09-17 19:43:04 -07:00
completions.rs Don't require justfile to print completions (#596) 2020-02-20 06:07:25 -08:00
dotenv.rs Search for .env file from working directory (#661) 2020-07-19 05:01:46 -07:00
edit.rs Add the --choose subcommand (#680) 2020-09-17 19:43:04 -07:00
examples.rs Test that example justfiles successfully parse (#643) 2020-06-09 22:57:16 -07:00
init.rs Add missing --init test (#543) 2019-11-20 01:35:29 -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
lib.rs Add the --choose subcommand (#680) 2020-09-17 19:43:04 -07:00
misc.rs Automatically track expected tokens while parsing (#711) 2020-10-25 19:37:26 -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
test.rs Add the --choose subcommand (#680) 2020-09-17 19:43:04 -07:00
working_directory.rs Wrap comments at 80 characters (#593) 2020-02-14 04:49:25 -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);
  }
}