From 0f062748ea7c5fac42305afe9fb6f9558889ce04 Mon Sep 17 00:00:00 2001 From: ehuss Date: Sat, 27 Jan 2018 09:50:38 -0800 Subject: [PATCH] Update message handling for Rust 1.24. (#235) * Remove Cargo.lock files in tests, not needed. * Update message handling for Rust 1.24. --- .gitignore | 1 + SyntaxCheckPlugin.py | 12 +++-- cargo_build.py | 6 ++- rust/cargo_config.py | 54 +++++-------------- rust/cargo_settings.py | 26 ++++++++- rust/messages.py | 12 ++--- rust/opanel.py | 14 +++-- rust/util.py | 35 ++++++++++++ tests/error-tests/Cargo.lock | 11 ---- tests/error-tests/dcrate/Cargo.lock | 4 -- tests/error-tests/tests/arg-count-mismatch.rs | 3 +- tests/error-tests/tests/error_across_mod.rs | 9 ++-- tests/error-tests/tests/error_across_mod_f.rs | 3 +- .../tests/macro-expansion-outside-1.rs | 2 +- tests/message-order/Cargo.lock | 4 -- tests/message-order/tests/test_test_output.rs | 12 +++-- tests/multi-targets/Cargo.lock | 4 -- tests/multi-targets/libs/cdylib/Cargo.lock | 4 -- tests/multi-targets/libs/dylib/Cargo.lock | 4 -- tests/multi-targets/libs/rlib/Cargo.lock | 4 -- tests/multi-targets/libs/staticlib/Cargo.lock | 4 -- tests/multi-targets/pmacro/Cargo.lock | 31 ----------- tests/multi-targets/tests/common/helpers.rs | 2 +- tests/slow-build/Cargo.lock | 4 -- tests/test_cargo_build.py | 19 +++---- tests/test_cargo_settings.py | 2 +- tests/test_interrupt.py | 2 +- tests/test_message_order.py | 13 +++-- tests/workspace/Cargo.lock | 8 --- tests/workspace/workspace2/src/lib.rs | 6 +-- 30 files changed, 140 insertions(+), 175 deletions(-) delete mode 100644 tests/error-tests/Cargo.lock delete mode 100644 tests/error-tests/dcrate/Cargo.lock delete mode 100644 tests/message-order/Cargo.lock delete mode 100644 tests/multi-targets/Cargo.lock delete mode 100644 tests/multi-targets/libs/cdylib/Cargo.lock delete mode 100644 tests/multi-targets/libs/dylib/Cargo.lock delete mode 100644 tests/multi-targets/libs/rlib/Cargo.lock delete mode 100644 tests/multi-targets/libs/staticlib/Cargo.lock delete mode 100644 tests/multi-targets/pmacro/Cargo.lock delete mode 100644 tests/slow-build/Cargo.lock delete mode 100644 tests/workspace/Cargo.lock diff --git a/.gitignore b/.gitignore index ca5fecec..2bb0f638 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.cache target/ +Cargo.lock diff --git a/SyntaxCheckPlugin.py b/SyntaxCheckPlugin.py index 240ca968..8351e0e7 100755 --- a/SyntaxCheckPlugin.py +++ b/SyntaxCheckPlugin.py @@ -73,8 +73,10 @@ class RustSyntaxCheckThread(rust_thread.RustThread, rust_proc.ProcListener): view = None # Absolute path to the view that triggered the check. triggered_file_name = None - # Directory of `triggered_file_name`. + # Directory where cargo will be run. cwd = None + # Base path for relative paths in messages. + msg_rel_path = None # This flag is used to terminate early. In situations where we can't # auto-detect the appropriate Cargo target, we compile multiple targets. # If we receive any messages for the current view, we might as well stop. @@ -125,7 +127,8 @@ def get_rustc_messages(self): # Clippy does not support cargo target filters, must be run for # all targets. cmd = settings.get_command(method, command_info, self.cwd, - force_json=True) + self.cwd, force_json=True) + self.msg_rel_path = cmd['msg_rel_path'] p = rust_proc.RustProc() p.run(self.window, cmd['command'], self.cwd, self, env=cmd['env']) p.wait() @@ -135,9 +138,10 @@ def get_rustc_messages(self): td = target_detect.TargetDetector(self.window) targets = td.determine_targets(self.triggered_file_name) for (target_src, target_args) in targets: - cmd = settings.get_command(method, command_info, self.cwd, + cmd = settings.get_command(method, command_info, self.cwd, self.cwd, initial_settings={'target': ' '.join(target_args)}, force_json=True) + self.msg_rel_path = cmd['msg_rel_path'] if method == 'no-trans': cmd['command'].extend(['--', '-Zno-trans', '-Zunstable-options']) if (util.get_setting('rust_syntax_checking_include_tests', True) and @@ -173,7 +177,7 @@ def on_error(self, proc, message): print('Rust Error: %s' % message) def on_json(self, proc, obj): - messages.add_rust_messages(self.window, self.cwd, obj, + messages.add_rust_messages(self.window, self.msg_rel_path, obj, self.current_target_src, msg_cb=None) if messages.has_message_for_path(self.window, self.triggered_file_name): diff --git a/cargo_build.py b/cargo_build.py index 68835d33..f83bc43c 100644 --- a/cargo_build.py +++ b/cargo_build.py @@ -191,13 +191,15 @@ def run(self): cmd = self.settings.get_command(self.command_name, self.command_info, self.settings_path, + self.working_dir, self.initial_settings) if not cmd: return messages.clear_messages(self.window) p = rust_proc.RustProc() - listener = opanel.OutputListener(self.window, self.working_dir, - self.command_name) + listener = opanel.OutputListener(self.window, cmd['msg_rel_path'], + self.command_name, + cmd['rustc_version']) decode_json = util.get_setting('show_errors_inline', True) and \ self.command_info.get('allows_json', False) try: diff --git a/rust/cargo_config.py b/rust/cargo_config.py index 5e2b61e7..c32a0968 100644 --- a/rust/cargo_config.py +++ b/rust/cargo_config.py @@ -9,7 +9,7 @@ import sublime import sublime_plugin from .cargo_settings import CargoSettings, CARGO_COMMANDS -from .util import index_with +from .util import index_with, get_cargo_metadata from . import rust_proc, util # Keep track of recent choices to set the default value. @@ -54,7 +54,7 @@ class CargoConfigBase(sublime_plugin.WindowCommand): # Dictionary of choices passed into the command, instead of using # interactive UI. - input = None + cmd_input = None # Sequence of questions to ask. sequence = None @@ -90,7 +90,7 @@ def run(self, **kwargs): self.sequence_index = 0 # Copy, since WindowCommand reuses objects. self._sequence = self.sequence[:] - self.input = kwargs + self.cmd_input = kwargs self.settings = CargoSettings(self.window) self.settings.load() self.show_next_question() @@ -123,8 +123,8 @@ def make_choice(value): self._sequence[i:i] = next self.show_next_question() - if q in self.input: - make_choice(self.input[q]) + if q in self.cmd_input: + make_choice(self.cmd_input[q]) else: try: item_info = getattr(self, 'items_' + q)() @@ -286,11 +286,11 @@ def items_which(self): """Choice to select at which level the setting should be saved at.""" # This is a bit of a hack so that when called programmatically you # don't have to specify 'which'. - if 'which' not in self.input: - if 'variant' in self.input: - self.input['which'] = 'project_package_variant' - elif 'target' in self.input: - self.input['which'] = 'project_package_target' + if 'which' not in self.cmd_input: + if 'variant' in self.cmd_input: + self.cmd_input['which'] = 'project_package_variant' + elif 'target' in self.cmd_input: + self.cmd_input['which'] = 'project_package_target' variant_extra = 'cargo build, cargo run, cargo test, etc.' target_extra = '--bin, --example, --test, etc.' @@ -615,9 +615,9 @@ def done(self): // Enter environment variables here in JSON syntax. // Close this view when done to commit the settings. """) - if 'contents' in self.input: + if 'contents' in self.cmd_input: # Used when parsing fails to attempt to edit again. - template = self.input['contents'] + template = self.cmd_input['contents'] elif default: template += sublime.encode_value(default, True) else: @@ -948,33 +948,3 @@ def _stock_build_system(self): pkg_name = __name__.split('.')[0] resource = 'Packages/%s/RustEnhanced.sublime-build' % pkg_name return sublime.decode_value(sublime.load_resource(resource)) - - -def get_cargo_metadata(window, cwd): - """Load Cargo metadata. - - :returns: None on failure, otherwise a dictionary from Cargo: - - packages: List of packages: - - name - - manifest_path: Path to Cargo.toml. - - targets: List of target dictionaries: - - name: Name of target. - - src_path: Path of top-level source file. May be a - relative path. - - kind: List of kinds. May contain multiple entries if - `crate-type` specifies multiple values in Cargo.toml. - Lots of different types of values: - - Libraries: 'lib', 'rlib', 'dylib', 'cdylib', 'staticlib', - 'proc-macro' - - Executables: 'bin', 'test', 'example', 'bench' - - build.rs: 'custom-build' - - :raises ProcessTermiantedError: Process was terminated by another thread. - """ - output = rust_proc.slurp_json(window, - 'cargo metadata --no-deps'.split(), - cwd=cwd) - if output: - return output[0] - else: - return None diff --git a/rust/cargo_settings.py b/rust/cargo_settings.py index a44ff992..6a85e798 100644 --- a/rust/cargo_settings.py +++ b/rust/cargo_settings.py @@ -350,7 +350,8 @@ def get_merged(self, settings_path, variant, target, key, return result def get_command(self, cmd_name, cmd_info, - settings_path, initial_settings={}, force_json=False): + settings_path, working_dir, + initial_settings={}, force_json=False): """Generates the command arguments for running Cargo. :param cmd_name: The name of the command, the key used to select a @@ -358,7 +359,9 @@ def get_command(self, cmd_name, cmd_info, :param cmd_info: Dictionary from `CARGO_COMMANDS` with rules on how to construct the command. :param settings_path: The absolute path to the Cargo project root - directory. + directory or script. + :param working_dir: The directory where Cargo is to be run (typically + the project root). :keyword initial_settings: Initial settings to inject which override all other settings. :keyword force_json: If True, will force JSON output. @@ -366,6 +369,10 @@ def get_command(self, cmd_name, cmd_info, :Returns: A dictionary with the keys: - `command`: The command to run as a list of strings. - `env`: Dictionary of environment variables (or None). + - `msg_rel_path`: The root path to use for relative paths in + messages. + - `rustc_version`: The version of rustc being used as a string, + such as '1.25.0-nightly'. Returns None if the command cannot be constructed. """ @@ -453,7 +460,22 @@ def expand(s): if not env: env = None + # Determine the base path for paths in messages. + # + # Starting in Rust 1.24, all messages and symbols are relative to the + # workspace root instead of the package root. + metadata = util.get_cargo_metadata(self.window, working_dir, toolchain) + if metadata and 'workspace_root' in metadata: + # 'workspace_root' key added in 1.24. + msg_rel_path = metadata['workspace_root'] + else: + msg_rel_path = working_dir + + rustc_version = util.get_rustc_version(self.window, working_dir, toolchain=toolchain) + return { 'command': result, 'env': env, + 'msg_rel_path': msg_rel_path, + 'rustc_version': rustc_version, } diff --git a/rust/messages.py b/rust/messages.py index fb9f8020..aa2e2163 100644 --- a/rust/messages.py +++ b/rust/messages.py @@ -636,11 +636,11 @@ def on_highlighted(idx): window.show_quick_panel(panel_items, on_done, 0, 0, on_highlighted) -def add_rust_messages(window, cwd, info, target_path, msg_cb): +def add_rust_messages(window, base_path, info, target_path, msg_cb): """Add messages from Rust JSON to Sublime views. - `window`: Sublime Window object. - - `cwd`: Directory where cargo/rustc was run. + - `base_path`: Base path used for resolving relative paths from Rust. - `info`: Dictionary of messages from rustc or cargo. - `target_path`: Absolute path to the top-level source file of the target (lib.rs, main.rs, etc.). May be None if it is not known. @@ -684,7 +684,7 @@ def add_rust_messages(window, cwd, info, target_path, msg_cb): # List of message dictionaries, belonging to the main message. additional_messages = [] - _collect_rust_messages(window, cwd, info, target_path, msg_cb, {}, + _collect_rust_messages(window, base_path, info, target_path, msg_cb, {}, main_message, additional_messages) messages = _create_cross_links(main_message, additional_messages) @@ -750,7 +750,7 @@ def escape_and_link(i_txt): False, None, content, None) -def _collect_rust_messages(window, cwd, info, target_path, +def _collect_rust_messages(window, base_path, info, target_path, msg_cb, parent_info, main_message, additional_messages): """ @@ -831,7 +831,7 @@ def _collect_rust_messages(window, cwd, info, target_path, return def make_span_path(span): - return os.path.realpath(os.path.join(cwd, span['file_name'])) + return os.path.realpath(os.path.join(base_path, span['file_name'])) def make_span_region(span): # Sublime text is 0 based whilst the line/column info from @@ -981,7 +981,7 @@ def find_span_r(span, expansion=None): # Recurse into children (which typically hold notes). for child in info['children']: - _collect_rust_messages(window, cwd, child, target_path, + _collect_rust_messages(window, base_path, child, target_path, msg_cb, parent_info.copy(), main_message, additional_messages) diff --git a/rust/opanel.py b/rust/opanel.py index 691de9d8..de26576c 100644 --- a/rust/opanel.py +++ b/rust/opanel.py @@ -4,7 +4,7 @@ import os import re -from . import rust_proc, messages, util +from . import rust_proc, messages, util, semver # Use the same panel name that Sublime's build system uses so that "Show Build # Results" will open the same panel. I don't see any particular reason why @@ -12,7 +12,7 @@ PANEL_NAME = 'exec' -def create_output_panel(window, cwd): +def create_output_panel(window, base_dir): output_view = window.create_output_panel(PANEL_NAME) s = output_view.settings() if util.get_setting('show_errors_inline', True): @@ -25,7 +25,7 @@ def create_output_panel(window, cwd): pattern = '(?|%s|%s)' % (build_pattern, test_pattern) s.set('result_file_regex', pattern) # Used for resolving relative paths. - s.set('result_base_dir', cwd) + s.set('result_base_dir', base_dir) s.set('word_wrap', True) # XXX Or False? s.set('line_numbers', False) s.set('gutter', False) @@ -58,10 +58,11 @@ class OutputListener(rust_proc.ProcListener): # Sublime view used for output. output_view = None - def __init__(self, window, base_path, command_name): + def __init__(self, window, base_path, command_name, rustc_version): self.window = window self.base_path = base_path self.command_name = command_name + self.rustc_version = rustc_version def on_begin(self, proc): self.output_view = create_output_panel(self.window, self.base_path) @@ -87,6 +88,9 @@ def on_data(self, proc, data): lineno = int(m.group(2)) - 1 # Region columns appear to the left, so this is +1. col = int(m.group(3)) + # Rust 1.24 changed column numbering to be 1-based. + if semver.match(self.rustc_version, '>=1.24.0-beta'): + col -= 1 span = ((lineno, col), (lineno, col)) # +2 to skip ", " build_region = sublime.Region(region_start + m.start() + 2, @@ -105,7 +109,7 @@ def on_error(self, proc, message): def on_json(self, proc, obj): if 'message' in obj: - messages.add_rust_messages(self.window, proc.cwd, obj['message'], + messages.add_rust_messages(self.window, self.base_path, obj['message'], None, self.msg_cb) def msg_cb(self, message): diff --git a/rust/util.py b/rust/util.py index 4692b210..07d638e9 100644 --- a/rust/util.py +++ b/rust/util.py @@ -110,3 +110,38 @@ def active_view_is_rust(window=None, view=None): if not view.file_name(): return False return 'source.rust' in view.scope_name(0) + + +def get_cargo_metadata(window, cwd, toolchain=None): + """Load Cargo metadata. + + :returns: None on failure, otherwise a dictionary from Cargo: + - packages: List of packages: + - name + - manifest_path: Path to Cargo.toml. + - targets: List of target dictionaries: + - name: Name of target. + - src_path: Path of top-level source file. May be a + relative path. + - kind: List of kinds. May contain multiple entries if + `crate-type` specifies multiple values in Cargo.toml. + Lots of different types of values: + - Libraries: 'lib', 'rlib', 'dylib', 'cdylib', 'staticlib', + 'proc-macro' + - Executables: 'bin', 'test', 'example', 'bench' + - build.rs: 'custom-build' + + :raises ProcessTermiantedError: Process was terminated by another thread. + """ + from . import rust_proc + cmd = ['cargo'] + if toolchain: + cmd.append('+' + toolchain) + cmd.extend(['metadata', '--no-deps']) + output = rust_proc.slurp_json(window, + cmd, + cwd=cwd) + if output: + return output[0] + else: + return None diff --git a/tests/error-tests/Cargo.lock b/tests/error-tests/Cargo.lock deleted file mode 100644 index ded6aea4..00000000 --- a/tests/error-tests/Cargo.lock +++ /dev/null @@ -1,11 +0,0 @@ -[root] -name = "error-tests" -version = "0.1.0" -dependencies = [ - "dcrate 0.1.0", -] - -[[package]] -name = "dcrate" -version = "0.1.0" - diff --git a/tests/error-tests/dcrate/Cargo.lock b/tests/error-tests/dcrate/Cargo.lock deleted file mode 100644 index 08a575f2..00000000 --- a/tests/error-tests/dcrate/Cargo.lock +++ /dev/null @@ -1,4 +0,0 @@ -[root] -name = "dcrate" -version = "0.1.0" - diff --git a/tests/error-tests/tests/arg-count-mismatch.rs b/tests/error-tests/tests/arg-count-mismatch.rs index 615f0656..88c5c0ee 100644 --- a/tests/error-tests/tests/arg-count-mismatch.rs +++ b/tests/error-tests/tests/arg-count-mismatch.rs @@ -11,8 +11,9 @@ // error-pattern: parameters were supplied /*BEGIN*/fn f(x: isize) { +// ^^^^^^^^^^^^^^ERR(>=1.24.0-beta) defined here }/*END*/ -// ~ERR defined here +// ~ERR(<1.24.0-beta) defined here // children without spans, spans with no labels // Should display error (with link) and a note of expected type. diff --git a/tests/error-tests/tests/error_across_mod.rs b/tests/error-tests/tests/error_across_mod.rs index 2c188894..935a1301 100644 --- a/tests/error-tests/tests/error_across_mod.rs +++ b/tests/error-tests/tests/error_across_mod.rs @@ -2,7 +2,10 @@ mod error_across_mod_f; fn test() { error_across_mod_f::f(1); -// ^ERR this function takes 0 parameters but 1 -// ^ERR expected 0 parameters -// ^MSG Note: error_across_mod_f.rs:1 +// ^ERR(<1.24.0-beta) this function takes 0 parameters but 1 +// ^ERR(<1.24.0-beta) expected 0 parameters +// ^MSG(<1.24.0-beta) Note: error_across_mod_f.rs:1 +// ^^^^^^^^^^^^^^^^^^^^^^^^ERR(>=1.24.0-beta) this function takes 0 parameters but 1 +// ^^^^^^^^^^^^^^^^^^^^^^^^ERR(>=1.24.0-beta) expected 0 parameters +// ^^^^^^^^^^^^^^^^^^^^^^^^MSG(>=1.24.0-beta) Note: error_across_mod_f.rs:1 } diff --git a/tests/error-tests/tests/error_across_mod_f.rs b/tests/error-tests/tests/error_across_mod_f.rs index 1f8bb46d..f4d6bea2 100644 --- a/tests/error-tests/tests/error_across_mod_f.rs +++ b/tests/error-tests/tests/error_across_mod_f.rs @@ -1,3 +1,4 @@ /*BEGIN*/pub fn f() { +// ^^^^^^^^^^ERR(>=1.24.0-beta) defined here }/*END*/ -// ~ERR defined here +// ~ERR(<1.24.0-beta) defined here diff --git a/tests/error-tests/tests/macro-expansion-outside-1.rs b/tests/error-tests/tests/macro-expansion-outside-1.rs index a1fa9933..4e138959 100644 --- a/tests/error-tests/tests/macro-expansion-outside-1.rs +++ b/tests/error-tests/tests/macro-expansion-outside-1.rs @@ -10,7 +10,7 @@ extern crate dcrate; // ~ERR(>=1.20.0) /expected one of .*, found `:`/ // ~ERR(>=1.20.0) this error originates in a macro outside of the current crate // ~ERR(>=1.20.0) /expected one of .* here/ -// ~ERR(>=1.20.0,<1.24.0-nightly) unexpected token +// ~ERR(>=1.20.0,<1.24.0-beta) unexpected token // ~ERR(>=1.20.0) /expected one of .*, found `:`/ // ~ERR(>=1.20.0) expected one of // end-msg: ERR(check,>=1.19.0,<1.20.0-beta) /expected one of .*, found `:`/ diff --git a/tests/message-order/Cargo.lock b/tests/message-order/Cargo.lock deleted file mode 100644 index dd7eb9a0..00000000 --- a/tests/message-order/Cargo.lock +++ /dev/null @@ -1,4 +0,0 @@ -[root] -name = "message-order" -version = "0.1.0" - diff --git a/tests/message-order/tests/test_test_output.rs b/tests/message-order/tests/test_test_output.rs index 6985d579..3bcf1927 100644 --- a/tests/message-order/tests/test_test_output.rs +++ b/tests/message-order/tests/test_test_output.rs @@ -6,27 +6,29 @@ fn passing() { #[test] fn basic_error1() { - /*ERR 1 "tests/test_test_output.rs:9:46"*/assert!(false); + // . is used for the column because Rust 1.24 changed the column indexing + // to be 1-based. + /*ERR 1 "tests/test_test_output.rs:11:4."*/assert!(false); } #[test] fn basic_error2() { - /*ERR 2 "tests/test_test_output.rs:14:47"*/assert_eq!(1, 0); + /*ERR 2 "tests/test_test_output.rs:16:4."*/assert_eq!(1, 0); } #[test] fn basic_error3() { - /*ERR 3 "tests/test_test_output.rs:19:47"*/assert_ne!(1, 1); + /*ERR 3 "tests/test_test_output.rs:21:4."*/assert_ne!(1, 1); } #[test] fn custom_message() { - /*ERR 4 "tests/test_test_output.rs:24:47"*/assert!(false, "Custom message"); + /*ERR 4 "tests/test_test_output.rs:26:4."*/assert!(false, "Custom message"); } #[test] fn manual_panic() { - /*ERR 5 "tests/test_test_output.rs:29:47"*/panic!("manual panic"); + /*ERR 5 "tests/test_test_output.rs:31:4."*/panic!("manual panic"); } #[test] diff --git a/tests/multi-targets/Cargo.lock b/tests/multi-targets/Cargo.lock deleted file mode 100644 index 777a6064..00000000 --- a/tests/multi-targets/Cargo.lock +++ /dev/null @@ -1,4 +0,0 @@ -[root] -name = "multi-targets" -version = "0.1.0" - diff --git a/tests/multi-targets/libs/cdylib/Cargo.lock b/tests/multi-targets/libs/cdylib/Cargo.lock deleted file mode 100644 index a35a29b6..00000000 --- a/tests/multi-targets/libs/cdylib/Cargo.lock +++ /dev/null @@ -1,4 +0,0 @@ -[root] -name = "cdylib" -version = "0.1.0" - diff --git a/tests/multi-targets/libs/dylib/Cargo.lock b/tests/multi-targets/libs/dylib/Cargo.lock deleted file mode 100644 index f49db359..00000000 --- a/tests/multi-targets/libs/dylib/Cargo.lock +++ /dev/null @@ -1,4 +0,0 @@ -[root] -name = "dylib" -version = "0.1.0" - diff --git a/tests/multi-targets/libs/rlib/Cargo.lock b/tests/multi-targets/libs/rlib/Cargo.lock deleted file mode 100644 index f7fe350e..00000000 --- a/tests/multi-targets/libs/rlib/Cargo.lock +++ /dev/null @@ -1,4 +0,0 @@ -[root] -name = "rlib" -version = "0.1.0" - diff --git a/tests/multi-targets/libs/staticlib/Cargo.lock b/tests/multi-targets/libs/staticlib/Cargo.lock deleted file mode 100644 index f7fe350e..00000000 --- a/tests/multi-targets/libs/staticlib/Cargo.lock +++ /dev/null @@ -1,4 +0,0 @@ -[root] -name = "rlib" -version = "0.1.0" - diff --git a/tests/multi-targets/pmacro/Cargo.lock b/tests/multi-targets/pmacro/Cargo.lock deleted file mode 100644 index ff1f2a15..00000000 --- a/tests/multi-targets/pmacro/Cargo.lock +++ /dev/null @@ -1,31 +0,0 @@ -[root] -name = "pmacro" -version = "0.1.0" -dependencies = [ - "quote 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "quote" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "syn" -version = "0.11.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "quote 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "unicode-xid" -version = "0.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[metadata] -"checksum quote 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)" = "e7b44fd83db28b83c1c58187159934906e5e955c812e211df413b76b03c909a5" -"checksum syn 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f4f94368aae82bb29656c98443a7026ca931a659e8d19dcdc41d6e273054e820" -"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" diff --git a/tests/multi-targets/tests/common/helpers.rs b/tests/multi-targets/tests/common/helpers.rs index 73b13b86..ff2610e5 100644 --- a/tests/multi-targets/tests/common/helpers.rs +++ b/tests/multi-targets/tests/common/helpers.rs @@ -9,7 +9,7 @@ /*BEGIN*/pub fn unused() { // ^^^^^^^^^^^^^^^WARN(>=1.22.0) function is never used -// ^^^^^^^^^^^^^^^NOTE(<1.24.0-nightly) #[warn(dead_code)] +// ^^^^^^^^^^^^^^^NOTE(<1.24.0-beta) #[warn(dead_code)] }/*END*/ // ~WARN(<1.22.0) function is never used // ~NOTE(<1.22.0,>=1.17.0) #[warn(dead_code)] diff --git a/tests/slow-build/Cargo.lock b/tests/slow-build/Cargo.lock deleted file mode 100644 index 3038bebe..00000000 --- a/tests/slow-build/Cargo.lock +++ /dev/null @@ -1,4 +0,0 @@ -[root] -name = "slow-build" -version = "0.1.0" - diff --git a/tests/test_cargo_build.py b/tests/test_cargo_build.py index 35744947..0eb1e193 100644 --- a/tests/test_cargo_build.py +++ b/tests/test_cargo_build.py @@ -54,28 +54,22 @@ def _test_build_with_target(self, view): targets = [ ('--bin bin1', [ exe('bin1'), - version('bin1.d', '>=1.21.0'), 'libmulti_targets.rlib']), ('--bin bin2', [ exe('bin2'), - version('bin2.d', '>=1.21.0'), 'libmulti_targets.rlib']), ('--bin otherbin', [ exe('otherbin'), - version('otherbin.d', '>=1.21.0'), 'libmulti_targets.rlib']), ('--bin multi-targets', [ exe('multi-targets'), - version('multi-targets.d', '>=1.21.0'), 'libmulti_targets.rlib']), ('--lib', [ - 'libmulti_targets.rlib', - version('libmulti_targets.d', '>=1.21.0')]), + 'libmulti_targets.rlib']), # Not clear to me why it produces ex1-* files. ('--example ex1', [ exe('examples/ex1'), exe('examples/ex1-*'), - version('examples/ex1.d', '>=1.21.0'), 'libmulti_targets.rlib']), ('--test test1', [ exe('bin1'), @@ -101,6 +95,7 @@ def _test_build_with_target(self, view): files = [x for x in files if os.path.isfile(os.path.join(debug, x)) and not x.startswith('.') and + not x.endswith('.d') and not x.endswith('.pdb')] files.sort() # Remove any option (None) entries. @@ -151,7 +146,7 @@ def _test_target_triple(self, view): settings.load() cmd_info = cargo_settings.CARGO_COMMANDS['build'] manifest_dir = util.find_cargo_manifest(view.file_name()) - cmd = settings.get_command('build', cmd_info, manifest_dir)['command'] + cmd = settings.get_command('build', cmd_info, manifest_dir, manifest_dir)['command'] self.assertEqual(cmd, ['cargo', 'build', '--target', 'a-b-c', '--message-format=json']) @@ -170,7 +165,7 @@ def _test_toolchain(self, view): settings.load() cmd_info = cargo_settings.CARGO_COMMANDS['build'] manifest_dir = util.find_cargo_manifest(view.file_name()) - cmd = settings.get_command('build', cmd_info, manifest_dir)['command'] + cmd = settings.get_command('build', cmd_info, manifest_dir, manifest_dir)['command'] self.assertEqual(cmd, ['cargo', '+nightly', 'build', '--message-format=json']) @@ -181,7 +176,7 @@ def _test_toolchain(self, view): settings.load() cmd_info = cargo_settings.CARGO_COMMANDS['build'] manifest_dir = util.find_cargo_manifest(view.file_name()) - cmd = settings.get_command('build', cmd_info, manifest_dir)['command'] + cmd = settings.get_command('build', cmd_info, manifest_dir, manifest_dir)['command'] self.assertEqual(cmd, ['cargo', 'build', '--message-format=json']) @@ -193,7 +188,7 @@ def _test_toolchain(self, view): 'target': '--bin bin1'}) settings.load() manifest_dir = util.find_cargo_manifest(view.file_name()) - cmd = settings.get_command('build', cmd_info, manifest_dir)['command'] + cmd = settings.get_command('build', cmd_info, manifest_dir, manifest_dir)['command'] self.assertEqual(cmd, ['cargo', '+nightly', 'build', '--bin', 'bin1', '--message-format=json']) @@ -418,7 +413,7 @@ def test_auto_build(self): """Test "auto" build.""" tests = [ # This should probably automatically use nightly? - ('benches/bench1.rs', r'may not be used on the stable release channel'), + ('benches/bench1.rs', r'may not be used on the (stable|beta) release channel'), ('examples/ex1.rs', r'(?m)^ex1$'), ('src/bin/bin1.rs', r'(?m)^bin1$'), ('src/altmain.rs', r'(?m)^altmain$'), diff --git a/tests/test_cargo_settings.py b/tests/test_cargo_settings.py index 19d368b7..96d3165f 100644 --- a/tests/test_cargo_settings.py +++ b/tests/test_cargo_settings.py @@ -16,7 +16,7 @@ def test_settings(self): def check_cmd(expected_cmd): cmd = settings.get_command('build', - cmd_info, manifest_dir)['command'] + cmd_info, manifest_dir, manifest_dir)['command'] self.assertEqual(cmd, expected_cmd.split()) cmd = 'cargo build --message-format=json' diff --git a/tests/test_interrupt.py b/tests/test_interrupt.py index 98ad2c41..e89c43ed 100644 --- a/tests/test_interrupt.py +++ b/tests/test_interrupt.py @@ -181,7 +181,7 @@ def _test_build_with_save(self, view): self._run_build() build_t = self._get_rust_thread() self._wrap_terminate(build_t) - time.sleep(4) + time.sleep(5) self.assertEqual(self._files(), [pattern + '-start-1', pattern + '-end-1']) diff --git a/tests/test_message_order.py b/tests/test_message_order.py index 23095b00..d55880e3 100644 --- a/tests/test_message_order.py +++ b/tests/test_message_order.py @@ -41,6 +41,12 @@ def test_message_order(self): The number is the order the message should appear. Two numbers can be specified separated with a comma, where the second number is the "unsorted" sequence (the order the message is emitted from rustc). + + The "inline" message is the message in the build output panel that + should be displayed when inline phantoms are being used. The "raw" + version is what is displayed when inline phantoms are not being used. + These value is a regular expressions tested against region in the + output panel. """ to_test = [ ('build', 'examples/ex_warning1.rs', @@ -99,9 +105,9 @@ def check_sequence(direction): plugin.rust.opanel.PANEL_NAME) panel_text = build_panel.substr(build_panel.sel()[0]) if inline: - self.assertEqual(panel_text, inline_highlight) + self.assertRegex(panel_text, inline_highlight) else: - self.assertEqual(panel_text, raw_highlight) + self.assertRegex(panel_text, raw_highlight) check_sequence('next') if inline: @@ -150,7 +156,8 @@ def _collect_message_order_view(self, view, result): def path_fixup(p): if sys.platform == 'win32': - return p.replace('/', '\\') + # Double backslash since it is a regex. + return p.replace('/', '\\\\') else: return p diff --git a/tests/workspace/Cargo.lock b/tests/workspace/Cargo.lock deleted file mode 100644 index e588f3b7..00000000 --- a/tests/workspace/Cargo.lock +++ /dev/null @@ -1,8 +0,0 @@ -[root] -name = "workspace2" -version = "0.1.0" - -[[package]] -name = "workspace1" -version = "0.1.0" - diff --git a/tests/workspace/workspace2/src/lib.rs b/tests/workspace/workspace2/src/lib.rs index 3c28f108..a25fd117 100644 --- a/tests/workspace/workspace2/src/lib.rs +++ b/tests/workspace/workspace2/src/lib.rs @@ -9,7 +9,7 @@ pub fn f() { // ^ERR mismatched types // ^NOTE expected type `&Trait` // ^NOTE(<1.16.0) found type -// ^HELP(>=1.18.0,<1.24.0-nightly) try with `&x` -// ^HELP(>=1.24.0-nightly) consider borrowing here -// ^HELP(>=1.24.0-nightly) &x +// ^HELP(>=1.18.0,<1.24.0-beta) try with `&x` +// ^HELP(>=1.24.0-beta) consider borrowing here +// ^HELP(>=1.24.0-beta) &x }