Skip to content

Commit ec7ea57

Browse files
HelioGuilherme66Helio GuilhermeNyraljnhyperionJohnny Huang
authored
Separates AppendText for MessagesLog. Adds process memory limit on Me… (#2086)
* Separates AppendText for MessagesLog. Adds process memory limit on MessagesLog. * Adds psutil to requirements. * Closes and reopens Messages Log window when process memory exceeds 80% * Key shortcuts update. * Fixes update notification * Improves Help links and About * Version 1.7.4rc1 * Update ride-1.7.4.rst Corrected rc1 version * Update ride-1.7.4.rst * Release notes for 1.7.4rc1 * Update ride-1.7.4.rst Make final version. * Development version * Improves release notes builder * Update ride-1.7.4.rst * Changes log to use unicode when on Python 2.7 (#2091) * Moved first condition at the end of the key processing event * Refactored structure of conditions in `OnKeyDown` * Makes some unit test files runnable * Version 1.7.4 * Back to development of 1.7.4.1 * Fixed shortcut in keyword tooltip. We no longer use Ctrl-M. (#2099) * Fixed shortcut in keyword tooltip. We no longer use Ctrl-M. * Updated implementation to use localize_shortcuts. * Fixed SelectAll issue in Grid Editor (#2096) * Moved first condition at the end of the key processing event * Refactored structure of conditions in `OnKeyDown` * Added debug prints and SelectAll shortcut when pressing Alt+A * Revert "Fixed SelectAll issue in Grid Editor (#2096)" (#2100) This reverts commit b7336e0. * Fixes newlines in cell tooltip (#2101) * Fixes newlines in cell tooltip * Fix tooltip unit test * Updates Maven and seleniumlibrary versions. (#2103) * Makes Text Editor read-only if file is read-only. Visual hint is back… (#2102) * Makes Text Editor read-only if file is read-only. Visual hint is background color change. * Updates Maven and seleniumlibrary versions. (#2103) * Fix named colors and update when file is read-only with focus on Text Editor * Update Travis to ubuntu xenial, wxPython and python 3.7 (#2104) * Corrects text update when on read-only on Text Editor (#2106) Fix read file when on read only on Text Editor * Fix for #1421, Repeated Resource files on Tree when on Windows (#2105) * Fix #2107 - Avoids changes in Resource file name when content assist. (#2109) * Removes changes to resource file name for suggestions of keywords * Avoids RuntimeError with ContentAssist for Resource Files * Fixes one test and reactivates other * Updates robotframework-mavenplugin version (#2110) * Uses unicode to calculate font name size when on Python 2.7 (#2112) * Made shortcuts from RIDE and Parser Log tabs to unregister when they're not selected * Removed debug prints and made Select All shortcut work (wasn't implemented) for Ride and Parser Log * Reverted workaround in previous commits and replaced `register_shortcuts` with OnKeyDown events to prevent further conflicts * Misc fixes (#2116) * Corrects Mac shortcut keys * Corrects messages for wxPython versions. * Added back shortcut registration for Cmd-C * Fixed SelectAll issue in Grid Editor, RIDE Log and Parser Log (#2113) * Moved first condition at the end of the key processing event * Refactored structure of conditions in `OnKeyDown` * Made shortcuts from RIDE and Parser Log tabs to unregister when they're not selected * Removed debug prints and made Select All shortcut work (wasn't implemented) for Ride and Parser Log * Reverted workaround in previous commits and replaced `register_shortcuts` with OnKeyDown events to prevent further conflicts * Added back shortcut registration for Cmd-C * Fixed SelectAll issue in Grid Editor, RIDE Log and Parser Log (#2113) * Moved first condition at the end of the key processing event * Refactored structure of conditions in `OnKeyDown` * Made shortcuts from RIDE and Parser Log tabs to unregister when they're not selected * Removed debug prints and made Select All shortcut work (wasn't implemented) for Ride and Parser Log * Reverted workaround in previous commits and replaced `register_shortcuts` with OnKeyDown events to prevent further conflicts * Added back shortcut registration for Cmd-C * Fixed SelectAll issue in Grid Editor, RIDE Log and Parser Log (#2113) * Moved first condition at the end of the key processing event * Refactored structure of conditions in `OnKeyDown` * Made shortcuts from RIDE and Parser Log tabs to unregister when they're not selected * Removed debug prints and made Select All shortcut work (wasn't implemented) for Ride and Parser Log * Reverted workaround in previous commits and replaced `register_shortcuts` with OnKeyDown events to prevent further conflicts * Added back shortcut registration for Cmd-C * Version 1.7.4.1 * Update ride-1.7.4.rst removed mentions to last support to python 2.7 * Update README.rest Version 1.7.4.1. * Back to development version - 2.0 * Replaces python 2.7 by 3.6 * Format Readme * Cleans Invoke * Removes python 2.7 from test_all.sh * Cleans tasks.py * Cleanup of wxPython/wxPhoenix version conditioning (#2121) * Adds pycodestyle for PyCharm PEP8 analysis * Removal of wxPython version conditions, code cleanup phase 1 * Removal of wxPython version conditions, code cleanup phase 1 * Removal of wxPython version conditions, code cleanup phase 1 * Removal of wxPython version conditions, code cleanup phase 1 * Removal of wxPython version conditions, code cleanup phase 1 * Removal of wxPython version conditions, code cleanup phase 1 * Change max line length to 90 char, for PyCharm * Removes Python 2.7 support (#2124) * Adds pycodestyle for PyCharm PEP8 analysis * Removal of wxPython version conditions, code cleanup phase 1 * Removal of wxPython version conditions, code cleanup phase 1 * Removal of wxPython version conditions, code cleanup phase 1 * Removal of wxPython version conditions, code cleanup phase 1 * Removal of wxPython version conditions, code cleanup phase 1 * Removal of wxPython version conditions, code cleanup phase 1 * Change max line length to 90 char, for PyCharm * Main removal of PY2 and PY3 * Final removal of PY2 and PY3 and basestring, unicode and unichar functions. * wx.NewId() to wx.NewIdRef() (#2125) * Changes wx.NewId to wx.NewIdRef * Add AppVeyor configuration (#2131) * Adds an autoclose timer to the Create Shortcut dialog. (#2130) * Adds an autoclose timer to the Create Shotcut dialog. * Changes Travis to use Ubuntu 18.04 * Appveyor (#2132) * Add AppVeyor configuration * Adds tox config * Changes install to be with tox (#2133) * Fixed Python 3.8 incompatibility (#2128) * Fixed setlocale error * Updated configobj to version 5.0.6 (latest). Old version was causing issues when reading from settings.cfg * Fixed small issue in preferences. Zoom factor wasn't getting set to negative values. * Fixes unit tests for #2128 (#2137) * Fixed setlocale error * Updated configobj to version 5.0.6 (latest). Old version was causing issues when reading from settings.cfg * Fixed small issue in preferences. Zoom factor wasn't getting set to negative values. * Fixes triggered errors and unit tests Co-authored-by: Nyral <[email protected]> * Fix travis (#2138) * Removes installation of RIDE. Avoids Segmentation fault on tags test * Fixes bad character when pressing a first key on Grid Editor * Fixes reprocessing of %date% %time% variables on Windows (#2141) * Inform that development branch is compatible with Python 3.8 * Cleans up unittests (#2142) * Fix one error that was being ignored * Restores two skipped tests. * Fixes resources and file unit tests * Better reason for skipped test. Removes errors of unclosed files * Reduced to two skipped tests * Attempt to clean C++ exceptions, only happens with Invoke * Fixed focus issue when using F2 to edit grid cell (#2140) * Added shortcut handling for F2 in order to set focus * Reverted previous commit and removed StartingClick because it's redundant. Text selection breaks if SelectAll() or SetSelection() is called after SetFocus(). This commit fixes that issue for double click and F2. * Added white color to inside the icon face (#2154) * Fixed crash when you delete tag and more (#2155) * Added condition to prevent event from return key from crashing RIDE * Added fix for when tag box remains empty when you delete the text you were writing in it; Added fix for TagBox deleted error when KillFocus is called. * Turns Test Suite Tree and File Explorer into Plugins (#2152) * Fix one error that was being ignored * First experiments * Test Suite Tree panel is now a Plugin * Changes File Explorer to be a Plugin * Added white color to inside the icon face (#2154) * Fixed crash when you delete tag and more (#2155) * Added condition to prevent event from return key from crashing RIDE * Added fix for when tag box remains empty when you delete the text you were writing in it; Added fix for TagBox deleted error when KillFocus is called. * Fixes perspectives on Tree pane * Fixes Perspectives and changes File Explorer to be a Plugin Co-authored-by: Nyral <[email protected]> * Fixes default arguments keyword help, #2134 (#2157) * Adds requirement for Python >=3.6 * Removes Python version conditioning * Adds APPDATA to environment and build step with Invoke. * Adds APPDATA var to tox.ini, changes to tox test * Adds badges for Travis and AppVeyor unit tests status * Adds README with ASCIIDoc format, will replace exisiting * Encloses text in Cell or selected text with certain symbols (#2158) * Encloses text in Cell or selected text with certain symbols * Corrects position of cursor. Fixes text selection highlight * Fixes select text (#2160) * Adds a flag to wx.TextControl to force selection highlight on Windows. * Text Editor - Encloses text in Cell or selected text with certain symbols. Adds support for Ctrl-3 and Ctrl-4 (Comment/Uncomment) * Fix comment/uncomment index range in Text Editor * Fix enclosing text * Fix variables creation * Fix keys in Grid editor * Fix keys in Grid Editor, [ and { still don't trigger * Fix error message from TreePlugin * Fix list selection on contextsuggestion. BREAKS enclose text in cell editor * Disable enclose text in cell editor when in Linux * Fixes { and [ in grid editor. Still disable in cell editor, on Linux * Adds autoident to Text Editor * Auto-indents, when first Task, Test or Keyword * Fixes { and [ in grid editor. Still disable in cell editor, on Linux * Fixes { and [ in Windows, grid editor * Fix keys (#2178) * Fixes { and [ in grid editor. Still disable in cell editor, on Linux * Avoids beep on keywords suggestions when on Linux * Adds ! to Save item on menu. Not detected when removed. (#2180) * Indents and de-indents block of selected text (#2181) * Experiments getting selection lines * Indent and de-indent blocks of text * Correct imports (#2182) * Adds conditions for wxPython 4.1.0 (#2184) * Upgrade wxPython to 4.1.0 (#2187) * Adds conditions for wxPython 4.1.0 * Fixes #2186 * Update docs about v1.7.4.2 * Log misc fixes (#2198) * Fixes syntax error * Makes error in removing log files a byte buffer. * Makes a test compatible with RF 3.2.1 * Better error and removal of old log files. (#2199) * Changes code to allow starting with File Explorer or Tree plugins disabled * Fix parsing warning of report/ log html file (#2212) Should not show this warning message if there're report/log html file in the workspace. Co-authored-by: Johnny Huang <[email protected]> * Fix for 1668: Given a large test suite, selecting all tests from the root of tree, freezes RIDE for some time (#2210) * 1668: The Select All Tests command on the root of a deeply nested test folder, freezes RIDE for several minutes. The problem is caused by Tree.SelectAllTests strategy: expanding and collapsing all the nodes. This causes CPU waste to expand/collapse (and maybe render) and wait for the creation of the tree node handlers. The idea of the fix is to navigate the tests using the link between controllers. In order to avoid all the dancing of the tree nodes. In this commit: - Changed Tree.SelectAllTests() to extract all the TestCaseController(s) and invoke TestSelectionController to change the selection for these. - Now both _ActionHandler OnDeselectAllTests() and OnSelectAllTests() invoke Tree.SelectAllTests(), with a parameter. - When a new TestCaseHandler is created, is registered to be notified about selection changes. It uses this notification to update the graphical node with the check. - RideTestSelectedForRunningChanged now also holds the controller of the test which has changed selection and whether has been selected or unselected. * Replace Tree DeselectAllTests(node) with SelectAllTests(node,False) as it's much more efficient. * TestSelectionController: Keep a copy of the tests to propagate in the event, rather than rebuild it everytime. * When selecting multiple tests, from the test search, do it efficiently. TestSelectionController: add select_all() to select multiple tests efficiently. Rewrite unselect_all() in terms of select_all() Tree: when selecting multiple tests, no need to navigate the full tree, just use TestSelectionController. * When deselecting multiple tests, from the test search, do it efficiently. Tree: when deselecting multiple tests, no need to navigate the full tree, just use TestSelectionController. * Do not expand all the tree nodes when selecting failed/passed tests. - Keep the information of failed/passed tests in TestCaseController - Update the information on the test execution - When selecting only failed/passed tests navigate the controller'tree rather than the graphical tree. - removed method _for_all_tests() as it was causing all the nodes to be loaded/rendered. * When selecting/deselecting multiple Tests, notify a single selection change event. Rather than one for each Test. * Restore previous behavior with "Select Failed/Passed": select only those and de-select any other test. * keep track of the selected tests using the TestCaseController(s), instead of the list of names. This removes the need for listen of name changes. * No need to generate the list of names, when determining if there's any. * Fix TestSelectionController.add_tag() * Handle RideTestSelectedForRunningChanged event on a new wx thread stack. This is to avoid the "Recursionerror: maximum recursion depth exceeded" * Remove unused variable. * Propagate the RideTestSelectedForRunningChanged event only if the selection actually changed. Co-authored-by: Valerio Bruno <[email protected]> * Fix tree node (#2214) * Increase development version. * Fixes error message on RIDE Log about missing tree_node_selected. * Fixes error message on RIDE Log about missing clear_all. (#2215) * Stops log when memory exceeds limit. Co-authored-by: Helio Guilherme <[email protected]> Co-authored-by: Nyral <[email protected]> Co-authored-by: Nyral <[email protected]> Co-authored-by: Johnny.H <[email protected]> Co-authored-by: Johnny Huang <[email protected]> Co-authored-by: Valerio <[email protected]> Co-authored-by: Valerio Bruno <[email protected]>
1 parent 856dbde commit ec7ea57

File tree

3 files changed

+80
-7
lines changed

3 files changed

+80
-7
lines changed

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ nose
33
mockito
44
invoke
55
rellu
6+
memory-profiler
67
# Include also normal project requirements.
78
-r requirements.txt
89

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ Pygments # This enables syntax highlighted in Text Editor
55
robotframeworklexer # Updates lexer to newer RF 3.1.1
66
robotframework
77
Pypubsub
8+
psutil

src/robotide/contrib/testrunner/testrunnerplugin.py

Lines changed: 78 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import datetime
4949
import time
5050
import os
51+
import psutil
5152
import re
5253
import wx
5354
import wx.stc
@@ -138,6 +139,10 @@ def __init__(self, application=None):
138139
self._register_shortcuts()
139140
self._min_log_level_number = LOG_LEVELS['INFO']
140141
self._selected_tests: {TestCaseController} = set()
142+
self._process = psutil.Process()
143+
self._initmemory = None
144+
self._limitmemory = None # This will be +80%
145+
self._maxmemmsg = None
141146

142147
@property
143148
def _names_to_run(self):
@@ -163,6 +168,7 @@ def _copy_from_out(self, event):
163168
return
164169
if self.message_log.GetSTCFocus():
165170
self.message_log.Copy()
171+
return
166172

167173
def enable(self):
168174
self.tree.set_checkboxes_for_tests()
@@ -217,14 +223,17 @@ def _subscribe_to_events(self):
217223
self.subscribe(self.OnSettingsChanged, RideSettingsChanged)
218224

219225
def OnSettingsChanged(self, data):
220-
"""Updates settings"""
226+
'''Updates settings'''
221227
section, setting = data.keys
222-
if section == "Test Run": # DEBUG temporarily we have two sections
228+
# print("DEBUG: enter OnSettingsChanged section %s" % (section))
229+
if section == 'Test Run': # DEBUG temporarily we have two sections
230+
# print("DEBUG: setting.get('confirm run')= %s " % setting)
231+
# print("DEBUG: new data= %s old %s new %s" % (data.keys, data.old, data.new))
223232
self.defaults.setdefault(setting, data.new)
224233
self.save_setting(setting, data.new)
225234

226235
def OnTestSelectedForRunningChanged(self, message):
227-
self._selected_tests = message.tests
236+
self._names_to_run = message.tests
228237

229238
def disable(self):
230239
self._remove_from_notebook()
@@ -267,29 +276,44 @@ def _hide_message_log(self):
267276
self.message_log = None
268277
self._right_panel.GetSizer().Layout()
269278

279+
def _recreate_message_log(self):
280+
self.show_log_messages_checkbox.SetValue(False)
281+
self._reset_memory_calc()
282+
self.show_log_messages_checkbox.SetValue(True)
283+
284+
def _reset_memory_calc(self):
285+
self._initmemory = self._process.memory_info()[0]
286+
self._limitmemory = self._initmemory * 1.80
287+
self._maxmemmsg = None
288+
270289
def OnStop(self, event):
271290
"""Called when the user clicks the "Stop" button
272291
273292
This sends a SIGINT to the running process, with the
274293
same effect as typing control-c when running from the
275294
command line."""
295+
self._reset_memory_calc()
276296
self._AppendText(self.out, '[ SENDING STOP SIGNAL ]\n',
277297
source='stderr')
278298
self._test_runner.send_stop_signal()
279299

280300
def OnPause(self, event):
301+
self._reset_memory_calc()
281302
self._AppendText(self.out, '[ SENDING PAUSE SIGNAL ]\n')
282303
self._test_runner.send_pause_signal()
283304

284305
def OnContinue(self, event):
306+
self._reset_memory_calc()
285307
self._AppendText(self.out, '[ SENDING CONTINUE SIGNAL ]\n')
286308
self._test_runner.send_continue_signal()
287309

288310
def OnStepNext(self, event):
311+
self._reset_memory_calc()
289312
self._AppendText(self.out, '[ SENDING STEP NEXT SIGNAL ]\n')
290313
self._test_runner.send_step_next_signal()
291314

292315
def OnStepOver(self, event):
316+
self._reset_memory_calc()
293317
self._AppendText(self.out, '[ SENDING STEP OVER SIGNAL ]\n')
294318
self._test_runner.send_step_over_signal()
295319

@@ -314,6 +338,7 @@ def OnRun(self, event):
314338
if not self.ask_user_to_run_anyway():
315339
# In Linux NO runs dialog 4 times
316340
return
341+
self._reset_memory_calc()
317342
self._initialize_ui_for_running()
318343
command = self._create_command()
319344
# DEBUG on Py3 it not shows correct if tags with latin chars
@@ -324,6 +349,7 @@ def OnRun(self, event):
324349
self._set_running()
325350
self._progress_bar.Start()
326351
except Exception as e:
352+
# self._output("DEBUG: Except block test_runner.run_command\n")
327353
self._set_stopped()
328354
error, log_message = self.get_current_profile().format_error(str(e), None)
329355
self._output(error)
@@ -475,10 +501,19 @@ def OnTimer(self, evt):
475501
self._output("\n", source="stdout")
476502
self._output(err_buffer, source="stderr")
477503
if self.message_log and not self._messages_log_texts.empty():
478-
texts = []
479-
while not self._messages_log_texts.empty():
480-
texts += [self._messages_log_texts.get()]
481-
self._AppendText(self.message_log, '\n'+'\n'.join(texts))
504+
if self._process.memory_info()[0] <= self._limitmemory:
505+
texts = []
506+
while not self._messages_log_texts.empty():
507+
texts += [self._messages_log_texts.get()]
508+
self._AppendTextMessageLog(self.message_log, '\n'+'\n'.join(texts))
509+
else:
510+
if not self._maxmemmsg:
511+
self._maxmemmsg = "Messages log exceeded 80% of process " \
512+
"memory, stopping for now..."
513+
self._AppendTextMessageLog(self.message_log,
514+
'\n' + self._maxmemmsg,
515+
source="stderr")
516+
# self._recreate_message_log() # DEBUG
482517

483518
def GetLastOutputChar(self):
484519
"""Return the last character in the output window"""
@@ -496,6 +531,7 @@ def _format_command(self, argv):
496531
"""
497532
result = []
498533
for arg in argv:
534+
# arg = arg.encode(encoding['SYSTEM'])
499535
if "'" in arg or " " in arg or "&" in arg:
500536
# for windows, if there are spaces we need to use
501537
# double quotes. Single quotes cause problems
@@ -513,6 +549,9 @@ def _show_notebook_tab(self):
513549
self._reload_model()
514550
self.show_tab(self.panel)
515551

552+
# from memory_profiler import profile as mprofile
553+
554+
# @mprofile
516555
def _AppendText(self, textctrl, string, source="stdout", enc=True):
517556
if not self.panel or not textctrl:
518557
return
@@ -551,6 +590,38 @@ def _AppendText(self, textctrl, string, source="stdout", enc=True):
551590
linecount = textctrl.GetLineCount()
552591
textctrl.ScrollToLine(linecount)
553592

593+
def _AppendTextMessageLog(self, textctrl, string, source="stdout", enc=True):
594+
if not self.panel or not textctrl:
595+
return
596+
textctrl.update_scroll_width(string)
597+
# we need this information to decide whether to autoscroll or not
598+
new_text_start = textctrl.GetLength()
599+
linecount = textctrl.GetLineCount()
600+
last_visible_line = textctrl.GetFirstVisibleLine() + \
601+
textctrl.LinesOnScreen() - 1
602+
603+
textctrl.SetReadOnly(False)
604+
try:
605+
if enc:
606+
textctrl.AppendText(string.encode(encoding['OUTPUT']))
607+
else:
608+
textctrl.AppendText(string)
609+
except UnicodeDecodeError as e:
610+
textctrl.AppendTextRaw(string.encode(encoding['SYSTEM']))
611+
except UnicodeEncodeError as e:
612+
textctrl.AppendText(string.encode('utf-8')) # DEBUG .encode('utf-8'))
613+
614+
new_text_end = textctrl.GetLength()
615+
616+
textctrl.StartStyling(new_text_start, 0x1f)
617+
if source == "stderr":
618+
textctrl.SetStyling(new_text_end-new_text_start, STYLE_STDERR)
619+
620+
textctrl.SetReadOnly(True)
621+
if last_visible_line >= linecount-4:
622+
linecount = textctrl.GetLineCount()
623+
textctrl.ScrollToLine(linecount)
624+
554625
def _get_console_width(self):
555626
# robot wants to know a fixed size for output, so calculate the
556627
# width of the window based on average width of a character. A

0 commit comments

Comments
 (0)