Skip to content

Commit 97982f1

Browse files
committed
Show first logical suite/test doc line in console.
Fixes robotframework#3150.
1 parent 26e9071 commit 97982f1

File tree

7 files changed

+30
-13
lines changed

7 files changed

+30
-13
lines changed

atest/robot/parsing/suite_settings.robot

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ Suite Name
1111

1212
Suite Documentation
1313
${doc} = Catenate SEPARATOR=\n
14-
... 1st line is shortdoc.
14+
... 1st logical line
15+
... (i.e. paragraph)
16+
... is shortdoc on console.
17+
... ${EMPTY}
1518
... Text from multiple columns is catenated with spaces,
1619
... and line continuation creates a new line.
1720
... Newlines can also be added literally "\n\n".
@@ -21,8 +24,8 @@ Suite Documentation
2124
Should Be Equal ${SUITE.doc} ${doc}
2225

2326
Suite Name And Documentation On Console
24-
Check Stdout Contains Suite Settings :: 1st line is shortdoc.${SPACE * 39}\n
25-
Check Stdout Contains Suite Settings :: 1st line is shortdoc.${SPACE * 31}| PASS |\n
27+
Check Stdout Contains Suite Settings :: 1st logical line (i.e. paragraph) is shortdoc on console.${SPACE * 3}\n
28+
Check Stdout Contains Suite Settings :: 1st logical line (i.e. paragraph) is shortdoc on... | PASS |\n
2629

2730
Test Setup
2831
${test} = Check Test Case Test Case

atest/robot/parsing/test_case_settings.robot

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ Names are not formatted
2323
Check Log Message ${ERRORS}[0] ${message} WARN
2424

2525
Documentation
26-
Verify Documentation Documentation for this test case
26+
Verify Documentation Documentation in single line and column.
2727

2828
Documentation in multiple columns
2929
Verify Documentation Documentation for this test case in multiple columns
3030

3131
Documentation in multiple rows
32-
Verify Documentation 1st line is shortdoc.
32+
Verify Documentation 1st logical line
33+
... is shortdoc.
34+
... ${EMPTY}
3335
... Documentation for this test case
3436
... in multiple rows.
3537

@@ -46,7 +48,11 @@ Documentation with escaping
4648
Verify Documentation \${XXX} c:\\temp${SPACE*2}\\
4749

4850
Name and documentation on console
49-
Check Stdout Contains Documentation in multiple rows :: 1st line is shortdoc.${SPACE * 15}| PASS |
51+
Check Stdout Contains Normal name${SPACE * 59}| PASS |
52+
Check Stdout Contains test_case names are NOT _forMatted_${SPACE * 35}| PASS |
53+
Check Stdout Contains Documentation :: Documentation in single line and column.${SPACE * 13}| PASS |
54+
Check Stdout Contains Documentation in multiple rows :: 1st logical line is shortdoc.${SPACE * 7}| PASS |
55+
Check Stdout Contains Documentation with non-existing variables :: Starting from RF ${2}.1 ... | PASS |
5056

5157
Tags
5258
Verify Tags force-1 test-1 test-2

atest/testdata/parsing/suite_settings.robot

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
*** Settings ***
2-
Documentation ${1}st line is shortdoc.
2+
Documentation ${1}st logical line
3+
... (i.e. paragraph)
4+
... is shortdoc on console.
5+
...
36
... Text from multiple columns is catenated with spaces,
47
... and line continuation creates a new line.
58
... Newlines can also be added literally "\n\n".

atest/testdata/parsing/test_case_settings.robot

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,17 @@ test_case names are NOT _forMatted_
2525
No Operation
2626

2727
Documentation
28-
[Documentation] Documentation for this test case
28+
[Documentation] Documentation in single line and column.
2929
No Operation
3030

3131
Documentation in multiple columns
3232
[Documentation] Documentation for this test case in multiple columns
3333
No Operation
3434

3535
Documentation in multiple rows
36-
[DOCUMENTATION] ${1}st line is shortdoc.
36+
[DOCUMENTATION] ${1}st logical line
37+
... is shortdoc.
38+
...
3739
... Documentation for this test case
3840
... in multiple rows.
3941
No Operation

src/robot/output/console/verbose.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
import sys
1717

1818
from robot.errors import DataError
19-
from robot.utils import get_console_length, isatty, pad_console_length
19+
from robot.utils import (get_console_length, getshortdoc, isatty,
20+
pad_console_length)
2021

2122
from .highlighting import HighlightingStream
2223

@@ -97,7 +98,8 @@ def _get_info_width_and_separator(self, start_suite):
9798
def _get_info(self, name, doc, width):
9899
if get_console_length(name) > width:
99100
return pad_console_length(name, width)
100-
info = name if not doc else '%s :: %s' % (name, doc.splitlines()[0])
101+
doc = getshortdoc(doc, linesep=' ')
102+
info = '%s :: %s' % (name, doc) if doc else name
101103
return pad_console_length(info, width)
102104

103105
def suite_separator(self):

src/robot/utils/text.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ def getdoc(item):
166166
return unic(doc)
167167

168168

169-
def getshortdoc(doc_or_item):
169+
def getshortdoc(doc_or_item, linesep='\n'):
170170
if not doc_or_item:
171171
return u''
172172
doc = doc_or_item if is_string(doc_or_item) else getdoc(doc_or_item)
173173
lines = takewhile(lambda line: line.strip(), doc.splitlines())
174-
return '\n'.join(lines)
174+
return linesep.join(lines)

utest/utils/test_text.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ def func():
363363

364364
def _verify(self, doc, expected):
365365
assert_equal(getshortdoc(doc), expected)
366+
assert_equal(getshortdoc(doc, linesep=' '), expected.replace('\n', ' '))
366367

367368

368369
if __name__ == '__main__':

0 commit comments

Comments
 (0)