Skip to content

Commit

Permalink
Integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
neunenak committed Jan 11, 2023
1 parent cd0cd8d commit ac4d25f
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ mod json;
mod line_prefixes;
mod misc;
mod multibyte_char;
mod multiple_justfiles;
mod no_cd;
mod no_exit_message;
mod os_attributes;
Expand Down
77 changes: 77 additions & 0 deletions tests/multiple_justfiles.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
use super::*;

#[test]
fn single_justfile_with_slash_syntax() {
let justfile_contents = unindent(
r#"
recipe_a:
echo "A"
recipe_b:
echo "B"
"#,
);
let tmp = temptree! {
subdir: {
justfile: justfile_contents
}
};

for arg_list in [
["subdir/recipe_a", "recipe_b"],
["subdir/recipe_a", "subdir/recipe_b"],
] {
let mut command = Command::new(executable_path("just"));
command.current_dir(tmp.path());

for arg in arg_list {
command.arg(arg);
}

let output = command.output().unwrap();

let stdout = String::from_utf8(output.stdout).unwrap();

assert!(output.status.success());
assert_eq!(stdout, "A\nB\n");
}
}

#[test]
fn multiple_justfiles_with_slash_syntax() {
let justfile_contents1 = unindent(
r#"
recipe_a:
echo "A"
"#,
);
let justfile_contents2 = unindent(
r#"
recipe_b:
echo "B"
"#,
);
let tmp = temptree! {
subdir: {
justfile: justfile_contents1
},
subdir2: {
justfile: justfile_contents2
}
};

let output = Command::new(executable_path("just"))
.current_dir(tmp.path())
.arg("subdir/recipe_a")
.arg("subdir2/recipe_b")
.output()
.unwrap();

let stderr = String::from_utf8(output.stderr).unwrap();

assert_eq!(
stderr,
"error: Conflicting path arguments: `subdir/` and `subdir2/`\n"
);
}

0 comments on commit ac4d25f

Please sign in to comment.