Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
Odoo scripts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Container Registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
XCG
Odoo scripts
Commits
8a307edc
Commit
8a307edc
authored
3 years ago
by
Vincent Hatakeyama
Browse files
Options
Downloads
Patches
Plain Diff
improve tests color output and make it compatible with odoo 15
parent
299bb41c
No related branches found
No related tags found
1 merge request
!80
Topic/default/run tests odoo 15
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
NEWS.rst
+2
-0
2 additions, 0 deletions
NEWS.rst
run_tests
+26
-15
26 additions, 15 deletions
run_tests
with
28 additions
and
15 deletions
NEWS.rst
+
2
−
0
View file @
8a307edc
...
@@ -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
------
------
...
...
This diff is collapsed.
Click to expand it.
run_tests
+
26
−
15
View file @
8a307edc
...
@@ -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
*/
\o
033[2m
\1\o
033[22m/' -e 's/ INFO
\w
*
\(
odoo
\.\(
tests
\.
runner
\|
modules
\.
module
\)
:
\)\(
.*
\)
/
\o
033[32m
\o
033[7mINFO
\o
033[0m
\1\o
033[34m
\3\o
033[0m/' -e 's/ ERROR
\w
*
\(
odoo
\.\(
tests
\.
runner
\|
modules.module
\)
:
\)\(
.*
\)
/
\o
033[31m
\o
033[7mERROR
\o
033[0m
\1\o
033[34m
\3\o
033[0m/' -e 's/
\(
INFO
\)
\(\w
*
\|
?
\)
\(
[a-Z._-]*
\)
:
\(
.*
\)
/
\o
033[32m
\o
033[7m
\1\o
033[0m
\3
:
\o
033[32m
\4\o
033[39m/' -e 's/
\(
DEBUG
\)
\w
*
\(
[a-Z
\.
_-]*
\)
:
\(
.*
\)
/
\o
033[33m
\o
033[7m
\1\o
033[0m
\2
:
\o
033[33m
\3\o
033[39m/' -e 's/
\(
WARNING
\)
\w
*
\(
[a-Z._-]*
\)
:
\(
.*
\)
/
\o
033[33m
\o
033[7m
\1\o
033[0m
\2
:
\o
033[33m
\3\o
033[0m/' -e 's/
\(
ERROR
\)
\w
*
\(
[a-Z
\.
_-]*
\)
:
\(
.*
\)
/
\o
033[31m
\o
033[7m
\1\o
033[0m
\2
:
\o
033[31m
\3\o
033[0m/' -e 's/ FAILED/
\o
033[41m
\o
033[97m
\o
033[1mFAILED
\o
033[0m/' -e 's/ FAIL
\(
.*
\)
/
\o
033[41m
\o
033[97m
\o
033[1mFAIL
\o
033[49m
\o
033[31m
\1\o
033[0m/' -e 's/
\(
CRITICAL
\)
\w
*
\(
[a-Z
\.
_-]*
\)
:
\(
.*
\)
/
\o
033[33m
\o
033[7m
\1\o
033[0m
\2
:
\o
033[33m
\3\o
033[39m/' -e 's/
\(
TEST
\)
\w
*
\(
.*
\)
\(
ERROR
\)\(
.*
\)
/
\o
033[34m
\o
033[7m
\1\o
033[27m
\2\o
033[0m
\o
033[41m
\o
033[97m
\o
033[1m
\3\o
033[49m
\o
033[0m/' -e 's/
\(
TEST
\)
\w
*
\(
.*
\)
\(
OK
\)
/
\o
033[34m
\o
033[7m
\1\o
033[27m
\2\o
033[0m
\o
033[32m
\o
033[7m
\3\o
033[27m
\o
033[39m/' -e 's/
\(
TEST
\)
\w
*
\(
[a-Z
\.
_-]*
\)
:
\(
.*
\)
/
\o
033[34m
\o
033[7m
\1\o
033[0m
\2
:
\o
033[34m
\3\o
033[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
\n
odoo_scripts_tests_failures
$tests_failures
\n
odoo_scripts_tests_error
$tests_error
\n
# EOF
\n
"
>
metrics
echo
-e
"odoo_scripts_tests_ran
$tests_ran
\n
odoo_scripts_tests_failures
$tests_failures
\n
odoo_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
\n
odoo_scripts_tests_failures
$tests_failures
\n
odoo_scripts_tests_error
$tests_error
\n
# EOF
\n
"
>
metrics
echo
-e
"odoo_scripts_tests_ran
$tests_ran
\n
odoo_scripts_tests_failures
$tests_failures
\n
odoo_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
fail
ures
,
$tests_error
s
errors"
echo
"
$tests_failures
fail
ed
,
$tests_error
error
(s) of
$tests_ran
test
s"
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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment