Skip to content

Commit 6658a1b

Browse files
Implement name (#2973)
* Implement parsing of --name and Name setting. Needs utests. * Unit test for named suites
1 parent 006f953 commit 6658a1b

File tree

10 files changed

+69
-18
lines changed

10 files changed

+69
-18
lines changed

CHANGELOG.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ and this project adheres to http://semver.org/spec/v2.0.0.html[Semantic Versioni
99
== https://github.com/robotframework/RIDE[Unreleased]
1010

1111
=== Added
12+
- Added parsing of option *--name* or *-N* and *Name* setting, to allow running test suites with them set.
13+
1214
- Added indication of *private* keywords in Grid Editor, keywords will show in _Italic_, and with error
1315
background, when they are used outside of Keywords section, or from different files.
1416

src/robotide/application/CHANGELOG.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Changelog</title><link rel="stylesheet" type="text/css" href="docbook-xsl.css" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /></head><body><div xml:lang="en" class="article" lang="en"><div class="titlepage"><div><div><h2 class="title"><a id="id1337"></a>Changelog</h2></div></div><hr /></div><p>All notable changes to this project will be documented in this file.</p><p>The format is based on <a class="ulink" href="http://keepachangelog.com/en/1.0.0/" target="_top">Keep a Changelog</a>
33
and this project adheres to <a class="ulink" href="http://semver.org/spec/v2.0.0.html" target="_top">Semantic Versioning</a>.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_ulink_url_https_github_com_robotframework_ride_unreleased_ulink"></a>1. <a class="ulink" href="https://github.com/robotframework/RIDE" target="_top">Unreleased</a></h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_added"></a>1.1. Added</h3></div></div></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
4+
Added parsing of option <span class="strong"><strong>--name</strong></span> or <span class="strong"><strong>-N</strong></span> and <span class="strong"><strong>Name</strong></span> setting, to allow running test suites with them set.
5+
</li><li class="listitem">
46
Added indication of <span class="strong"><strong>private</strong></span> keywords in Grid Editor, keywords will show in <span class="emphasis"><em>Italic</em></span>, and with error
57
background, when they are used outside of Keywords section, or from different files.
68
</li><li class="listitem">

src/robotide/application/releasenotes.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def set_content(self, html_win, content):
150150
151151
<p><a class="reference external" href="https://github.com/robotframework/RIDE/">RIDE (Robot Framework IDE)</a>
152152
{VERSION} is a new release with some enhancements and bug fixes. The reference for valid arguments is
153-
<a class="reference external" href="https://robotframework.org/">Robot Framework</a> current version, 7.3.1. However,
153+
<a class="reference external" href="https://robotframework.org/">Robot Framework</a> current version, 7.3.2. However,
154154
internal library code is originally based on version 3.1.2, but adapted for new versions.</p>
155155
<ul class="simple">
156156
<li>This version supports Python 3.8 up to 3.13 (and also tested on 3.14.a7 with wxPython 4.2.3).</li>
@@ -172,6 +172,7 @@ def set_content(self, html_win, content):
172172
</ul>
173173
<p><strong>New Features and Fixes Highlights</strong></p>
174174
<ul class="simple">
175+
<li>Added parsing of option <b>--name</b> or <b>-N</b> and <b>Name</b> setting, to allow running tests with them set.</li>
175176
<li>Added indication of <b>private</b> keywords in Grid Editor, keywords will show in <em>Italic</em>, and with error
176177
background, when they are used outside of Keywords section, or from different files.</li>
177178
<li>Added indication of <b>private</b> keywords in Details pop-up for keywords with tag <b>robot:private</b> or name starting
@@ -255,7 +256,7 @@ def set_content(self, html_win, content):
255256
<pre class="literal-block">python -m robotide.postinstall -install</pre>
256257
<p>or</p>
257258
<pre class="literal-block">ride_postinstall.py -install</pre>
258-
<p>RIDE {VERSION} was released on 17/July/2025.</p>
259+
<p>RIDE {VERSION} was released on 20/July/2025.</p>
259260
<!-- <br/>
260261
<h3>May The Fourth Be With You!</h3>
261262
<h3>Celebrate the bank holiday, 10th June, Day of Portugal, Portuguese Communities and Camões!!</h3>

src/robotide/contrib/testrunner/ArgsParser.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ class ArgsParser:
3636

3737
@staticmethod
3838
def get_message_log_level(args, default='INFO'):
39-
level = ArgsParser._get_arg_value('-L', '--loglevel',
40-
args, default)
39+
level = ArgsParser._get_arg_value('-L', '--loglevel', args, default)
4140
level_list = level.upper().split(':')
4241
try:
4342
min_level = LOG_LEVELS[level_list[0]] or LOG_LEVELS[default]
@@ -49,8 +48,11 @@ def get_message_log_level(args, default='INFO'):
4948

5049
@staticmethod
5150
def get_output_directory(args, default):
52-
return ArgsParser._get_arg_value('-d', '--outputdir',
53-
args, default)
51+
return ArgsParser._get_arg_value('-d', '--outputdir', args, default)
52+
53+
@staticmethod
54+
def get_named_suite(args, default=''):
55+
return ArgsParser._get_arg_value('-N', '--name', args, default)
5456

5557
@staticmethod
5658
def _get_arg_value(short_name, full_name, source, default):

src/robotide/contrib/testrunner/CommandArgs.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,20 @@ def with_output_directory(self, output_directory):
6060
self._output_directory = output_directory
6161
return self
6262

63-
def with_runnable_tests(self, tests):
63+
def with_runnable_tests(self, tests, named_suite=''):
64+
def fix_name(name):
65+
if named_suite:
66+
if '.' in name:
67+
l_name = name.split('.')
68+
l_name[0] = named_suite
69+
return '.'.join(l_name)
70+
else:
71+
return named_suite
72+
return name
73+
6474
self._tests_to_run.clear()
6575
for suite, test in tests:
66-
self._tests_to_run += ['--suite', suite, '--test', test]
76+
self._tests_to_run += ['--suite', fix_name(suite), '--test', fix_name(test)]
6777
return self
6878

6979
def without_console_color(self, without_colors=True):

src/robotide/contrib/testrunner/testrunner.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,19 @@ def __init__(self, project):
6464
self.profiles = {}
6565
self._pause_longname = None
6666
self._pause_testname = None
67+
self._named_suite = ''
68+
self._suite_name = None
6769

6870
def enable(self, result_handler):
6971
self._start_listener_server(result_handler)
7072

7173
def add_profile(self, name, item):
7274
self.profiles[name] = item
7375

76+
def set_named_suite(self, name):
77+
self._suite_name = self._project.suite.name
78+
self._named_suite = name
79+
7480
def get_profile(self, name):
7581
return self.profiles[name]
7682

@@ -125,6 +131,9 @@ def _result_handler(self, event, *args):
125131

126132
def _get_test_controller(self, longname, testname=None):
127133
ret = self._project.find_controller_by_longname(longname, testname)
134+
if not ret and self._named_suite:
135+
ret = self._project.find_controller_by_longname(longname.replace(self._named_suite, self._suite_name)
136+
.strip('.'), testname)
128137
return ret
129138

130139
def clear_server(self):
@@ -186,6 +195,8 @@ def is_running(self):
186195
def command_ended(self):
187196
self._results.set_stopped(None)
188197
self._process = None
198+
self._named_suite = ''
199+
self._suite_name = None
189200

190201

191202
# The following two classes implement a small line-buffered socket

src/robotide/contrib/testrunner/testrunnerplugin.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ def __init__(self, application=None):
181181
self._initmemory = None
182182
self._limitmemory = None # This will be +80%
183183
self._maxmemmsg = None
184+
self._named_suite = ''
184185
self.active_status_bar = self.__getattr__('active_status_bar')
185186
self.use_colors = self.__getattr__('use colors')
186187
self.fail_color = self.__getattr__('fail color')
@@ -193,6 +194,10 @@ def _names_to_run(self):
193194
map(lambda ctrl: (ctrl.datafile_controller.longname, ctrl.longname),
194195
self._selected_tests))
195196

197+
def named_suite(self, args):
198+
self._named_suite = ArgsParser.get_named_suite(args)
199+
return self._named_suite
200+
196201
def _register_shortcuts(self):
197202
self.register_shortcut('CtrlCmd-C', self._copy_from_log_ctrls)
198203
self.register_shortcut('CtrlCmd-L', self.on_show_log)
@@ -410,7 +415,7 @@ def _create_command_args(self, profile_command_args, log_level='INFO', use_color
410415
.with_python_path(self.global_settings.get('pythonpath', None)) \
411416
.with_console_width(self._get_console_width()) \
412417
.without_console_color(not use_colors) \
413-
.with_runnable_tests(self._names_to_run) \
418+
.with_runnable_tests(self._names_to_run, self.named_suite(profile_command_args)) \
414419
.build()
415420

416421
def _save_command_args_in_file(self, args):
@@ -430,16 +435,14 @@ def _initialize_variables_for_running(self, profile_settings, args):
430435
self._report_file = self._log_file = None
431436
self._log_message_queue = Queue()
432437

433-
self._min_log_level_number = \
434-
ArgsParser.get_message_log_level(args)
438+
self._min_log_level_number = ArgsParser.get_message_log_level(args)
439+
440+
self._logs_directory = ArgsParser.get_output_directory(args, self._default_output_dir)
435441

436-
self._logs_directory = \
437-
ArgsParser.get_output_directory(args, self._default_output_dir)
442+
self._test_runner.set_named_suite(self.named_suite(args)) # When no tests selected, to have execution status
438443

439-
console_log_name = \
440-
SettingsParser.get_console_log_name(profile_settings)
441-
self._console_log = '' if not console_log_name \
442-
else os.path.join(self._logs_directory, console_log_name)
444+
console_log_name = SettingsParser.get_console_log_name(profile_settings)
445+
self._console_log = '' if not console_log_name else os.path.join(self._logs_directory, console_log_name)
443446

444447
def _get_current_working_dir(self, profile):
445448
if profile.name == runprofiles.CustomScriptProfile.name:

src/robotide/lib/robot/parsing/model.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,12 @@ def _table_is_allowed(self, table):
248248

249249
@property
250250
def name(self):
251+
# if self.has_setting_table():
252+
# print(f"DEBUG: model.py _TestData name HAS SETTING_TABLE")
253+
suite_name = self.setting_table.suite_name
254+
if suite_name and suite_name.value:
255+
# print(f"DEBUG: model.py _TestData name RETURN SUITE_NAME={suite_name.value}")
256+
return suite_name.value
251257
return self._format_name(self._get_basename()) if self.source else None
252258

253259
@property

src/robotide/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
#
1616
# Automatically generated by `tasks.py`.
1717

18-
VERSION = 'v2.2dev34'
18+
VERSION = 'v2.2dev35'

utest/contrib/testrunner/test_args_parser.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,20 @@ def test_get_output_directory_long(self):
124124
result = ArgsParser.get_output_directory(args, DEFAULT_LOGS)
125125
self.assertEqual('/temp/report', result)
126126

127+
def test_get_named_suite_short(self):
128+
args = ['-N', 'My Named Suite',
129+
'--suite', 'suite_name_1',
130+
'--test', 'test_1']
131+
result = ArgsParser.get_named_suite(args)
132+
self.assertEqual('My Named Suite', result)
133+
134+
def test_get_named_suite_long(self):
135+
args = ['--name', 'My Named Suite',
136+
'--suite', 'suite_name_1',
137+
'--test', 'test_1']
138+
result = ArgsParser.get_named_suite(args)
139+
self.assertEqual('My Named Suite', result)
140+
127141

128142
if __name__ == '__main__':
129143
unittest.main()

0 commit comments

Comments
 (0)