Remove dotenv_load from tests (#853)

This commit is contained in:
Casey Rodarmor 2021-06-03 01:12:39 -04:00 committed by GitHub
parent 0a9ffd7a7b
commit 28fdd36430
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 35 deletions

View File

@ -83,7 +83,7 @@ push: check
git push github git push github
pr: push pr: push
hub pull-request -o gh pr create --web
# clean up feature branch BRANCH # clean up feature branch BRANCH
done BRANCH=`git rev-parse --abbrev-ref HEAD`: done BRANCH=`git rev-parse --abbrev-ref HEAD`:

View File

@ -37,7 +37,6 @@ test! {
"#, "#,
stdout: "undefined\n", stdout: "undefined\n",
stderr: "if [ -n \"${DOTENV_KEY+1}\" ]; then echo defined; else echo undefined; fi\n", stderr: "if [ -n \"${DOTENV_KEY+1}\" ]; then echo defined; else echo undefined; fi\n",
dotenv_load: false,
} }
test! { test! {
@ -50,7 +49,6 @@ test! {
"#, "#,
stdout: "dotenv-value\n", stdout: "dotenv-value\n",
stderr: "echo $DOTENV_KEY\n", stderr: "echo $DOTENV_KEY\n",
dotenv_load: false,
} }
test! { test! {
@ -63,7 +61,6 @@ test! {
"#, "#,
stdout: "dotenv-value\n", stdout: "dotenv-value\n",
stderr: "echo $DOTENV_KEY\n", stderr: "echo $DOTENV_KEY\n",
dotenv_load: false,
} }
// Un-comment this on 2021-07-01. // Un-comment this on 2021-07-01.
@ -89,5 +86,4 @@ test! {
// See https://github.com/casey/just/issues/469 for more details. // See https://github.com/casey/just/issues/469 for more details.
// echo $DOTENV_KEY // echo $DOTENV_KEY
// ", // ",
// dotenv_load: false,
// } // }

View File

@ -1949,14 +1949,10 @@ test! {
stdout: " stdout: "
default stdin = `cat justfile`: default stdin = `cat justfile`:
echo {{stdin}} echo {{stdin}}
set dotenv-load := true
", ",
stderr: " stderr: "
echo 'default stdin = `cat justfile`: echo 'default stdin = `cat justfile`:
echo '{{stdin}}' echo '{{stdin}}''
set dotenv-load := true'
", ",
} }

View File

@ -15,7 +15,6 @@ macro_rules! test {
$(stderr: $stderr:expr,)? $(stderr: $stderr:expr,)?
$(status: $status:expr,)? $(status: $status:expr,)?
$(shell: $shell:expr,)? $(shell: $shell:expr,)?
$(dotenv_load: $dotenv_load:expr,)?
) => { ) => {
#[test] #[test]
fn $name() { fn $name() {
@ -32,7 +31,6 @@ macro_rules! test {
$(stderr: $stderr,)? $(stderr: $stderr,)?
$(status: $status,)? $(status: $status,)?
$(shell: $shell,)? $(shell: $shell,)?
$(dotenv_load: $dotenv_load,)?
env, env,
..crate::test::Test::default() ..crate::test::Test::default()
}.run(); }.run();
@ -41,29 +39,27 @@ macro_rules! test {
} }
pub(crate) struct Test<'a> { pub(crate) struct Test<'a> {
pub(crate) justfile: &'a str, pub(crate) justfile: &'a str,
pub(crate) args: &'a [&'a str], pub(crate) args: &'a [&'a str],
pub(crate) env: BTreeMap<String, String>, pub(crate) env: BTreeMap<String, String>,
pub(crate) stdin: &'a str, pub(crate) stdin: &'a str,
pub(crate) stdout: &'a str, pub(crate) stdout: &'a str,
pub(crate) stderr: &'a str, pub(crate) stderr: &'a str,
pub(crate) status: i32, pub(crate) status: i32,
pub(crate) shell: bool, pub(crate) shell: bool,
pub(crate) dotenv_load: bool,
} }
impl<'a> Default for Test<'a> { impl<'a> Default for Test<'a> {
fn default() -> Test<'a> { fn default() -> Test<'a> {
Test { Test {
justfile: "", justfile: "",
args: &[], args: &[],
env: BTreeMap::new(), env: BTreeMap::new(),
stdin: "", stdin: "",
stdout: "", stdout: "",
stderr: "", stderr: "",
status: EXIT_SUCCESS, status: EXIT_SUCCESS,
shell: true, shell: true,
dotenv_load: true,
} }
} }
} }
@ -72,11 +68,7 @@ impl<'a> Test<'a> {
pub(crate) fn run(self) { pub(crate) fn run(self) {
let tmp = tempdir(); let tmp = tempdir();
let mut justfile = unindent(self.justfile); let justfile = unindent(self.justfile);
if self.dotenv_load {
justfile.push_str("\nset dotenv-load := true\n");
}
let stdout = unindent(self.stdout); let stdout = unindent(self.stdout);
let stderr = unindent(self.stderr); let stderr = unindent(self.stderr);