47 lines
2.2 KiB
Diff
47 lines
2.2 KiB
Diff
--- a/src/testing.sh 2018-02-24 14:44:24.213182846 +0100
|
|
+++ b/src/testing.sh 2018-02-24 14:44:58.046031444 +0100
|
|
@@ -731,6 +731,12 @@
|
|
Be aware that there are some variables which can collide with your code executed
|
|
within rlRun. You should avoid using __INTERNAL_rlRun_* variables.
|
|
|
|
+=item
|
|
+
|
|
+When any of C<-t> C<-l>, C<-c>, or C<-s> option is used, special file
|
|
+descriptors 111 and 112 are used to avoid the issue with incomplete log file,
|
|
+bz1361246.
|
|
+
|
|
=back
|
|
|
|
B<Warning:> using C<unbuffer> tool is now disabled because of bug 547686.
|
|
@@ -848,9 +854,28 @@
|
|
__INTERNAL_PrintText "$__INTERNAL_rlRun_comment_begin" "BEGIN"
|
|
|
|
if $__INTERNAL_rlRun_DO_LOG || $__INTERNAL_rlRun_DO_TAG || $__INTERNAL_rlRun_DO_KEEP; then
|
|
- eval "$__INTERNAL_rlRun_command" 2> >(sed -u -e "s/^/$__INTERNAL_rlRun_TAG_ERR/g" |
|
|
- tee -a $__INTERNAL_rlRun_LOG_FILE) 1> >(sed -u -e "s/^/$__INTERNAL_rlRun_TAG_OUT/g" | tee -a $__INTERNAL_rlRun_LOG_FILE)
|
|
+ # handle issue with incomplete logs (bz1361246), this could be improved using coproc
|
|
+ # in RHEL-6 and higher
|
|
+ # open file descriptors to parsing processes
|
|
+ exec 111> >(sed -u -e "s/^/$__INTERNAL_rlRun_TAG_OUT/g" | tee -a $__INTERNAL_rlRun_LOG_FILE)
|
|
+ local __INTERNAL_rlRun_OUTpid=$!
|
|
+ exec 112> >(sed -u -e "s/^/$__INTERNAL_rlRun_TAG_ERR/g" | tee -a $__INTERNAL_rlRun_LOG_FILE)
|
|
+ local __INTERNAL_rlRun_ERRpid=$!
|
|
+ eval "$__INTERNAL_rlRun_command" 2>&112 1>&111
|
|
local __INTERNAL_rlRun_exitcode=$?
|
|
+ # close parsing processes
|
|
+ exec 111>&-
|
|
+ exec 112>&-
|
|
+ # wait for parsing processes to finish their job
|
|
+ local __INTERNAL_rlRun_counter=0
|
|
+ while kill -0 $__INTERNAL_rlRun_OUTpid 2>/dev/null || kill -0 $__INTERNAL_rlRun_ERRpid 2>/dev/null; do
|
|
+ [[ $((__INTERNAL_rlRun_counter++)) -gt 12000 ]] && {
|
|
+ rlLogError "waiting for flushing the output timed out, there might be some data missing in the output file"
|
|
+ break
|
|
+ }
|
|
+ sleep 0.01;
|
|
+ done
|
|
+ rlLogDebug "waiting for parsing processes took $__INTERNAL_rlRun_counter cycles"
|
|
else
|
|
eval "$__INTERNAL_rlRun_command"
|
|
local __INTERNAL_rlRun_exitcode=$?
|