Hi bitserf,
Unfortunately I can’t see the screenshot you linked to (blocked by my work), but I have some ideas on how you might approach this type of issue.
Maybe you can create your own output panel for the test results, write your results to that output panel and set the syntax of the panel to use a custom syntax that adequately “highlights” your results.
Your plugin can write to the panel as it completes the test cases, giving you a decent progress indicator. You could also get creative with the message that you are writing and include the overall success status of the test cases alongside the status of the most recent test case. If you also know how many test cases there are and which one you are on, you could provide a %-complete indication as well.
Here is a very basic custom syntax to use as an example. If your line starts with “FAIL” it will highlight the word FAIL (according to your color scheme). Save this file in “Packages/User/TestCaseResults.tmLanguage”.
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>patterns</key>
<array>
<dict>
<key>match</key>
<string>^FAIL</string>
<key>name</key>
<string>invalid.illegal.unexpected-text.test_case_results</string>
</dict>
</array>
<key>name</key>
<string>Test case results custom syntax</string>
<key>scopeName</key>
<string>source.test_case_results</string>
</dict>
</plist>
Creating a custom syntax to highlight your test case results may take some fiddling, but shouldn’t be too tough (depending on how complicated your test case results are and how much coloring you want).
Here are some resources on creating a custom syntax (aka language grammars). There are also a bunch of forum discussion about creating custom syntaxes.
manual.macromates.com/en/language_grammars
sublimetext.info/docs/en/extensi … xdefs.html
Here is some example code to make your own output panel, write to it and set the syntax. This code will request some input and simply echo that to an output panel. To see the custom syntax working, you will need to enter some text that starts with “FAIL”.
import sublime, sublime_plugin
class ExampleCommand(sublime_plugin.WindowCommand):
def run(self):
sublime.active_window().show_input_panel('Enter a test case result to append to the output panel', '', lambda s: self.appendTestCaseResult(s), None, None)
def appendTestCaseResult(self, message):
# some unique name for your output panel
panel_name = 'MyPluginName-OutputPanel'
# relative path to your custom syntax
custom_syntax = 'Packages/User/TestCaseResults.tmLanguage'
# only use "get_output_panel" once, otherwise sublime will
# recreate a new one and you will lose any existing text
if not hasattr(self, 'panel'):
self.panel = sublime.active_window().get_output_panel(panel_name)
v = self.panel
# write this text to the output panel and display it
edit = v.begin_edit()
v.insert(edit, v.size(), message + '\n')
v.end_edit(edit)
v.show_at_center(v.size())
# set the syntax of the output panel
v.set_syntax_file(custom_syntax)
# make sure the panel is visible
sublime.active_window().run_command("show_panel", {"panel": "output." + panel_name})
Hope that helps.
Cheers,
Josh