Skip to content

Return host's file path when using Environment.GetCommandLineArgs()[0] in single-file apps#41019

Merged
mateoatr merged 4 commits into
dotnet:masterfrom
mateoatr:getCommandLineArgs
Aug 21, 2020
Merged

Return host's file path when using Environment.GetCommandLineArgs()[0] in single-file apps#41019
mateoatr merged 4 commits into
dotnet:masterfrom
mateoatr:getCommandLineArgs

Conversation

@mateoatr
Copy link
Copy Markdown
Contributor

Fixes #40874.

@ghost
Copy link
Copy Markdown

ghost commented Aug 19, 2020

Tagging subscribers to this area: @swaroop-sridhar, @agocke
See info in area-owners.md if you want to be subscribed.

@@ -0,0 +1,15 @@
using System;

namespace EnvironmentGetCommandLineArgs
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to have one parametrized test asset for single-file API tests, rather than a different asset for each API. For example, #40974 will need a test for Assembly.CodeBase. We also need to add tests for Assembly.Location, AppContext.BaseDirectory, etc.

But I'm fine if we take this change, and adapt it when we test a second API.

Copy link
Copy Markdown
Member

@vitek-karas vitek-karas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - regarding tests, I'm fine with this for now... I think we should revisit single-file tests after 5 to come up with some good way of doing it.

.Pass()
.And
.HaveStdOutContaining(singleFile);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @mateoatr these tests should be separate facts. Thanks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to have the second test here? Feels a little bit weird to test the behavior of a non single-file app in this file.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that this is not a great factoring. I suggested having the related test here because we have the infrastructure (and we cannot yet test single-file easily from Libraries subset). But its only a suggestion.

However, if we do keep the two versions they should be separate facts, because unit tests should test only one thing. Thanks for making the change.
Thanks for making the change.

@mateoatr mateoatr merged commit 551288f into dotnet:master Aug 21, 2020
@agocke
Copy link
Copy Markdown
Member

agocke commented Aug 26, 2020

/backport to release/5.0

@github-actions
Copy link
Copy Markdown
Contributor

Started backporting to release/5.0: https://github.com/dotnet/runtime/actions/runs/225028145

agocke added a commit that referenced this pull request Aug 26, 2020
[release/5.0] Port API fixes for single file apps

Backport of #41019 and #40974 to release/5.0
@ghost ghost locked as resolved and limited conversation to collaborators Dec 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Environment.GetCommandLineArgs()[0] points to non-existing file in single-file apps

4 participants