diff --git a/beakerlib.spec b/beakerlib.spec index 7ff6383..21926ad 100644 --- a/beakerlib.spec +++ b/beakerlib.spec @@ -1,12 +1,10 @@ Name: beakerlib Summary: A shell-level integration testing library Version: 1.17 -Release: 7%{?dist} +Release: 8%{?dist} License: GPLv2 Group: Development/Libraries BuildRoot: %{_tmppath}/%{name}-%{version}-root -Source0: https://github.com/beakerlib/beakerlib/archive/%{name}-%{version}.tar.gz -Source1: %{name}-tmpfiles.conf BuildArch: noarch URL: https://github.com/%{name} Requires: nfs-utils @@ -27,15 +25,8 @@ BuildRequires: /usr/bin/pod2man BuildRequires: perl-generators BuildRequires: util-linux -%description -The BeakerLib project means to provide a library of various helpers, which -could be used when writing operating system level integration tests. - -%package vim-syntax -Summary: Files for syntax highlighting BeakerLib tests in VIM editor -Group: Development/Libraries -Requires: vim-common -BuildRequires: vim-common +Source0: https://github.com/beakerlib/beakerlib/archive/%{name}-%{version}.tar.gz +Source1: %{name}-tmpfiles.conf Patch0: test-built-time.patch Patch1: result-file.patch @@ -48,23 +39,15 @@ Patch7: enable-nested-phases.patch Patch8: debug-to-console.patch Patch9: phase-names-sanitization.patch Patch10: reboot-in-phase.patch - -%description vim-syntax -Files for syntax highlighting BeakerLib tests in VIM editor +Patch11: rxvt-terminals-coloring.patch +Patch12: persistent-data-load.patch +Patch13: final-summary-in-rlJournalEnd.patch +Patch14: extended-coloring-capabilities.patch +Patch15: unified-footer.patch %prep %setup -q -%patch0 -p1 -b .test-built-time -%patch1 -p1 -b .result-file -%patch2 -p1 -b .ifs-issue -%patch3 -p1 -b .journaling-fixes -%patch4 -p1 -b .get-text-journal-size -%patch5 -p1 -b .var-TEST -%patch6 -p1 -b .reduce-meta -%patch7 -p1 -b .enable-nested-phases -%patch8 -p1 -b .debug-to-console -%patch9 -p1 -b .phase-names-sanitization -%patch10 -p1 -b .reboot-in-phase +%autopatch -p1 %build make build @@ -80,6 +63,9 @@ install -m 0644 %{SOURCE1} $RPM_BUILD_ROOT/%{_tmpfilesdir}/%{name}.conf %clean rm -rf $RPM_BUILD_ROOT +%description +The BeakerLib project means to provide a library of various helpers, which +could be used when writing operating system level integration tests. %files %defattr(-,root,root,-) @@ -96,12 +82,27 @@ rm -rf $RPM_BUILD_ROOT %doc %{_pkgdocdir}/* %config %{_tmpfilesdir}/%{name}.conf +%package vim-syntax +Summary: Files for syntax highlighting BeakerLib tests in VIM editor +Group: Development/Libraries +Requires: vim-common +BuildRequires: vim-common + +%description vim-syntax +Files for syntax highlighting BeakerLib tests in VIM editor %files vim-syntax %{_datadir}/vim/vimfiles/after/ftdetect/beakerlib.vim %{_datadir}/vim/vimfiles/after/syntax/beakerlib.vim %changelog +* Fri Feb 2 2018 Dalibor Pospisil - 1.17-8 +- support rxvt terminal colors +- fixed persistent data load for bash version <= 4.1.2 +- moved printing of final summray to rlJournalEnd +- extended coloring capabilities +- unified footer format + * Fri Jan 26 2018 Dalibor Pospisil - 1.17-7 - phase name sanitization (remove all weird characters) - allow debug message to to only to console (speeds execution up in debug) diff --git a/extended-coloring-capabilities.patch b/extended-coloring-capabilities.patch new file mode 100644 index 0000000..ebb1eb5 --- /dev/null +++ b/extended-coloring-capabilities.patch @@ -0,0 +1,106 @@ +From 44221b0c9970f11451016f4566602932861458e6 Mon Sep 17 00:00:00 2001 +From: Dalibor Pospisil +Date: Fri, 2 Feb 2018 15:06:58 +0100 +Subject: [PATCH 4/5] extended coloring capabilities + +this change allow to color result from other placed +--- + src/logging.sh | 72 ++++++++++++++++++++++++++++++++++++++-------------------- + 1 file changed, 48 insertions(+), 24 deletions(-) + +diff --git a/src/logging.sh b/src/logging.sh +index 38a0466..59709df 100644 +--- a/src/logging.sh ++++ b/src/logging.sh +@@ -57,41 +57,65 @@ __INTERNAL_PrintText() { + __INTERNAL_LogText "$@" + } + ++# $1 - text to color ++# $2 - variable to put the color sequence to ++# $3 - variable to put the uncolor sequence to ++__INTERNAL_get_prio_colors() { ++ local prio="$1" var_color="$2" var_uncolor="$3" ++ local ____COLOR='' ____UNCOLOR='' ++ if [[ -t 2 ]]; then ++ ____UNCOLOR="$__INTERNAL_color_reset" ++ case ${prio^^} in ++ DEBUG*) ++ ____COLOR="$__INTERNAL_color_purple" ++ ;; ++ PASS) ++ ____COLOR="$__INTERNAL_color_green" ++ ;; ++ FAIL|FATAL) ++ ____COLOR="$__INTERNAL_color_light_red" ++ ;; ++ LOG) ++ ____COLOR="$__INTERNAL_color_cyan" ++ ;; ++ LOG|INFO|BEGIN) ++ ____COLOR="$__INTERNAL_color_blue" ++ ;; ++ WARN*|SKIP*) ++ ____COLOR="$__INTERNAL_color_yellow" ++ ;; ++ esac ++ fi ++ eval "$var_color=\"${____COLOR}\"" ++ eval "$var_uncolor=\"${____UNCOLOR}\"" ++} ++ ++# $1 - text to color ++# $2 - variable to put the result to ++__INTERNAL_colorize_prio() { ++ local prio="$1" var="$2" ++ local COLOR='' UNCOLOR='' ++ __INTERNAL_get_prio_colors "$prio" COLOR UNCOLOR ++ eval "$var=\"$COLOR$prio$UNCOLOR\"" ++} ++ ++# $1 - MESSAGE ++# $2 - prio ++# $3 - LOGFILE ++# $4 - MESSAGE_COLORED, if empty MESSAGE is used + __INTERNAL_LogText() { + local MESSAGE="$1" +- local MESSAGE_COLORED="${MESSAGE}" ++ local MESSAGE_COLORED="${4:-"$MESSAGE"}" + local prio="$2" + local LOGFILE=${3:-$OUTPUTFILE} + local res=0 + local COLOR='' UNCOLOR='' +- if [[ -t 2 ]]; then +- UNCOLOR="$__INTERNAL_color_reset" +- case ${prio^^} in +- DEBUG*) +- COLOR="$__INTERNAL_color_purple" +- ;; +- PASS) +- COLOR="$__INTERNAL_color_green" +- ;; +- FAIL|FATAL) +- COLOR="$__INTERNAL_color_light_red" +- ;; +- LOG) +- COLOR="$__INTERNAL_color_cyan" +- ;; +- LOG|INFO|BEGIN) +- COLOR="$__INTERNAL_color_blue" +- ;; +- WARN*|SKIP*) +- COLOR="$__INTERNAL_color_yellow" +- ;; +- esac +- fi + [[ -n "$prio" ]] && { + local left=$(( (10+${#prio})/2 )) + local prefix prefix_colored timestamp + __INTERNAL_SET_TIMESTAMP + printf -v timestamp "%($__INTERNAL_TIMEFORMAT_SHORT)T" "$__INTERNAL_TIMESTAMP" ++ __INTERNAL_get_prio_colors "$prio" COLOR UNCOLOR + printf -v prefix_colored ":: [ %s ] :: [%s%*s%*s%s] ::" "$timestamp" "$COLOR" "$left" "${prio}" "$(( 10-$left ))" '' "$UNCOLOR" + printf -v prefix ":: [ %s ] :: [%*s%*s] ::" "$timestamp" "$left" "${prio}" "$(( 10-$left ))" + MESSAGE="$prefix $MESSAGE" +-- +2.14.3 diff --git a/final-summary-in-rlJournalEnd.patch b/final-summary-in-rlJournalEnd.patch new file mode 100644 index 0000000..8821d05 --- /dev/null +++ b/final-summary-in-rlJournalEnd.patch @@ -0,0 +1,49 @@ +From 94c83310182228dcb959f390c6a513cbdebe4976 Mon Sep 17 00:00:00 2001 +From: Dalibor Pospisil +Date: Fri, 2 Feb 2018 15:13:46 +0100 +Subject: [PATCH 3/5] move final summary printing to rlJournalEnd + +also put the text to journal.txt +this will ensure the summary is always printed at the end and is also present in the text file +--- + src/journal.sh | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) + +diff --git a/src/journal.sh b/src/journal.sh +index 04e4a10..867d08f 100644 +--- a/src/journal.sh ++++ b/src/journal.sh +@@ -242,6 +242,8 @@ rlJournalEnd(){ + __INTERNAL_ENDTIME=$__INTERNAL_TIMESTAMP + __INTERNAL_update_journal_txt + ++ __INTERNAL_PrintHeadLog "${__INTERNAL_TEST_NAME}" 2>&1 ++ + if [ -n "$TESTID" ] ; then + __INTERNAL_JournalXMLCreate + $BEAKERLIB_COMMAND_SUBMIT_LOG -T $TESTID -l $__INTERNAL_BEAKERLIB_JOURNAL \ +@@ -252,6 +254,10 @@ rlJournalEnd(){ + fi + + echo "#End of metafile" >> $__INTERNAL_BEAKERLIB_METAFILE ++ ++ __INTERNAL_LogText "Phases: $__INTERNAL_PHASES_PASSED good, $__INTERNAL_PHASES_FAILED bad" LOG 2>&1 ++ __INTERNAL_LogText "RESULT: $__INTERNAL_TEST_NAME" $__INTERNAL_PHASES_WORST_RESULT 2>&1 ++ + __INTERNAL_JournalXMLCreate + __INTERNAL_TestResultsSave + } +@@ -434,11 +440,6 @@ rlJournalPrintText(){ + [[ -t 1 ]] && textfile="$__INTERNAL_BEAKERLIB_JOURNAL_COLORED" || textfile="$__INTERNAL_BEAKERLIB_JOURNAL_TXT" + cat "$textfile" + +- local __INTERNAL_LogText_no_file=1 +- __INTERNAL_PrintHeadLog "${__INTERNAL_TEST_NAME}" 2>&1 +- __INTERNAL_LogText "Phases: $__INTERNAL_PHASES_PASSED good, $__INTERNAL_PHASES_FAILED bad" LOG 2>&1 +- __INTERNAL_LogText "RESULT: $__INTERNAL_TEST_NAME" $__INTERNAL_PHASES_WORST_RESULT 2>&1 +- + return 0 + } + +-- +2.14.3 diff --git a/persistent-data-load.patch b/persistent-data-load.patch new file mode 100644 index 0000000..e701b92 --- /dev/null +++ b/persistent-data-load.patch @@ -0,0 +1,76 @@ +From e866044b7d2050c5558de8e8e2cc7f7d7f34e715 Mon Sep 17 00:00:00 2001 +From: Dalibor Pospisil +Date: Fri, 2 Feb 2018 11:41:00 +0100 +Subject: [PATCH 2/5] fixed persistent data load for bash <= 4.1.2 + +there's no '-g' option to declare in bash <= 4.1.2 +therefore declare cannot be used for this purpose +--- + src/journal.sh | 51 +++++++++++++++++++++++++++------------------------ + 1 file changed, 27 insertions(+), 24 deletions(-) + +diff --git a/src/journal.sh b/src/journal.sh +index f35d03b..04e4a10 100644 +--- a/src/journal.sh ++++ b/src/journal.sh +@@ -937,31 +937,34 @@ __INTERNAL_PrintHeadLog() { + # functions __INTERNAL_PersistentDataLoad and __INTERNAL_PersistentDataSave + # should be called before and after that respectively. + ++__INTERNAL_PersistentDataSave_sed='s/^declare/\0 -g/' ++# ugly workaround for bash-4.1.2 and older, where -g does not exist ++# there might be an issue when there's a line break in the variables and there's ++# "")'" or "()'" at the end of the line. This should not never happen, the worst ++# case might happen in the phase name but is is not expected to contain line ++# breaks ++declare -g &> /dev/null || __INTERNAL_PersistentDataSave_sed="s/(^declare -a[^=]+=)'\(/\1(/;s/([\"(]\))'$/\1/;s/declare\s+\S+\s+([^=]+=)/\1/" ++ + __INTERNAL_PersistentDataSave() { +- local var +- ( +- for var in \ +- __INTERNAL_STARTTIME \ +- __INTERNAL_TEST_STATE \ +- __INTERNAL_PHASES_PASSED \ +- __INTERNAL_PHASES_FAILED \ +- __INTERNAL_PHASES_SKIPPED \ +- __INTERNAL_JOURNAL_OPEN \ +- __INTERNAL_PHASE_OPEN \ +- __INTERNAL_PHASES_WORST_RESULT \ +- __INTERNAL_METAFILE_INDENT_LEVEL \ +- __INTERNAL_PHASE_TYPE \ +- __INTERNAL_PHASE_NAME \ +- __INTERNAL_PHASE_FAILED \ +- __INTERNAL_PHASE_PASSED \ +- __INTERNAL_PHASE_STARTTIME \ +- __INTERNAL_PHASE_TXTLOG_START \ +- __INTERNAL_PHASE_METRICS \ +- ; +- do +- declare -p $var +- done +- ) | sed -r 's/declare/\0 -g/' > "$__INTERNAL_PERSISTENT_DATA" ++ declare -p \ ++ __INTERNAL_STARTTIME \ ++ __INTERNAL_TEST_STATE \ ++ __INTERNAL_PHASES_PASSED \ ++ __INTERNAL_PHASES_FAILED \ ++ __INTERNAL_PHASES_SKIPPED \ ++ __INTERNAL_JOURNAL_OPEN \ ++ __INTERNAL_PHASE_OPEN \ ++ __INTERNAL_PHASES_WORST_RESULT \ ++ __INTERNAL_METAFILE_INDENT_LEVEL \ ++ __INTERNAL_PHASE_TYPE \ ++ __INTERNAL_PHASE_NAME \ ++ __INTERNAL_PHASE_FAILED \ ++ __INTERNAL_PHASE_PASSED \ ++ __INTERNAL_PHASE_STARTTIME \ ++ __INTERNAL_PHASE_TXTLOG_START \ ++ __INTERNAL_PHASE_METRICS \ ++ __INTERNAL_TEST_NAME \ ++ | sed -r "$__INTERNAL_PersistentDataSave_sed" > "$__INTERNAL_PERSISTENT_DATA" + } + + __INTERNAL_PersistentDataLoad() { +-- +2.14.3 diff --git a/rxvt-terminals-coloring.patch b/rxvt-terminals-coloring.patch new file mode 100644 index 0000000..d8faf6c --- /dev/null +++ b/rxvt-terminals-coloring.patch @@ -0,0 +1,26 @@ +From e6a98ff289c0c085767c2e910e0a3fb983d8b273 Mon Sep 17 00:00:00 2001 +From: Alois Mahdal +Date: Thu, 1 Feb 2018 15:12:12 +0100 +Subject: [PATCH 1/5] Enable colors on rxvt terminals + +rxvt-unicode sets TERM to 'rxvt-unicode'. plain old rxvt sets it to +`rxvt`. +--- + src/logging.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/logging.sh b/src/logging.sh +index 2d3972a..38a0466 100644 +--- a/src/logging.sh ++++ b/src/logging.sh +@@ -175,7 +175,7 @@ __INTERNAL_color_set() { + [[ -t 1 ]] || T="" + [[ -t 2 ]] || T="" + case $T in +- xterm*|screen|linux) ++ xterm*|screen|linux|rxvt*) + __INTERNAL_color_black="\e[0;30m" + __INTERNAL_color_dark_gray="\e[1;30m" + __INTERNAL_color_red="\e[0;31m" +-- +2.14.3 diff --git a/unified-footer.patch b/unified-footer.patch new file mode 100644 index 0000000..93e1de9 --- /dev/null +++ b/unified-footer.patch @@ -0,0 +1,85 @@ +From c8b0fdde74b7cb1717454992772ab63e6cffd234 Mon Sep 17 00:00:00 2001 +From: Dalibor Pospisil +Date: Fri, 2 Feb 2018 15:16:58 +0100 +Subject: [PATCH 5/5] unify footer printing + +make footer of the phase and also the footer of whole test formated the same +it also removes controversary strong splitter of footer +--- + src/journal.sh | 47 ++++++++++++++++++++++++++++++++++++++++------- + 1 file changed, 40 insertions(+), 7 deletions(-) + +diff --git a/src/journal.sh b/src/journal.sh +index 867d08f..f3f2b78 100644 +--- a/src/journal.sh ++++ b/src/journal.sh +@@ -255,8 +255,13 @@ rlJournalEnd(){ + + echo "#End of metafile" >> $__INTERNAL_BEAKERLIB_METAFILE + +- __INTERNAL_LogText "Phases: $__INTERNAL_PHASES_PASSED good, $__INTERNAL_PHASES_FAILED bad" LOG 2>&1 +- __INTERNAL_LogText "RESULT: $__INTERNAL_TEST_NAME" $__INTERNAL_PHASES_WORST_RESULT 2>&1 ++ __INTERNAL_PrintFootLog $__INTERNAL_STARTTIME \ ++ $__INTERNAL_ENDTIME \ ++ Phases \ ++ $__INTERNAL_PHASES_PASSED \ ++ $__INTERNAL_PHASES_FAILED \ ++ $__INTERNAL_PHASES_WORST_RESULT \ ++ "OVERALL" + + __INTERNAL_JournalXMLCreate + __INTERNAL_TestResultsSave +@@ -603,11 +608,12 @@ rljClosePhase(){ + rlLogDebug "rljClosePhase: Phase $name closed" + __INTERNAL_SET_TIMESTAMP + local endtime="$__INTERNAL_TIMESTAMP" +- __INTERNAL_LogText "________________________________________________________________________________" +- __INTERNAL_LogText "Duration: $((endtime - __INTERNAL_PHASE_STARTTIME))s" LOG +- __INTERNAL_LogText "Assertions: $__INTERNAL_PHASE_PASSED good, $__INTERNAL_PHASE_FAILED bad" LOG +- __INTERNAL_LogText "RESULT: $name" $result +- __INTERNAL_LogText '' ++ __INTERNAL_PrintFootLog $__INTERNAL_PHASE_STARTTIME \ ++ $endtime \ ++ Assertions \ ++ $__INTERNAL_PHASE_PASSED \ ++ $__INTERNAL_PHASE_FAILED \ ++ $result + local logfile="$(mktemp)" + tail -n +$((__INTERNAL_PHASE_TXTLOG_START+1)) $__INTERNAL_BEAKERLIB_JOURNAL_TXT > $logfile + rlReport "$(echo "${name//[^[:alnum:]]/-}" | tr -s '-')" "$result" "$score" "$logfile" +@@ -934,6 +940,33 @@ __INTERNAL_PrintHeadLog() { + } + + ++# $1 - start time ++# $2 - end time ++# $3 - stat name ++# $4 - stat good ++# $5 - stat bad ++# $6 - result ++# $7 - result prefix ' RESULT: ' ++__INTERNAL_PrintFootLog(){ ++ local result_colored ++ local starttime="$1" ++ local endtime="$2" ++ local stat_name="$3" ++ local stat_good="$4" ++ local stat_bad="$5" ++ local result="$6" ++ local result_pref="$7" ++ [[ -n "$result_pref" ]] && result_pref+=" " ++ __INTERNAL_colorize_prio "$result" result_colored ++ __INTERNAL_LogText "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" ++ __INTERNAL_LogText ":: Duration: $((endtime - starttime))s" ++ __INTERNAL_LogText ":: $stat_name: $stat_good good, $stat_bad bad" ++ __INTERNAL_LogText ":: ${result_pref}RESULT: $result" '' '' \ ++ ":: ${result_pref}RESULT: $result_colored" ++ __INTERNAL_LogText '' ++} ++ ++ + # whenever any of the persistent variable is touched, + # functions __INTERNAL_PersistentDataLoad and __INTERNAL_PersistentDataSave + # should be called before and after that respectively. +-- +2.14.3