rcasia / neotest-java

Neotest adapter for Java.
MIT License
38 stars 21 forks source link

Tests fail to run with fish shell #96

Closed ColdMacaroni closed 4 months ago

ColdMacaroni commented 5 months ago

When I try to run a test the command fails to execute. This is because fish doesn't support {} blocks (used here).

I've gotten it to work by wrapping the command in a call to bash. (I need to enable globstar otherwise it fails to find my files)

diff --git a/lua/neotest-java/core/spec_builder.lua b/lua/neotest-java/core/spec_builder.lua
index 6fd8222..639ee47 100644
--- a/lua/neotest-java/core/spec_builder.lua
+++ b/lua/neotest-java/core/spec_builder.lua
@@ -26,7 +26,7 @@ function SpecBuilder.build_spec(args, project_type, ignore_wrapper, config)
        end

        return {
-           command = command:build(),
+           command = { "bash", "-O", "globstar", "-c", command:build() },
            cwd = root,
            symbol = position.name,
            context = { report_file = reports_dir .. "/TEST-junit-jupiter.xml" },
@@ -42,7 +42,7 @@ function SpecBuilder.build_spec(args, project_type, ignore_wrapper, config)
    command:test_reference(resolve_qualfied_name(absolute_path), position.name, "file")

    return {
-       command = command:build(),
+       command = { "bash", "-O", "globstar", "-c", command:build() },
        cwd = root,
        symbol = position.name,
        context = { report_file = reports_dir .. "/TEST-junit-jupiter.xml" },

I was thinking of making a PR, but I'm not sure of what the best way of writing the bash wrapper is

rcasia commented 4 months ago

Hey @ColdMacaroni, apologies for the delay.

I merged a fix, let me know if any issue arise.