Giter VIP home page Giter VIP logo

neotest-zig's Introduction

Hi there ๐Ÿ‘‹

lawrence-laz's GitHub stats

neotest-zig's People

Contributors

freakmangd avatar lawrence-laz avatar ratakor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

neotest-zig's Issues

docs: Demo video is not playing in Firefox or in Quick-time when downloaded

Describe the bug

The video in the README (
https://github.com/lawrence-laz/neotest-zig/assets/8823448/2e959ca5-db2a-4eee-a422-48c11e853595) is not playable.

Steps To Reproduce

  1. Open firefox and navigate to the README, or download the file

Current behavior

The video does not play unless I am using Chrome.

Expected behavior

The video should play in all browsers, or when downloaded.

Screenshots

Screenshot 2023-12-10 at 18 51 45

Additional context

We may want to look at another format.

Note: this is a docs-only issue.

Hang on non-zig repo

Describe the bug

Inside a repository containing no zig file (and there are no zig files in any of its parent directories either), invoking neotest.run.run() hangs forever.

Steps To Reproduce

Minimal setup:

require('neotest').setup {
  adapters = {
    require('neotest-go'),
    require('neotest-zig'),
  },
}

Current behavior

neotest hangs on Parsing tests step. There is no log when debug logging is enabled. This seems to be caused by this line here

M.root = lib.files.match_root_pattern("**/*.zig")

I changed the match pattern to just *.zig, and everything seems fine. It might hang because of the recursive searching inside each parent directory.

Expected behavior

neotest-zig shouldn't block other adapters from running.

Environment

  • OS: AlpineLinux
  • Zig version: 0.11.0
  • Nvim version: 0.9.4
  • Neotest version: main
  • Neotest Zig version: main

Debug test support

Neotest supports DAP debugging for tests.
Need to set it up either with lldb or gdb, depending on what's available.

No tests found when using neotest.run.run()

Describe the bug
Running lua require("neotest").run.run() gives the output No tests found.
Running lua require("neotest").run.run(vim.fn.expand("%")) results in a forever pending result (see screenshot)

Expected behavior

A report of how many tests passed/failed

Screenshots

image

Environment

  • OS: Windows x64
  • Zig version: 0.12.0-dev.696+9a001e1f7
  • Nvim version: NVIM v0.9.1
  • Neotest version: latest
  • Neotest Zig version: latest

Additional context

The file was called main.zig and it was the only file in the folder

Installation using packer.nvim:

    use {
        "nvim-neotest/neotest",
        requires = {
            "lawrence-laz/neotest-zig",
            "nvim-lua/plenary.nvim",
            "nvim-treesitter/nvim-treesitter",
            "antoinemadec/FixCursorHold.nvim"
        },
        config = function()
            require("neotest").setup({
                adapters = {
                    require("neotest-zig"), -- Registration
                }
            })
        end
    }

The config option actually didnt seem to work so i made a file called /after/plugin/neotest.lua and put this in it:

local nt = require("neotest")

nt.setup({
    adapters = {
        require("neotest-zig"), -- Registration
    }
})

which actually runs

My :TSConfigInfo command gives this under ensure_installed: { "c", "lua", "vim", "query", "javascript", "rust", "zig", "cpp" }

Support tests that depend on modules

The adapter can now run single test files, but if they have dependencies on other modules, the tests will never pass.
An example can be found in nested container tests from zig docs.

Ideally the user should not have to do anything else, and the tests should import required modules.

image

Neotest-zig adapter is used for non-zig repos, resulting in unexpected 'No tests found'

Describe the bug

When neotest-zig adapter is enabled, alongside another plugin, such as neotest-go, it's can get selected incorrectly if it's the earlier adapter that is being tested first.

I believe the adapter selection may happen due to the root definition at

Neotest returns the root if any of the matches are found (source). And, since .git is a directory that will exist in any git repo, it always matches, which is incorrect.

As far as I understand, neotest should run for .zig files even if they aren't detected in a project. So if the root dir does not have any .zig files, then the root dir will not be detected as a zig project, but zig tests can still run in individual files (see docs)

Steps To Reproduce

  1. Enable two adapters, one of which is zig.
  2. Start vim and run neotest
  3. Receive "No tests found"

Current behavior

Using the zig adapter alongside another neotest adapter takes away the ability to use the other adapter.

Expected behavior

One should be able to use neotest-zig alongside any neotest-* adapter without this unexpected side effect.

Logs

No neotest-zig logs should actually be emitted for this issue, so I didn't bother enabling logging and running those. But, here's the relevant neotest.log excerpt from when neotest ran in a Go test module:

Details

INFO | 2024-04-02T16:00:14Z+0100 | ...ocal/share/nvim/lazy/neotest/lua/neotest/client/init.lua:380 | Initialising client
INFO | 2024-04-02T16:00:14Z+0100 | ...are/nvim/lazy/neotest/lua/neotest/client/events/init.lua:48 | Emitting starting event
DEBUG | 2024-04-02T16:00:14Z+0100 | ...are/nvim/lazy/neotest/lua/neotest/client/events/init.lua:50 | Calling listener summary for event starting
INFO | 2024-04-02T16:00:14Z+0100 | ...al/share/nvim/lazy/neotest/lua/neotest/adapters/init.lua:18 | Found 1 adapters for directory /home/asfaltboy/Code/learning/gophercises/ex-01-quiz
DEBUG | 2024-04-02T16:00:14Z+0100 | ...al/share/nvim/lazy/neotest/lua/neotest/adapters/init.lua:19 | Adapters: { {
    adapter = {
      _debug_log_path = "/home/asfaltboy/.local/share/nvim/neotest-zig.log",
      _does_file_contain_tests = <function 1>,
      _enable_debug_log = <function 2>,
      _is_debug_log_enabled = false,
      _test_treesitter_query = "\t;;query\n\t(TestDecl\n\t\t[(IDENTIFIER) (STRINGLITERALSINGLE)] @test.name\n\t) @test.definition\n",
      build_spec = <function 3>,
      discover_positions = <function 4>,
      get_strategy_config = <function 5>,
      get_test_node_by_runspec = <function 6>,
      is_test_file = <function 7>,
      name = "neotest-zig",
      results = <function 8>,
      root = <function 9>,
      setup = <function 10>,
      version = "v1.0.5",
      <metatable> = {
        __call = <function 11>
      }
    },
    root = "/home/asfaltboy/Code/learning/gophercises/ex-01-quiz"
  } }

Environment

  • OS: ArchLinux
  • Zig version: 0.11.0
  • Nvim version: 0.9.5
  • Neotest version: 5.0.1
  • Neotest Zig version: 742f97f

Support for decl tests and unnamed tests

test "add" works, but the other two tests don't.

fn add(a: anytype, b: anytype) @TypeOf(a, b) {
    return a + b;
}

test "add" {
    try std.testing.expectEqual(3, add(1, 2));
}

test add {
    try std.testing.expectEqual(3, add(1, 2));
}

test {
    try std.testing.expectEqual(3, add(1, 2));
}

We can get test add working just by changing this line:

@@ -61,7 +61,7 @@ function M.discover_positions(path)
        local query = [[
                ;;query
                (TestDecl
-                       (STRINGLITERALSINGLE) @test.name
+                       [(IDENTIFIER) (STRINGLITERALSINGLE)] @test.name
                ) @test.definition
        ]]
        log.debug("Running query", query)

I couldn't figure out a way to capture unnamed tests, but that's mainly because I'm unfamiliar with the system, I'm sure its doable.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.