Skip to content

Fix macOS install issue #518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ jobs:
steps:
- uses: actions/checkout@v1
- run: bash ci/install-rust.sh ${{ matrix.rust }}
# Temporary workaround until Package Control 4 works
# https://github.com/wbond/package_control/issues/1612
- name: Fix macOS OpenSSL
if: matrix.os == 'macos-latest'
run: brew unlink openssl
- uses: SublimeText/UnitTesting/actions/setup@v1
with:
package-name: Rust Enhanced
Expand Down
17 changes: 13 additions & 4 deletions rust/opanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@
# this would be a problem. If it is, it's a simple matter of changing this.
PANEL_NAME = 'exec'

# Pattern used for finding location of panics in test output.
#
# Rust 1.73 changed the formatting of a panic message.
# Older versions looked like:
# thread 'basic_error1' panicked at 'assertion failed: false', tests/test_test_output.rs:9:5
# 1.73 changed it to look like:
# thread 'basic_error1' panicked at tests/test_test_output.rs:9:5:
# assertion failed: false
PANIC_PATTERN = r'(?:, |panicked at )([^,<\n]*\.[A-z]{2}):([0-9]+)'

def create_output_panel(window, base_dir):
output_view = window.create_output_panel(PANEL_NAME)
Expand All @@ -21,8 +30,7 @@ def create_output_panel(window, base_dir):
s.set('result_file_regex', '^[^:]+: (..[^:]*):([0-9]+): (.*)$')
else:
build_pattern = '^[ \\t]*-->[ \\t]*([^<\n]*):([0-9]+):([0-9]+)'
test_pattern = ', ([^,<\n]*\\.[A-z]{2}):([0-9]+)'
pattern = '(?|%s|%s)' % (build_pattern, test_pattern)
pattern = '(?|%s|%s)' % (build_pattern, PANIC_PATTERN)
s.set('result_file_regex', pattern)
# Used for resolving relative paths.
s.set('result_base_dir', base_dir)
Expand Down Expand Up @@ -76,8 +84,9 @@ def on_data(self, proc, data):
# Re-fetch the data to handle things like \t expansion.
appended = self.output_view.substr(
sublime.Region(region_start, self.output_view.size()))
m = re.search(r', ([^,<\n]*\.[A-z]{2}):([0-9]+):([0-9]+)',
appended)
# This pattern also includes column numbers (which Sublime's
# result_file_regex doesn't support).
m = re.search(PANIC_PATTERN + r':([0-9]+)', appended)
if m:
path = os.path.join(self.base_path, m.group(1))
if not os.path.exists(path):
Expand Down
40 changes: 29 additions & 11 deletions tests/test_message_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,19 @@ def _test_message_order(self, view, messages, inline, command):

to_close = []

# Helper to check when the view is updated to the correct location.
def check_view_has_updated(window, expected_filename, expected_row_col):
view = window.active_view()
view_filename = os.path.normpath(view.file_name())
if view_filename != expected_filename:
return False
region = view.sel()[0]
rowcol = view.rowcol(region.begin())
if expected_row_col[1] is None:
return rowcol[0] == expected_row_col[0]
else:
return rowcol == expected_row_col

def check_sequence(direction):
omsgs = messages if direction == 'next' else reversed(messages)
levels = ('all', 'error', 'warning') if inline else ('all',)
Expand All @@ -124,22 +137,27 @@ def check_sequence(direction):
window.run_command('rust_' + direction + '_message',
{'levels': level})
# Sublime doesn't always immediately move the active
# view when 'next_result' is called, so give it a
# moment to update.
time.sleep(0.1)
next_view = window.active_view()
to_close.append(next_view)
self.assertEqual(os.path.normpath(next_view.file_name()),
os.path.normpath(next_filename))
region = next_view.sel()[0]
rowcol = next_view.rowcol(region.begin())
# view when 'next_result' is called, so loop until
# it looks like it has updated to the correct location.
expected_filename = os.path.normpath(next_filename)
if inline:
self.assertEqual(rowcol, next_row_col)
expected_row_col = next_row_col
else:
# When inline is disabled, we use Sublime's
# built-in next/prev, which goes to the beginning.
# Just validate the row is correct.
self.assertEqual(rowcol[0], next_row_col[0])
expected_row_col = (next_row_col[0], None)
for _ in range(30):
if check_view_has_updated(window, expected_filename, expected_row_col):
break
time.sleep(0.1)
else:
view = window.active_view()
raise AssertionError('view did not update to %r at %r as expected\ncurrent view is %r at %r' % (
expected_filename, expected_row_col,
view.file_name(), view.rowcol(view.sel()[0].begin()))
)
to_close.append(window.active_view())
# Verify the output panel is highlighting the correct
# thing.
build_panel = window.find_output_panel(
Expand Down