From 46757ade5df16b0fca009f70c0be28da57ec74fb Mon Sep 17 00:00:00 2001 From: Alisson Perez Date: Thu, 30 Jul 2015 17:53:11 -0300 Subject: [PATCH 1/2] Changed to show used command to execute tests --- PythonTestOutput.hidden-tmLanguage | 18 ++++++++++++++++++ PythonTestOutput.hidden-tmTheme | 11 +++++++++++ plugin.py | 13 +++++++++---- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/PythonTestOutput.hidden-tmLanguage b/PythonTestOutput.hidden-tmLanguage index acb5a90..90c5ffa 100644 --- a/PythonTestOutput.hidden-tmLanguage +++ b/PythonTestOutput.hidden-tmLanguage @@ -6,6 +6,24 @@ PythonTestOutput patterns + + begin + Command: + captures + + 1 + + name + test.command + + + comment + command running + end + \n + match + "(.*)" + begin ^[=-]+$ diff --git a/PythonTestOutput.hidden-tmTheme b/PythonTestOutput.hidden-tmTheme index 744b430..ac84b79 100644 --- a/PythonTestOutput.hidden-tmTheme +++ b/PythonTestOutput.hidden-tmTheme @@ -23,6 +23,17 @@ #DDF0FF33 + + name + Command + scope + test.command + settings + + foreground + #004ACA + + name Test diff --git a/plugin.py b/plugin.py index 383259c..ef77fc5 100644 --- a/plugin.py +++ b/plugin.py @@ -20,6 +20,10 @@ def run(self, edit): # turn on language/theme for output panel somehow panel = self.view.window().create_output_panel('exec') panel.settings().set('color_scheme', self.color_scheme(settings)) + + command_print_msg = r'echo "Command: \"{}\""'.format(re.sub('"', '\\"', command)) + command = command_print_msg + "; " + command + self.view.window().run_command( "exec", {"cmd": [command], "file_regex": TB_FILE, @@ -57,21 +61,22 @@ def find_test_name(self, tx, point): matches = TEST_FUNC_RE.findall(tx) if not matches: return - print(matches) + indent, funcname = matches[-1] if not indent: return funcname + # find the enclosing class before = self.view.substr(sublime.Region(0, point)) - print(len(before)) classes = TEST_CASE_RE.findall(before) - print(classes) + if not classes: return funcname # this is probably bad + candidates = [c for i, c in classes if len(i) < len(indent)] - print(candidates) if candidates: return "%s.%s" % (candidates[-1], funcname) + return funcname # also probably bad def file_to_module(self, wd, fn): From df854a8d4035f7a21a7cee0de3a545e76fcfeb2a Mon Sep 17 00:00:00 2001 From: Alisson Perez Date: Mon, 31 Aug 2015 14:54:48 -0300 Subject: [PATCH 2/2] Fixed "echo bug" - Sometimes terminal was freezing with 'echo' to print test command used. With python print this is not happening anymore. --- plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.py b/plugin.py index ef77fc5..2315bb2 100644 --- a/plugin.py +++ b/plugin.py @@ -21,7 +21,7 @@ def run(self, edit): panel = self.view.window().create_output_panel('exec') panel.settings().set('color_scheme', self.color_scheme(settings)) - command_print_msg = r'echo "Command: \"{}\""'.format(re.sub('"', '\\"', command)) + command_print_msg = 'python -c "print(\'Command \\"{}\\"\')"'.format(re.sub('"', '\\"', command)) command = command_print_msg + "; " + command self.view.window().run_command(