-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from jakedeichert/utility-env-vars
Add $MASK and $MASKFILE_DIR utility env variables
- Loading branch information
Showing
5 changed files
with
138 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
use assert_cmd::prelude::*; | ||
use predicates::str::contains; | ||
|
||
mod common; | ||
use common::MaskCommandExt; | ||
|
||
// NOTE: This test suite depends on the mask binary being available in the current shell | ||
|
||
// Using current_dir(".github") to make sure the default maskfile.md can't be found | ||
mod env_var_mask { | ||
use super::*; | ||
|
||
#[test] | ||
fn works_from_any_dir() { | ||
let (_temp, maskfile_path) = common::maskfile( | ||
r#" | ||
## ci | ||
~~~bash | ||
$MASK test | ||
~~~ | ||
## test | ||
~~~bash | ||
echo "tests passed" | ||
~~~ | ||
"#, | ||
); | ||
|
||
common::run_mask(&maskfile_path) | ||
.current_dir(".github") | ||
.command("ci") | ||
.assert() | ||
.stdout(contains("tests passed")) | ||
.success(); | ||
} | ||
|
||
#[test] | ||
fn set_to_the_correct_value() { | ||
let (_temp, maskfile_path) = common::maskfile( | ||
r#" | ||
## run | ||
~~~bash | ||
echo "mask = $MASK" | ||
~~~ | ||
"#, | ||
); | ||
|
||
common::run_mask(&maskfile_path) | ||
.current_dir(".github") | ||
.command("run") | ||
.assert() | ||
// Absolute maskfile path starts with / | ||
.stdout(contains("mask = mask --maskfile /")) | ||
// And ends with maskfile.md | ||
.stdout(contains("maskfile.md")) | ||
.success(); | ||
} | ||
} | ||
|
||
// Using current_dir(".github") to make sure the default maskfile.md can't be found | ||
mod env_var_maskfile_dir { | ||
use super::*; | ||
|
||
#[test] | ||
fn set_to_the_correct_value() { | ||
let (_temp, maskfile_path) = common::maskfile( | ||
r#" | ||
## run | ||
~~~bash | ||
echo "maskfile_dir = $MASKFILE_DIR" | ||
~~~ | ||
"#, | ||
); | ||
|
||
common::run_mask(&maskfile_path) | ||
.current_dir(".github") | ||
.command("run") | ||
.assert() | ||
// Absolute maskfile path starts with / | ||
.stdout(contains("maskfile_dir = /")) | ||
.success(); | ||
} | ||
} |