Closed amagura closed 9 years ago
test.bats:
@test "environment variable" {
[ "$VAR" = "hello" ]
}
$ bats test.bats
✗ environment variable
(in test file test.bats, line 2)
`[ "$VAR" = "hello" ]' failed
1 test, 1 failure
$ VAR=hello bats test.bats
✓ environment variable
1 test, 0 failures
Um... an rcfile is a run control file that some applications use to setup their environment ahead of time.. y'know like ~/.bashrc
. An isolated one would just be one that only contains what's absolutely necessary in order for whatever test you're running to work; it's best to use an isolated one since using your ~/.FILErc
may make the test non-portable.
An environment variable might work, but when I tried to use one... it didn't seem to bleed through into the testing environment, which is probably a good sign... since if the environment could do that then it could potentially mess up certain kinds of tests.
Bats can't read from
stdin
, which makes it impossible to run a command with an isolated rcfile:Instead of reading from
STDIN
, bats prints out its help usage:A work around would be to allow users to specify variables that can be used globally within the bats file, however, bats should still probably be able to read from
stdin
regardless.