Skip to content
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
4 changes: 2 additions & 2 deletions rust/target_detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ def determine_targets(self, file_name, metadata=None):
if result:
return result

log.critical(self.window,
log.log(self.window,
'Rust Enhanced: Failed to find target for %r', file_name)
return []
return [(None, [])]

def _targets_manual_config(self, file_name):
"""Check for Cargo targets in the Sublime settings."""
Expand Down
18 changes: 12 additions & 6 deletions tests/test_target_detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def test_multi_targets(self):
# Random module in src/, defaults to --lib.
('src/lmod1.rs', [('src/lib.rs', '--lib')]),
# Target failure. Perhaps this should run rustc directly?
('mystery.rs', []),
('build.rs', []),
('mystery.rs', [(None, '')]),
('build.rs', [(None, '')]),
# Shared module in test, not possible to easily determine which
# test it belongs to.
('tests/common/helpers.rs', [('tests/test1.rs', '--test test1'),
Expand All @@ -53,11 +53,17 @@ def test_multi_targets(self):

for (path, targets) in expected_targets:
path = os.path.join('tests', 'multi-targets', path)
targets = [(os.path.normpath(
os.path.join(plugin_path, 'tests', 'multi-targets', x[0])),
x[1].split()) for x in targets]
joined_targets = []
for (target_path, args) in targets:
args = args.split()
if target_path:
joined = os.path.normpath(
os.path.join(plugin_path, 'tests', 'multi-targets', target_path))
joined_targets.append((joined, args))
else:
joined_targets.append((None, args))
self._with_open_file(path,
lambda view: self._test_multi_targets(view, targets))
lambda view: self._test_multi_targets(view, joined_targets))

def _test_multi_targets(self, view, expected_targets):
expected_targets.sort()
Expand Down