Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore chooser tests #1513

Merged
merged 2 commits into from
Jan 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,17 @@ build-book:
mdbook build book/en
mdbook build book/zh

convert-integration-test test:
cargo expand --test integration {{test}} | \
sed \
-E \
-e 's/#\[cfg\(test\)\]/#\[test\]/' \
-e 's/^ *let test = //' \
-e 's/^ *test[.]/./' \
-e 's/;$//' \
-e 's/crate::test::Test/Test/' \
-e 's/\.run\(\)/.run();/'

# run all polyglot recipes
polyglot: _python _js _perl _sh _ruby
# (recipes that start with `_` are hidden from --list)
Expand Down
224 changes: 125 additions & 99 deletions tests/choose.rs
Original file line number Diff line number Diff line change
@@ -1,116 +1,142 @@
use super::*;

test! {
name: env,
justfile: "
foo:
echo foo

bar:
echo bar
",
args: ("--choose"),
env: {
"JUST_CHOOSER": "head -n1",
},
stdout: "bar\n",
stderr: "echo bar\n",
#[test]
fn env() {
Test::new()
.arg("--choose")
.env("JUST_CHOOSER", "head -n1")
.justfile(
"
foo:
echo foo

bar:
echo bar
",
)
.stderr("echo bar\n")
.stdout("bar\n")
.run();
}

test! {
name: chooser,
justfile: "
foo:
echo foo

bar:
echo bar
",
args: ("--choose", "--chooser", "head -n1"),
stdout: "bar\n",
stderr: "echo bar\n",
#[test]
fn chooser() {
Test::new()
.arg("--choose")
.arg("--chooser")
.arg("head -n1")
.justfile(
"
foo:
echo foo

bar:
echo bar
",
)
.stderr("echo bar\n")
.stdout("bar\n")
.run();
}

test! {
name: override_variable,
justfile: "
baz := 'A'

foo:
echo foo

bar:
echo {{baz}}
",
args: ("--choose", "baz=B"),
env: {
"JUST_CHOOSER": "head -n1",
},
stdout: "B\n",
stderr: "echo B\n",
#[test]
fn override_variable() {
Test::new()
.arg("--choose")
.arg("baz=B")
.env("JUST_CHOOSER", "head -n1")
.justfile(
"
baz := 'A'

foo:
echo foo

bar:
echo {{baz}}
",
)
.stderr("echo B\n")
.stdout("B\n")
.run();
}

test! {
name: skip_private_recipes,
justfile: "
foo:
echo foo

_bar:
echo bar
",
args: ("--choose"),
env: {
"JUST_CHOOSER": "head -n1",
},
stdout: "foo\n",
stderr: "echo foo\n",
#[test]
fn skip_private_recipes() {
Test::new()
.arg("--choose")
.env("JUST_CHOOSER", "head -n1")
.justfile(
"
foo:
echo foo

_bar:
echo bar
",
)
.stderr("echo foo\n")
.stdout("foo\n")
.run();
}

test! {
name: skip_recipes_that_require_arguments,
justfile: "
foo:
echo foo

bar BAR:
echo {{BAR}}
",
args: ("--choose"),
env: {
"JUST_CHOOSER": "head -n1",
},
stdout: "foo\n",
stderr: "echo foo\n",
#[test]
fn skip_recipes_that_require_arguments() {
Test::new()
.arg("--choose")
.env("JUST_CHOOSER", "head -n1")
.justfile(
"
foo:
echo foo

bar BAR:
echo {{BAR}}
",
)
.stderr("echo foo\n")
.stdout("foo\n")
.run();
}

test! {
name: no_choosable_recipes,
justfile: "
_foo:
echo foo

bar BAR:
echo {{BAR}}
",
args: ("--choose"),
stdout: "",
stderr: "error: Justfile contains no choosable recipes.\n",
status: EXIT_FAILURE,
#[test]
fn no_choosable_recipes() {
crate::test::Test::new()
.arg("--choose")
.justfile(
"
_foo:
echo foo

bar BAR:
echo {{BAR}}
",
)
.status(EXIT_FAILURE)
.stderr("error: Justfile contains no choosable recipes.\n")
.stdout("")
.run();
}

test! {
name: multiple_recipes,
justfile: "
foo:
echo foo

bar:
echo bar
",
args: ("--choose", "--chooser", "echo foo bar"),
stdout: "foo\nbar\n",
stderr: "echo foo\necho bar\n",
#[test]
#[ignore]
fn multiple_recipes() {
Test::new()
.arg("--choose")
.arg("--chooser")
.arg("echo foo bar")
.justfile(
"
foo:
echo foo

bar:
echo bar
",
)
.stderr("echo foo\necho bar\n")
.stdout("foo\nbar\n")
.run();
}

#[test]
Expand Down