Skip to content

Commit d30a3cb

Browse files
committed
Deprecate --xunitskipnoncritical option
1 parent 4fb15ea commit d30a3cb

File tree

7 files changed

+21
-53
lines changed

7 files changed

+21
-53
lines changed

atest/robot/output/xunit.robot

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,10 @@ Invalid XUnit File
5959
Stderr Should Match Regexp
6060
... \\[ ERROR \\] Opening xunit file '${path}' failed: .*
6161

62-
Skipping non-critical tests
63-
Run tests --xUnit xunit.xml --xUnitSkipNonCritical --NonCritical fail ${PASS AND FAIL}
64-
${root} = Get XUnit Node .
65-
Suite Stats Should Be ${root} 2 0 1
66-
${skipped} = Get XUnit Node testcase/skipped
67-
Should be equal ${skipped.text} FAIL: Expected failure
62+
Skipping non-critical tests is deprecated
63+
Run tests --xUnit xunit.xml --xUnitSkipNonCritical ${PASS AND FAIL}
64+
Stderr Should Contain Command line option --xunitskipnoncritical has been deprecated.
6865

69-
Skipping all tests
70-
Run tests --xunit xunit.xml --xunitskip ${PASS AND FAIL}
71-
${root} = Get XUnit Node .
72-
Suite Stats Should Be ${root} 2 0 2
73-
${skipped} = Get XUnit Nodes testcase/skipped
74-
Should be equal ${skipped[0].text} PASS
75-
Should be equal ${skipped[1].text} FAIL: Expected failure
76-
Length Should Be ${skipped} 2
7766

7867
*** Keywords ***
7968
Get XUnit Node

atest/robot/rebot/xunit.robot

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,9 @@ Times in xUnit output
3737
Element Attribute Should Match ${suite} time ?.???
3838
Element Attribute Should Match ${suite} time ?.??? xpath=.//testcase[1]
3939

40-
XUnit skip non-criticals
41-
Run Rebot --xUnit xunit.xml --xUnitSkipNonCritical --NonCritical f1 ${INPUT FILE}
42-
Stderr Should Be Empty
43-
${root} = Parse XML ${OUTDIR}/xunit.xml
44-
Element Attribute Should Be ${root} tests 19
45-
Element Attribute Should Be ${root} failures 4
46-
Element Attribute Should Be ${root} skipped 10
47-
${skipped} = Get Elements ${root} xpath=testcase/skipped
48-
Should Be Equal ${skipped[0].text} FAIL: Expected
49-
Should Be Equal ${skipped[1].text} PASS
50-
Length Should Be ${skipped} 10
40+
XUnit skip non-criticals is deprecated
41+
Run Rebot --xUnit xunit.xml --xUnitSkipNonCritical ${INPUT FILE}
42+
Stderr Should Contain Command line option --xunitskipnoncritical has been deprecated.
5143

5244
Invalid XUnit File
5345
Create Directory ${INVALID}

src/robot/conf/settings.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ def _validate_expandkeywords(self, values):
305305
if not opt.lower().startswith(('name:', 'tag:')):
306306
raise DataError("Invalid value for option '--expandkeywords'. "
307307
"Expected 'TAG:<pattern>', or "
308-
"'NAME:<pattern>' but got '%s'." % opt)
308+
"'NAME:<pattern>' but got '%s'." % opt)
309309

310310
def __contains__(self, setting):
311311
return setting in self._cli_opts
@@ -346,10 +346,6 @@ def split_log(self):
346346
def status_rc(self):
347347
return self['StatusRC']
348348

349-
@property
350-
def xunit_skip_noncritical(self):
351-
return self['XUnitSkipNonCritical']
352-
353349
@property
354350
def statistics_config(self):
355351
return {

src/robot/rebot.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@
145145
similarly as --log. Default: report.html
146146
-x --xunit file xUnit compatible result file. Not created unless this
147147
option is specified.
148-
--xunitskipnoncritical Mark non-critical tests in xUnit output as skipped.
148+
--xunitskipnoncritical *Deprecated* since Robot Framework 4.0.
149149
-T --timestampoutputs When this option is used, timestamp in a format
150150
`YYYYMMDD-hhmmss` is added to all generated output
151151
files between their basename and extension. For
@@ -339,6 +339,8 @@ def __init__(self):
339339
def main(self, datasources, **options):
340340
settings = RebotSettings(options)
341341
LOGGER.register_console_logger(**settings.console_output_config)
342+
if settings['XUnitSkipNonCritical']:
343+
LOGGER.warn("Command line option --xunitskipnoncritical has been deprecated.")
342344
LOGGER.disable_message_cache()
343345
rc = ResultWriter(*datasources).write_results(settings)
344346
if rc < 0:

src/robot/reporting/resultwriter.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ def write_results(self, settings=None, **options):
5757
if settings.output:
5858
self._write_output(results.result, settings.output)
5959
if settings.xunit:
60-
self._write_xunit(results.result, settings.xunit,
61-
settings.xunit_skip_noncritical)
60+
self._write_xunit(results.result, settings.xunit)
6261
if settings.log:
6362
config = dict(settings.log_config,
6463
minLevel=results.js_result.min_level)
@@ -72,8 +71,8 @@ def write_results(self, settings=None, **options):
7271
def _write_output(self, result, path):
7372
self._write('Output', result.save, path)
7473

75-
def _write_xunit(self, result, path, skip_noncritical):
76-
self._write('XUnit', XUnitWriter(result, skip_noncritical).write, path)
74+
def _write_xunit(self, result, path):
75+
self._write('XUnit', XUnitWriter(result).write, path)
7776

7877
def _write_log(self, js_result, path, config):
7978
self._write('Log', LogWriter(js_result).write, path, config)

src/robot/reporting/xunitwriter.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@
2121

2222
class XUnitWriter(object):
2323

24-
def __init__(self, execution_result, skip_noncritical):
24+
def __init__(self, execution_result):
2525
self._execution_result = execution_result
26-
self._skip_noncritical = skip_noncritical
2726

2827
def write(self, output):
2928
xml_writer = XmlWriter(output, usage='xunit')
30-
writer = XUnitFileWriter(xml_writer, self._skip_noncritical)
29+
writer = XUnitFileWriter(xml_writer)
3130
self._execution_result.visit(writer)
3231

3332

@@ -38,10 +37,9 @@ class XUnitFileWriter(ResultVisitor):
3837
http://marc.info/?l=ant-dev&m=123551933508682
3938
"""
4039

41-
def __init__(self, xml_writer, skip_noncritical=False):
40+
def __init__(self, xml_writer):
4241
self._writer = xml_writer
4342
self._root_suite = None
44-
self._skip_noncritical = skip_noncritical
4543

4644
def start_suite(self, suite):
4745
if self._root_suite:
@@ -57,12 +55,8 @@ def start_suite(self, suite):
5755
self._writer.start('testsuite', attrs)
5856

5957
def _get_stats(self, statistics):
60-
if self._skip_noncritical:
61-
failures = statistics.critical.failed
62-
skipped = statistics.all.total - statistics.critical.total
63-
else:
64-
failures = statistics.all.failed
65-
skipped = 0
58+
failures = statistics.all.failed
59+
skipped = 0
6660
return str(statistics.all.total), str(failures), str(skipped)
6761

6862
def end_suite(self, suite):
@@ -74,16 +68,10 @@ def visit_test(self, test):
7468
{'classname': test.parent.longname,
7569
'name': test.name,
7670
'time': self._time_as_seconds(test.elapsedtime)})
77-
if self._skip_noncritical and not test.critical:
78-
self._skip_test(test)
79-
elif not test.passed:
71+
if not test.passed:
8072
self._fail_test(test)
8173
self._writer.end('testcase')
8274

83-
def _skip_test(self, test):
84-
self._writer.element('skipped', '%s: %s' % (test.status, test.message)
85-
if test.message else test.status)
86-
8775
def _fail_test(self, test):
8876
self._writer.element('failure', attrs={'message': test.message,
8977
'type': 'AssertionError'})

src/robot/run.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,8 @@ def __init__(self):
425425
def main(self, datasources, **options):
426426
settings = RobotSettings(options)
427427
LOGGER.register_console_logger(**settings.console_output_config)
428+
if settings['XUnitSkipNonCritical']:
429+
LOGGER.warn("Command line option --xunitskipnoncritical has been deprecated.")
428430
LOGGER.info('Settings:\n%s' % unic(settings))
429431
builder = TestSuiteBuilder(settings['SuiteNames'],
430432
included_extensions=settings.extension,

0 commit comments

Comments
 (0)