From fdf4b5b859a4f0dddba3d816e443cfbdcdcac3dc Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Mon, 16 Jan 2023 00:42:34 -0800 Subject: [PATCH] Ignore chooser tests (#1513) --- justfile | 11 +++ tests/choose.rs | 208 +++++++++++++++++++++++++++--------------------- 2 files changed, 128 insertions(+), 91 deletions(-) diff --git a/justfile b/justfile index 3f29b9ce..52b4ee1f 100755 --- a/justfile +++ b/justfile @@ -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) diff --git a/tests/choose.rs b/tests/choose.rs index b7e9f442..9dd0b19e 100644 --- a/tests/choose.rs +++ b/tests/choose.rs @@ -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]