Reading syntax tests' output feels downright painful when scopes start to span multiple lines:
Does the problem lie with the tests themselves? I don't think so - at times, complexity is unavoidable, and nested contexts tend to bring a lot of clutter with them; rather, I think it's a matter of presentation - not knowing where to look when reading output containing lengthy scopes is...
On the other hand, it's not possible to appeal to everyone - people have their own preferences regarding how an easier to parse output should look like, as previous discussions showed.
Preferred solution
Make RunSyntaxTestsCommand accept a custom formatter as a parameter:
Overriding run_syntax_tests.py locally, modifying RunSyntaxTestsCommand at the very least.
Additional Information
Feel free to use the following patch as you deem fit - I don't know how sublime_api.run_syntax_test(...) works exactly, but this assumes it would return list[dict[...]] with failure details instead of list[str]:
diff --git a/Default/run_syntax_tests.py b/Default/run_syntax_tests.py
index 8ec24b73b4a2..228347c2b61f 100644
--- a/Default/run_syntax_tests.py
+++ b/Default/run_syntax_tests.py
@@ -13,12 +13,16 @@ class RunSyntaxTestsCommand(sublime_plugin.WindowCommand):
def run(self,
find_all=False,
syntax='Plain text.tmLanguage',
+ formatter=None,
**kwargs):
if not hasattr(self, 'output_view'):
# Try not to call get_output_panel until the regexes are assigned
self.output_view = self.window.create_output_panel('exec')
+ if formatter is None:
+ formatter = '{file}:{line}:{column}: [{expected}] does not match scope [{actual}]\n'
+
settings = self.output_view.settings()
settings.set('result_file_regex', PACKAGES_FILE_REGEX)
@@ -69,13 +73,12 @@ class RunSyntaxTestsCommand(sublime_plugin.WindowCommand):
total_assertions = 0
failed_assertions = 0
- for t in tests:
- assertions, test_output_lines = sublime_api.run_syntax_test(t)
+ for test in tests:
+ assertions, failures = sublime_api.run_syntax_test(test)
total_assertions += assertions
- if len(test_output_lines) > 0:
- failed_assertions += len(test_output_lines)
- for line in test_output_lines:
- append(self.output_view, line + '\n')
+ if failures:
+ failed_assertions += len(failures)
+ append(self.output_view, ''.join(formatter.format(failure) for failure in failures))
if failed_assertions > 0:
message = 'FAILED: {} of {} assertions in {} files failed\n'
Related: #3022 (though that issue centers on syntax, not semantics)
Problem description
Reading syntax tests' output feels downright painful when scopes start to span multiple lines:
Does the problem lie with the tests themselves? I don't think so - at times, complexity is unavoidable, and nested contexts tend to bring a lot of clutter with them; rather, I think it's a matter of presentation - not knowing where to look when reading output containing lengthy scopes is...
On the other hand, it's not possible to appeal to everyone - people have their own preferences regarding how an easier to parse output should look like, as previous discussions showed.
Preferred solution
Make
RunSyntaxTestsCommand
accept a custom formatter as a parameter:Custom syntax + custom formatter = free reign.
Alternatives
Overriding
run_syntax_tests.py
locally, modifyingRunSyntaxTestsCommand
at the very least.Additional Information
Feel free to use the following patch as you deem fit - I don't know how
sublime_api.run_syntax_test(...)
works exactly, but this assumes it would returnlist[dict[...]]
with failure details instead oflist[str]
:Related: #3022 (though that issue centers on syntax, not semantics)