Ignore chooser tests (#1513)

This commit is contained in:
Casey Rodarmor 2023-01-16 00:42:34 -08:00 committed by GitHub
parent 42b4c084c4
commit fdf4b5b859
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 128 additions and 91 deletions

View File

@ -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)

View File

@ -1,116 +1,142 @@
use super::*;
test! {
name: env,
justfile: "
foo:
echo foo
#[test]
fn env() {
Test::new()
.arg("--choose")
.env("JUST_CHOOSER", "head -n1")
.justfile(
"
foo:
echo foo
bar:
echo bar
",
args: ("--choose"),
env: {
"JUST_CHOOSER": "head -n1",
},
stdout: "bar\n",
stderr: "echo bar\n",
bar:
echo bar
",
)
.stderr("echo bar\n")
.stdout("bar\n")
.run();
}
test! {
name: chooser,
justfile: "
foo:
echo foo
#[test]
fn chooser() {
Test::new()
.arg("--choose")
.arg("--chooser")
.arg("head -n1")
.justfile(
"
foo:
echo foo
bar:
echo bar
",
args: ("--choose", "--chooser", "head -n1"),
stdout: "bar\n",
stderr: "echo bar\n",
bar:
echo bar
",
)
.stderr("echo bar\n")
.stdout("bar\n")
.run();
}
test! {
name: override_variable,
justfile: "
baz := 'A'
#[test]
fn override_variable() {
Test::new()
.arg("--choose")
.arg("baz=B")
.env("JUST_CHOOSER", "head -n1")
.justfile(
"
baz := 'A'
foo:
echo foo
foo:
echo foo
bar:
echo {{baz}}
",
args: ("--choose", "baz=B"),
env: {
"JUST_CHOOSER": "head -n1",
},
stdout: "B\n",
stderr: "echo B\n",
bar:
echo {{baz}}
",
)
.stderr("echo B\n")
.stdout("B\n")
.run();
}
test! {
name: skip_private_recipes,
justfile: "
foo:
echo foo
#[test]
fn skip_private_recipes() {
Test::new()
.arg("--choose")
.env("JUST_CHOOSER", "head -n1")
.justfile(
"
foo:
echo foo
_bar:
echo bar
",
args: ("--choose"),
env: {
"JUST_CHOOSER": "head -n1",
},
stdout: "foo\n",
stderr: "echo foo\n",
_bar:
echo bar
",
)
.stderr("echo foo\n")
.stdout("foo\n")
.run();
}
test! {
name: skip_recipes_that_require_arguments,
justfile: "
foo:
echo foo
#[test]
fn skip_recipes_that_require_arguments() {
Test::new()
.arg("--choose")
.env("JUST_CHOOSER", "head -n1")
.justfile(
"
foo:
echo foo
bar BAR:
echo {{BAR}}
",
args: ("--choose"),
env: {
"JUST_CHOOSER": "head -n1",
},
stdout: "foo\n",
stderr: "echo foo\n",
bar BAR:
echo {{BAR}}
",
)
.stderr("echo foo\n")
.stdout("foo\n")
.run();
}
test! {
name: no_choosable_recipes,
justfile: "
_foo:
echo foo
#[test]
fn no_choosable_recipes() {
crate::test::Test::new()
.arg("--choose")
.justfile(
"
_foo:
echo foo
bar BAR:
echo {{BAR}}
",
args: ("--choose"),
stdout: "",
stderr: "error: Justfile contains no choosable recipes.\n",
status: EXIT_FAILURE,
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
#[test]
#[ignore]
fn multiple_recipes() {
Test::new()
.arg("--choose")
.arg("--chooser")
.arg("echo foo bar")
.justfile(
"
foo:
echo foo
bar:
echo bar
",
args: ("--choose", "--chooser", "echo foo bar"),
stdout: "foo\nbar\n",
stderr: "echo foo\necho bar\n",
bar:
echo bar
",
)
.stderr("echo foo\necho bar\n")
.stdout("foo\nbar\n")
.run();
}
#[test]