-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pipping echo command prints to output #296
Comments
I don't think evaluation line "When" can resolve redirection. LOG_FILE="$SHELLSPEC_TMPDIR/test"
remove_logs() {
rm "$LOG_FILE"
}
Context 'log'
AfterEach 'remove_logs'
File log_file="$LOG_FILE"
log_to_file(){
echo 'test message' >> "$LOG_FILE"
}
It 'should log a message to file'
When call echo 'toto' >> "$LOG_FILE"
The file log_file should be a file
The file log_file should not be a empty file
The file log_file should be readable
The length of output should equal 0
End
End |
Hello JConan! # Constants accessed from functions
% DATE_STR: dom 26 mar 2023 22:38:45
% LOG_DIR: .
% LOG_PATH: "$LOG_DIR/$DATE_STR test_env_builder.log"
#######################################
Mock date
if [ ! -e "$date_lock" ]; then
echo $DATE_STR
touch "$date_lock"
else
echo dom 26 mar 2023 22:38:46
fi
End
export "DATE_STR"
Context 'log'
Include $script_file
Context 'usage: caller'
It 'should redirect the stdout to the file setted by log'
usage() {
log
echo 'test message' &>> "$LOG_FILE"
}
When call usage
The file "$LOG_PATH" should be a file
The file "$LOG_PATH" should not be a empty file
The file "$LOG_PATH" should be readable
The output should equal ""
End
End
It 'should set the log file with the right format'
When call log
The variable "LOG_FILE" should equal "$LOG_PATH"
End
It 'should set the log file path one time only'
log_twice() {
log
log
}
When call log_twice
The variable "LOG_FILE" should equal "$LOG_PATH"
End
End |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello!
I wrote this example, I think it's self explanatory
The result I got:
Using Dump I found out that the echo command is printed to output. I expected a success, is this a bug or I'm doing it wrong?
The text was updated successfully, but these errors were encountered: