You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 29, 2021. It is now read-only.
Hi, I have a question, I realized that you can't use variables in the same ways as bash files inside bats, for instance for the next file:
file=/home/file1
@test "Check $file for WARNING!!!" {
run grep -qse "WARNING \!\!\!" $file
[ ${status} -eq 0 ]
}
file=/home/file2
@test "Check $file for WARNING!!!" {
run grep -qse "WARNING \!\!\!" $file
[ ${status} -eq 0 ]
}
All the test is done using /home/file2, for both test, although in the first one I set /home/file1. To try to solve that issue I set different variables, as follow:
file1=/home/file1
@test "Check $file1 for WARNING!!!" {
run grep -qse "WARNING \!\!\!" $file1
[ ${status} -eq 0 ]
}
file2=/home/file2
@test "Check $file2 for WARNING!!!" {
run grep -qse "WARNING \!\!\!" $file2
[ ${status} -eq 0 ]
}
With this workaround works. But I found one situation where the error persist and I couldn't solve using variables, I have to hard code the filenames, the case is the following:
filetail=/etc/motd.tail
@test "Check ${filetail} for WARNING!!!" {
run grep -qse "WARNING \!\!\!" ${filetail}
[ ${status} -eq 0 ]
}
filemotd=/etc/motd
@test "Check ${filemotd} for WARNING!!!" {
run grep -qse "WARNING \!\!\!" ${filemotd}
[ ${status} -eq 0 ]
}
And the output is as follow:
✓ Check /etc/motd for WARNING!!!
✓ Check /etc/motd for WARNING!!!
Always, it is used the last valor of the variable, if I change the order, the output is:
✓ Check /etc/motd.tail for WARNING!!!
✓ Check /etc/motd.tail for WARNING!!!
I don't know if this behavior is by design, but I'd like to use variables, is there a way to solve that or it uses a workaround.
Regards
The text was updated successfully, but these errors were encountered:
This rewrites the old logic a bit by using `type -p`, `readlink -m` and
on boxes where we don't have coreutils like `readlink` we use `realpath`
to figure out the correct installation directory of bats.
Also fixes GH#182
Signed-off-by: Wesley Schwengle <wesley@schwengle.net>
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi, I have a question, I realized that you can't use variables in the same ways as bash files inside bats, for instance for the next file:
All the test is done using /home/file2, for both test, although in the first one I set /home/file1. To try to solve that issue I set different variables, as follow:
With this workaround works. But I found one situation where the error persist and I couldn't solve using variables, I have to hard code the filenames, the case is the following:
And the output is as follow:
Always, it is used the last valor of the variable, if I change the order, the output is:
I don't know if this behavior is by design, but I'd like to use variables, is there a way to solve that or it uses a workaround.
Regards
The text was updated successfully, but these errors were encountered: