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 infinite loop on redirect to file #184

Closed
wants to merge 5 commits into from

Conversation

Projects
None yet
4 participants
@mrkane27
Copy link

commented Jan 7, 2016

@dnfclas

This comment has been minimized.

Copy link

commented Jan 7, 2016

Hi @mrkane27, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution!

This seems like a small (but important) contribution, so no Contribution License Agreement is required at this point. Real humans will now evaluate your PR.

TTYL, DNFBOT;

@yishaigalatzer yishaigalatzer changed the title [1893] fix infinite loop on redirect to file fix infinite loop on redirect to file Jan 7, 2016

@yishaigalatzer

This comment has been minimized.

Copy link
Contributor

commented Jan 7, 2016

Sorry - Commented on the issue instead of the PR.

Thanks for this cool fix. We would love to take it after adding a failing test in the current code, that gets fixed by this change.

@mrkane27

This comment has been minimized.

Copy link
Author

commented Jan 7, 2016

Thanks for replying!

As far as I can tell, the issue only happens on Linux and Mac, using Mono.
Do you run tests on any of those? If yes, could you point me to where I should add a test? -- I've never contributed to this repository before.

@yishaigalatzer

This comment has been minimized.

Copy link
Contributor

commented Jan 7, 2016

Ah - Cool.

We are not yet running tests on mac and linux regularly (but in fact that is what half the team is doing this week, making it all happen for core clr).

Lets do this for now

  1. Add a comment that this only happens on mono
  2. We will try that with the new nuget.commandline.xplat package (to make sure it doesn't repeat there)
  3. Add a follow up test, once we have the linux tests passing properly (we are still tracking a few tens of test failures)
[Fact]
public void TestConsoleWindowWidthNotZero()
{
Assert.NotEqual(0, new NuGet.Common.Console().WindowWidth);

This comment has been minimized.

Copy link
@mrkane27

mrkane27 Jan 8, 2016

Author

This test will only be relevant if someone runs the tests on Linux, with output redirect. I tried messing around with System.Console.SetOut() and the like at runtime, but Mono does some initialization before that, so it won't apply.

@mrkane27

This comment has been minimized.

Copy link
Author

commented Jan 8, 2016

A different take might be to use System.Console.IsOutputRedirected and default to e.g. a width of 80, which would make sense for file output -- but that might be overkill for this fix.

@yishaigalatzer

This comment has been minimized.

Copy link
Contributor

commented Jan 8, 2016

I like this new idea better. Lets update to it or does not sound like an overkill.

We are running tests on Linux on a CI regularly starting from this week.

@mrkane27

This comment has been minimized.

Copy link
Author

commented Jan 8, 2016

I thought about this for a bit more, and it might not actually work. For example, if you do nuget ... | cat, you might still want it formatted for the terminal. I don't think there's a reliable way to determine whether the final output is into a file. What do you think?

I've also run some tests on how Console behaves on .NET and Mono, if you want to take a look.

@yishaigalatzer

This comment has been minimized.

Copy link
Contributor

commented Jan 8, 2016

I think the key is to unblock the hang. In general we are moving NuGet off mono and moving it gradually to coreCLR on unix (see nuget.commandline.xplat package), so coming up with something reasonable (like your suggestion of 80 chars) might be good enough. And then on coreCLR we can try to get things fixed.

@mrkane27

This comment has been minimized.

Copy link
Author

commented Jan 18, 2016

Is this current state what you had in mind?

@deepakaravindr deepakaravindr self-assigned this Feb 5, 2016

@deepakaravindr

This comment has been minimized.

Copy link
Member

commented Feb 5, 2016

@mrkane27, Thanks for the tests on how Console behaves on .NET and Mono. I have checked it out. Your fix looks good to me too. I have merged it with 6afc0ac

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.