Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

--file cannot handle paths with spaces #71

Closed
jnm2 opened this issue Jun 22, 2019 · 12 comments
Closed

--file cannot handle paths with spaces #71

jnm2 opened this issue Jun 22, 2019 · 12 comments
Assignees
Labels
Milestone

Comments

@jnm2
Copy link

jnm2 commented Jun 22, 2019

Using 1.5.0

$testResultsDir = 'artifacts\Test results'

codecov --name $tfm --file "$testResultsDir\coverage.$tfm.xml" --token $env:CODECOV_TOKEN
WRN The file D:\a\1\s\artifacts\Test does not exist.
WRN The file results\coverage.net472.xml does not exist.
FTL No Report detected.

It should respect quotes by using the string[] args that dotnet passes to Program.Main.

With this hypothetical call:

codecov --file "artifacts\Test results\a.xml" "artifacts\Test results\b.xml"

Program.Main will receive this as args:

new[]
{
    "--file",
    "artifacts\Test results\a.xml",
    "artifacts\Test results\b.xml"
}

Given such arguments, the files collection should contain artifacts\Test results\a.xml and artifacts\Test results\b.xml, not artifacts\Test, results\a.xml, artifacts\Test, results\b.xml.

@jnm2
Copy link
Author

jnm2 commented Jun 22, 2019

Workaround:

# Workaround for https://github.com/codecov/codecov-exe/issues/71
$codecovFullPath = Join-Path (Get-Location) $codecov
Push-Location $testResultsDir

& $codecovFullPath --name $tfm --file coverage.$tfm.xml --token $env:CODECOV_TOKEN

# Workaround for https://github.com/codecov/codecov-exe/issues/71
Pop-Location

@AdmiringWorm
Copy link
Collaborator

Unfortunately this is a limitation of the command parsing library being used, and how it has been set up.
CommandLineParser
While I am not 100% sure, I do believe the following needs to be used to get around it:

$testResultsDir = 'artifacts\Test results'

codecov --name $tfm --file "'$testResultsDir\coverage.$tfm.xml'" --token $env:CODECOV_TOKEN

(Notice the single quotes used after and before the double quote).

codecov --file "artifacts\Test results\a.xml" "artifacts\Test results\b.xml"

Passing multiple file paths this way is not supported unfortunately, all paths are expected to be within a singe quote string, using either single or double quotes.

IE:

codecov --file '"artifacts\Test results\a.xml" "artifacts\Test results\b.xml"'

Or

codecov --file "'artifacts\Test results\a.xml' 'artifacts\Test results\b.xml'"

(Again, I am not 100% certain it works with spaces).

If the mentioned ways do not work, then I am afraid that this won't be fixed until v 2.0 of codecov-exe (where I plan a major overhaul of the program, and changing how the arguments get parsed, changing the argument parser, changing the arguments to be similar but not exactly the same as the codecov bash script).

@AdmiringWorm AdmiringWorm added this to the Future milestone Jun 22, 2019
@jnm2
Copy link
Author

jnm2 commented Jun 22, 2019

Thanks.

--file "'$testResultsDir\coverage.$tfm.xml'" has the same result as without the single quotes.

@AdmiringWorm
Copy link
Collaborator

I was almost afraid of that.
Most likely in is the result of the separator used on the argument attribute (https://github.com/codecov/codecov-exe/blob/master/Source/Codecov/Program/CommandLineOptions.cs#L74).

I will investigate and see if this is something we are able to handle with the current library used, and without a breaking change.

@AdmiringWorm AdmiringWorm added Bug and removed Triage labels Jun 22, 2019
@AdmiringWorm
Copy link
Collaborator

Unfortunately I have not been able to figure out how to fix this in a non-breaking way, as such I am afraid that this will not be fixed until the next major version have been released (which I have not yet started working on).

I will add a new section to the readme for Known Issues with a reference to this issue.

@AdmiringWorm AdmiringWorm modified the milestones: Future, 2.0.0 Jun 25, 2019
@jnm2
Copy link
Author

jnm2 commented Jun 25, 2019

Thanks for looking and for the tool! I appreciate both.

@AdmiringWorm
Copy link
Collaborator

Not a problem.

You should actually thank @larzw for the tool. While I am the one maintaining the tool now, he was the one that created it and most of the codebase is his work.

@jnm2
Copy link
Author

jnm2 commented Jun 25, 2019

Thanks @larzw! 😊

Semi-related, have you seen https://github.com/dotnet/command-line-api/wiki/DragonFruit-overview?

@AdmiringWorm
Copy link
Collaborator

No I had not, but I will make a note of it before deciding which parser to change to.

I was actually thinking of changing to Spectre.Cli, which have most of the features I want (and some others in the planning stage).

@AdmiringWorm AdmiringWorm modified the milestones: 2.0.0, 1.11.2 Jun 10, 2020
@AdmiringWorm
Copy link
Collaborator

I have been looking into this issue a little more, and it actually turns out that it isn't a limitation with the commandline parser, but rather something we had done wrong while using it instead.

I have a fix ready, but not sure if I will be pushing it today or not (as I have already pushed 2 versions today, and want to wait a little in case those introduced other issues).

@AdmiringWorm AdmiringWorm self-assigned this Jun 10, 2020
@github-actions
Copy link

🎉 This issue has been resolved in version 1.11.2 🎉

The release is available on:

Your friendly GitReleaseManager bot 📦🚀

@PureKrome
Copy link

Woot cheers!

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

No branches or pull requests

3 participants