forked from SublimeText/UnitTesting
/
test_color_scheme.py
47 lines (36 loc) · 1.39 KB
/
test_color_scheme.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import sublime
from sublime_plugin import ApplicationCommand
from .mixin import UnitTestingMixin
from .const import DONE_MESSAGE
try:
from ColorSchemeUnit.lib.runner import ColorSchemeUnit
except Exception:
print('ColorSchemeUnit runner could not be imported')
class UnitTestingColorSchemeCommand(ApplicationCommand, UnitTestingMixin):
def run(self, package=None, **kargs):
if not package:
return
window = sublime.active_window()
settings = self.load_unittesting_settings(package, **kargs)
stream = self.load_stream(package, settings["output"])
tests = sublime.find_resources("color_scheme_test*")
tests = [t for t in tests if t.startswith("Packages/%s/" % package)]
if not tests:
stream.write("ERROR: No syntax_test files are found in %s!" % package)
stream.write("\n")
stream.write(DONE_MESSAGE)
stream.close()
return
# trigger "Start reading output"
stream.write("Running ColorSchemeUnit\n")
stream.flush()
result = ColorSchemeUnit(window).run(output=stream, package=package, async=False)
if result:
stream.write('\n')
stream.write("OK.\n")
else:
stream.write('\n')
stream.write("FAILED.\n")
stream.write("\n")
stream.write(DONE_MESSAGE)
stream.close()