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

Fix docker path #18

Closed
wants to merge 1 commit into from
Closed

Conversation

eerison
Copy link

@eerison eerison commented Nov 14, 2023

Close #11

@eerison
Copy link
Author

eerison commented Nov 14, 2023

Screenshot 2023-11-14 at 16 09 14

I am investigating why test is passing and it is red on the left side (🔴 )

@eerison
Copy link
Author

eerison commented Nov 14, 2023

Hey @olimorris

when I run the tests I can see this error in neotest.log

ERROR | 2023-11-14T17:25:13Z+0100 | ...e/nvim/lazy/neotest-phpunit/lua/neotest-phpunit/init.lua:126 | No test output file found: var/nvim/phpunit.output

do you have any idea why?

Note: this folder is visible into the container and host
Note 2: I guess it is still saving in the old path 🤔
Note 3: this phpunit.output, should it be a file or folder? in theory it should be generated automatically, shouldn't it? if yes it hasn't created 🤔

@olimorris
Copy link
Owner

@eerison thanks for your work on this, looks really promising. Off the top of my head, I have no idea but will see if I can take a look in the coming weeks.

@eerison
Copy link
Author

eerison commented Nov 15, 2023

Ok just a update, the file is created into the folder, then the problem is when it is loaded.

probably it is getting from old path

Note 1: Ok the file is created in container and host, But I saw that output file it is adding full path file="/app/test/...

@eerison
Copy link
Author

eerison commented Nov 15, 2023

Ok just a update, the file is created into the folder, then the problem is when it is loaded.

probably it is getting from old path

Note 1: Ok the file is created in container and host, But I saw that output file it is adding full path file="/app/test/...

well I guess it is the issue, when I run test with relative path it create the output file with full path :'(
infection/infection#1329

@eerison
Copy link
Author

eerison commented Nov 20, 2023

Hey @olimorris do you remember where this icon is handled?

@foobar1643
Copy link

foobar1643 commented Dec 3, 2023

If we're at the point of parsing test results (NeotestAdapter.results function), you can use a regular expression to replace the path prefix:

function escape_pattern(target)
    return target:gsub("(%W)", "%%%1")
end

function NeotestAdapter.results(test, result, tree)
  local output_file = test.context.results_path

  local ok, data = pcall(lib.files.read, output_file)
  if not ok then
    logger.error("No test output file found:", output_file)
    return {}
  end

  data = data:gsub(escape_pattern("/app"),  escape_pattern(local_root_dir))

  local ok, parsed_data = pcall(lib.xml.parse, data)
  ...

This code replaces all occurences of /app (location of the project inside a container) with local_root_dir which is the result of NeotestAdapter.root function.

I made this as a quick-fix solution in my fork of this plugin and it has been working successfully for a couple of months now. There's probably more efficient way around escaping/replacing stuff but I don't have the time to look into it at the moment.

@eerison eerison closed this Mar 22, 2024
@eerison eerison deleted the feature/11-fix-docker-path branch July 1, 2024 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How do I run Test from within Docker?
3 participants