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

remotePathResolve not working for every path #366

Open
der-schick96 opened this issue Apr 29, 2022 · 1 comment
Open

remotePathResolve not working for every path #366

der-schick96 opened this issue Apr 29, 2022 · 1 comment

Comments

@der-schick96
Copy link

der-schick96 commented Apr 29, 2022

Describe the bug
The resolveRemotePaths cannot resolve every path correctly.

To Reproduce
Steps to reproduce the behaviour:

  • I have a python application, which generated a corbuleta xml report, which was successfully parsed and imported by the extension
  • The application runs on a docker container, and is copied to an absolute path '/app'
  • I set the 'resolveRemotePath' setting to ['/app', '']
  • I am trying to display the coverage

Expected behaviour
The coverage is rendered.

Outcome
The extensions fails to resolve any path, but does not give a warning or error.

I actually found the cause of the bug. The path is resolved with the following function:

sectionfinder.ts:81

private resolveFileName(fileName: string): string {
        let potentialFileName = fileName;
        const remoteLocalPaths = this.configStore.remotePathResolve;
        if (remoteLocalPaths) {
            const remoteFragment = remoteLocalPaths[0];
            const localFragment = remoteLocalPaths[1];
            const paths = fileName.split(remoteFragment);

            // If we have a length of two we have a match and can swap the paths
            // Note: this is because split will give us an array of two with the first element
            // being an empty string and the second being the project path.
            if (paths.length === 2) {
                potentialFileName = localFragment + paths[1];
            }
        }
        return potentialFileName;
    }

In my case, i had a path /app/src/app/my_module.py which should be resolved to src/app/my_module.py.
With remotePathResolve set to ['/app', ''], the '/app' substring is matched two times by .split, causing the
file name resolution to fail.
I could fix the issue by changing the setting to ' ['/app'/src, 'src']', but i had to go through the source code to figure this one out.

Desktop (please complete the following information):

  • OS: Ubuntu 20.04 64bit
  • Extension Version v2.9.1
  • VSCode Version 1.66.2 x64

Additional context
Add any other context about the problem here.

@der-schick96 der-schick96 changed the title resolveRemotePath not working for every path remotePathResolve not working for every path Apr 29, 2022
@ryanluker
Copy link
Owner

@der-schick96 Thanks for the ticket and the investigation!
Very interesting bug, I agree with your thinking around the issue living in the resolveFileName as well.
I will try to put in some time to make a failing test for this function, that uses the scenario you mentioned above, but in the meantime you can use the workaround you found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants