Skip to content
Snippets Groups Projects
Commit 8a307edc authored by Vincent Hatakeyama's avatar Vincent Hatakeyama
Browse files

:pencil: improve tests color output and make it compatible with odoo 15

parent 299bb41c
No related branches found
No related tags found
1 merge request!80Topic/default/run tests odoo 15
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
Also do branch coverage when doing coverage. Also do branch coverage when doing coverage.
Better output of odoo 15 tests with run_tests shell script.
15.0.0 15.0.0
------ ------
......
...@@ -43,4 +43,6 @@ ...@@ -43,4 +43,6 @@
then then
export PRE_ODOO_BIN="python3-coverage run --omit=__manifest__.py --source=$project_home " export PRE_ODOO_BIN="python3-coverage run --omit=__manifest__.py --source=$project_home "
fi fi
# colorize also remove database name and thread number
alias colorize="sed -e 's/^\(\w*-..-.. ..:..:..,\w*\) \w*/\o033[2m\1\o033[22m/' -e 's/ INFO \w* \(odoo\.\(tests\.runner\|modules\.module\): \)\(.*\)/ \o033[32m\o033[7mINFO\o033[0m \1\o033[34m\3\o033[0m/' -e 's/ ERROR \w* \(odoo\.\(tests\.runner\|modules.module\): \)\(.*\)/ \o033[31m\o033[7mERROR\o033[0m \1\o033[34m\3\o033[0m/' -e 's/ \(INFO\) \(\w*\|?\) \([a-Z._-]*\):\(.*\)/ \o033[32m\o033[7m\1\o033[0m \3:\o033[32m\4\o033[39m/' -e 's/ \(DEBUG\) \w* \([a-Z\._-]*\):\(.*\)/ \o033[33m\o033[7m\1\o033[0m \2:\o033[33m\3\o033[39m/' -e 's/ \(WARNING\) \w* \([a-Z._-]*\):\(.*\)/ \o033[33m\o033[7m\1\o033[0m \2:\o033[33m\3\o033[0m/' -e 's/ \(ERROR\) \w* \([a-Z\._-]*\):\(.*\)/ \o033[31m\o033[7m\1\o033[0m \2:\o033[31m\3\o033[0m/' -e 's/ FAILED/ \o033[41m\o033[97m\o033[1mFAILED\o033[0m/' -e 's/ FAIL\(.*\)/ \o033[41m\o033[97m\o033[1mFAIL\o033[49m\o033[31m\1\o033[0m/' -e 's/ \(CRITICAL\) \w* \([a-Z\._-]*\):\(.*\)/ \o033[33m\o033[7m\1\o033[0m \2:\o033[33m\3\o033[39m/' -e 's/ \(TEST\) \w* \(.*\) \(ERROR\)\(.*\)/ \o033[34m\o033[7m\1\o033[27m \2\o033[0m \o033[41m\o033[97m\o033[1m\3\o033[49m\o033[0m/' -e 's/ \(TEST\) \w* \(.*\) \(OK\)/ \o033[34m\o033[7m\1\o033[27m \2\o033[0m \o033[32m\o033[7m\3\o033[27m\o033[39m/' -e 's/ \(TEST\) \w* \([a-Z\._-]*\):\(.*\)/ \o033[34m\o033[7m\1\o033[0m \2:\o033[34m\3\o033[0m/'"
# Catch both stdout & stderr here as Odoo 10 uses stderr, unlike previous Odoo versions. # Catch both stdout & stderr here as Odoo 10 uses stderr, unlike previous Odoo versions.
...@@ -46,3 +48,3 @@ ...@@ -46,3 +48,3 @@
# Catch both stdout & stderr here as Odoo 10 uses stderr, unlike previous Odoo versions. # Catch both stdout & stderr here as Odoo 10 uses stderr, unlike previous Odoo versions.
$here/start $update -d $dbname $db_user_param --test-enable $loglevel --max-cron=0 --stop-after-init $* 2>&1 | tee $logfile | sed -e 's/\(.*\) \(INFO\) \(.*\)/\o033[2m\1\o033[22m \o033[32m\o033[7m\2\o033[27m \3\o033[39m/' -e 's/\(.*\) \(DEBUG\) \(.*\)/\o033[2m\1\o033[22m \o033[33m\o033[7m\2\o033[27m \2\o033[39m/' -e 's/\(.*\) \(WARNING\) \(.*\)/\o033[2m\1\o033[22m \o033[33m\o033[7m\2\o033[27m \3\o033[39m/' -e 's/\(.*\) \(ERROR\) \(.*\)/\o033[2m\1\o033[22m \o033[31m\o033[7m\2\o033[27m \3\o033[0m/' -e 's/ FAILED/ \o033[41m\o033[97m\o033[1mFAILED\o033[0m/' -e 's/ FAIL\(.*\)/ \o033[41m\o033[97m\o033[1mFAIL\o033[49m\o033[31m\1\o033[0m/' -e 's/\(.*\) \(CRITICAL\) \(.*\)/\o033[2m\1\o033[22m \o033[33m\o033[7m\2\o033[27m \3\o033[39m/' -e 's/\(.*\) \(TEST\) \(.*\) \(ERROR\)\(.*\)/\o033[2m\1\o033[22m \o033[34m\o033[7m\2\o033[27m \3\o033[0m \o033[41m\o033[97m\o033[1m\4\o033[49m\o033[31m\5\o033[0m/' -e 's/\(.*\) \(TEST\) \(.*\) \(OK\)/\o033[2m\1\o033[22m \o033[34m\o033[7m\2\o033[27m \3\o033[0m \o033[32m\o033[7m\4\o033[27m\o033[39m/' -e 's/\(.*\) \(TEST\) \(.*\)/\o033[2m\1\o033[22m \o033[34m\o033[7m\2\o033[27m \3 \o033[0m/' $here/start $update -d $dbname $db_user_param --test-enable $loglevel --max-cron=0 --stop-after-init $* 2>&1 | tee $logfile | colorize
start_status=$pipestatus[1] start_status=$pipestatus[1]
...@@ -48,7 +50,4 @@ ...@@ -48,7 +50,4 @@
start_status=$pipestatus[1] start_status=$pipestatus[1]
# Valid with odoo 7, 11, 13 and probably the rest too # Odoo 15 detection
tests_ran=$(grep -P 'o(penerp|doo).(modules.module|[^ ]+): Ran \K([[:digit:]]+)' $logfile -o | perl -ne '$sum += $_ } { print $sum') if [ $(grep -P 'odoo\.tests\.runner: ([[:digit:]]+) failed, [[:digit:]]+ error\(s\) of [[:digit:]]+ tests when loading database' $logfile --count) -gt 0 ];
tests_failures=$(grep -P 'o(penerp|doo).(modules.module|[^ ]+): Module [a-z0-9_]+: \K([[:digit:]]+)' $logfile -o | perl -ne '$sum += $_ } { print $sum')
# that might be doable in the perl above
if [ -z "$tests_failures" ];
then then
...@@ -54,13 +53,25 @@ ...@@ -54,13 +53,25 @@
then then
tests_failures=0 # Valid with odoo 15
fi tests_ran=$(grep -P 'odoo\.tests\.runner: ([[:digit:]]+) failed, [[:digit:]]+ error\(s\) of \K[[:digit:]]+' $logfile -o)
tests_errors=$(grep -P 'o(penerp|doo).(modules.module|[^ ]+): Module [a-z0-9_]+: [[:digit:]]+ failures, \K([[:digit:]]+)' $logfile -o | perl -ne '$sum += $_ } { print $sum') tests_failures=$(grep -P 'odoo\.tests\.runner: \K([[:digit:]]+)' $logfile -o)
if [ -z "$tests_errors" ]; test_errors=$(grep -P 'odoo\.tests\.runner: ([[:digit:]]+) failed, \K[[:digit:]]+' $logfile -o)
then else
tests_errors=0 # Valid with odoo 7, 11, 13
tests_ran=$(grep -P 'o(penerp|doo).(modules.module|[^ ]+): Ran \K([[:digit:]]+)' $logfile -o | perl -ne '$sum += $_ } { print $sum')
tests_failures=$(grep -P 'o(penerp|doo).(modules.module|[^ ]+): Module [a-z0-9_]+: \K([[:digit:]]+)' $logfile -o | perl -ne '$sum += $_ } { print $sum')
# that might be doable in the perl above
if [ -z "$tests_failures" ];
then
tests_failures=0
fi
tests_errors=$(grep -P 'o(penerp|doo).(modules.module|[^ ]+): Module [a-z0-9_]+: [[:digit:]]+ failures, \K([[:digit:]]+)' $logfile -o | perl -ne '$sum += $_ } { print $sum')
if [ -z "$tests_errors" ];
then
tests_errors=0
fi
fi fi
# create a OpenMetrics metrics file # create a OpenMetrics metrics file
if [ "$CI" = "true" ]; if [ "$CI" = "true" ];
then then
echo -e "odoo_scripts_tests_ran $tests_ran\nodoo_scripts_tests_failures $tests_failures\nodoo_scripts_tests_error $tests_error\n# EOF\n" > metrics echo -e "odoo_scripts_tests_ran $tests_ran\nodoo_scripts_tests_failures $tests_failures\nodoo_scripts_tests_error $tests_error\n# EOF\n" > metrics
fi fi
...@@ -61,10 +72,10 @@ ...@@ -61,10 +72,10 @@
fi fi
# create a OpenMetrics metrics file # create a OpenMetrics metrics file
if [ "$CI" = "true" ]; if [ "$CI" = "true" ];
then then
echo -e "odoo_scripts_tests_ran $tests_ran\nodoo_scripts_tests_failures $tests_failures\nodoo_scripts_tests_error $tests_error\n# EOF\n" > metrics echo -e "odoo_scripts_tests_ran $tests_ran\nodoo_scripts_tests_failures $tests_failures\nodoo_scripts_tests_error $tests_error\n# EOF\n" > metrics
fi fi
if [ $ODOO_TYPE != 'odoo13' ]; if [ "$ODOO_TYPE" = 'odoo7' ] || [ "$ODOO_TYPE" = 'odoo8' ] || [ "$ODOO_TYPE" = 'odoo9' ] || [ "$ODOO_TYPE" = 'odoo10' ] || [ "$ODOO_TYPE" = 'odoo11' ];
then then
ok=$(grep ' OK' $logfile -c) ok=$(grep ' OK' $logfile -c)
fi fi
...@@ -79,8 +90,8 @@ ...@@ -79,8 +90,8 @@
fi fi
echo '' echo ''
echo "${esc}[2m*****${esc}[22m ${esc}[1mTest results${esc}[21m ${esc}[2m*****${esc}[22m" echo "${esc}[2m*****${esc}[22m ${esc}[1mTest results${esc}[21m ${esc}[2m*****${esc}[22m"
echo "Ran $tests_ran tests, $tests_failures failures, $tests_errors errors" echo "$tests_failures failed, $tests_error error(s) of $tests_ran tests"
if [ $ODOO_TYPE != 'odoo13' ]; if [ "$ODOO_TYPE" = 'odoo7' ] || [ "$ODOO_TYPE" = 'odoo8' ] || [ "$ODOO_TYPE" = 'odoo9' ] || [ "$ODOO_TYPE" = 'odoo10' ] || [ "$ODOO_TYPE" = 'odoo11' ];
then then
echo "$OK $ok modules passing" echo "$OK $ok modules passing"
fi fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment