Skip to content
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

Regression: Neotest adapter diagnostics started including color codes in the test failure output #609

Closed
7 of 9 tasks
ketchupfriend opened this issue Dec 8, 2024 · 2 comments · Fixed by #610
Closed
7 of 9 tasks
Labels
bug Something isn't working

Comments

@ketchupfriend
Copy link

Have you read the docs and searched existing issues?

Neovim version (nvim -v)

v0.10.2

Operating system/version

macOS

Output of :checkhealth rustaceanvim

==============================================================================
rustaceanvim: require("rustaceanvim.health").check()

Checking for Lua dependencies ~
- WARNING dap not installed. Needed for debugging features [mfussenegger/nvim-dap](https://github.com/mfussenegger/nvim-dap)

Checking external dependencies ~
- OK rust-analyzer: found rust-analyzer 1.83.0 (90b35a62 2024-11-26)
- OK Cargo: found cargo 1.83.0
- OK rustc: found rustc 1.83.0 (90b35a623 2024-11-26) (Homebrew)

Checking config ~
- OK No errors found in config.

Checking for conflicting plugins ~
- OK No conflicting plugins detected.

Checking for tree-sitter parser ~
- WARNING No tree-sitter parser for Rust detected. Required by 'Rustc unpretty' command.
- OK .vscode/settings.json loaded without errors.

How to reproduce the issue

I have provided minimal_init.lua and main.rs in the minimal config section, but just want to note there is really nothing special about the setup. On my personal config on any Rust project, I was able to observe the problem.

nvim -u minimal_init.lua main.rs
:Neotest run

Expected behaviour

Plain diagnostic message should be output:
image

Diagnostics:
1. assertion `left == right` failed
     left: 1
    right: 2
   note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This is the behaviour with commit = "8ece53be36515cb9e76f3d03511643636469502d",.

Actual behaviour

Behaviour has regressed from an earlier version of rustaceanvim. Color code is included in the diagnostic message, which makes it hard to read:
image

Diagnostics:
1. �[31;1massertion `left == right` failed�[0m
     left: 1
    right: 2
   note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
   �[0m
   
�[2K------------
...

I believe this is a regression in rustaceanvim because reverting to 8ece53be36515cb9e76f3d03511643636469502d restores the clean output.

The minimal config used to reproduce this issue.

# The minimal_init.lua
vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
    spec = {
        {
            'mrcjkb/rustaceanvim',
            version = '^5', -- Recommended
            lazy = false, -- This plugin is already lazy
        },

        {
            "nvim-neotest/neotest",
            dependencies = {
                "nvim-neotest/nvim-nio",
                "nvim-lua/plenary.nvim",
                "antoinemadec/FixCursorHold.nvim",
                "nvim-treesitter/nvim-treesitter"
            },
            keys = {
                {
                    " tts",
                    function()
                        require("neotest").summary.toggle()
                    end,
                    desc = "[t]oggle [t]est [s]ummary",
                },
            },
        },
    },
})

require("neotest").setup({
    adapters = {
        require("rustaceanvim.neotest"),
    },
})


# main.rs
fn main() {
    println!("Hello, world!");
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn always_fails() {
        assert_eq!(1, 2);
    }
}
@ketchupfriend ketchupfriend added the bug Something isn't working label Dec 8, 2024
@mrcjkb
Copy link
Owner

mrcjkb commented Dec 8, 2024

Hey 👋

I cannot reproduce this (neither with my config nor with the minimal config you posted).
There also haven't been any changes related to neotest since the commit you are referencing (which points to the 5.14.1 release).

Rustaceanvim passes --color=never when using Cargo.
I can reproduce the behaviour with cargo-nextest, so perhaps a recent change to cargo-nextest is the cause.
Are you using cargo-nextest by any chance?

@ketchupfriend
Copy link
Author

I didn't configure nextest manually, but I dumped the args that rustaceanvim is using and it seems like it's deferring to nextest since I have it installed. This is on 5.18.0 that you just released (and it fixes the issue):

15:07:21 msg_show.echo ARGS
15:07:21 msg_show { "nextest", "--color", "never", "run", "--no-fail-fast", "--package", "sample", "--bin", "sample", "--", "tests" }

I think this is the default behaviour btw according to the docs:

        {enable_nextest?}                    (boolean)
                                                                                                               Whether to enable nextest. If enabled, `cargo test` commands will be transformed to `cargo nextest run` commands.
                                                                                                               Defaults to `true` if cargo-nextest is detected. Ignored if `cargo_override` is set.

I wonder if it might be helpful to have the resolved cargo test command in the checkhealth for the plugin, to help in future debugging?

Appreciate the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants