Skip to content

Fix config lookup#581

Merged
jeschu1 merged 1 commit into
microsoft:masterfrom
jeschu1:fix
Dec 6, 2018
Merged

Fix config lookup#581
jeschu1 merged 1 commit into
microsoft:masterfrom
jeschu1:fix

Conversation

@jeschu1
Copy link
Copy Markdown
Member

@jeschu1 jeschu1 commented Dec 5, 2018

This is a bad bug caused by yours truly. I'll look at ways to unit/functional test, but in the interim let's fix it.

@jeschu1 jeschu1 requested a review from derrickstolee December 5, 2018 19:27
@sanoursa
Copy link
Copy Markdown
Contributor

sanoursa commented Dec 5, 2018

What are the symptoms of this bug?

@jeschu1
Copy link
Copy Markdown
Member Author

jeschu1 commented Dec 5, 2018

      What are the symptoms of this bug?

No mountId / enlistmentId in telemetry :-(. Very bad!

@sanoursa
Copy link
Copy Markdown
Contributor

sanoursa commented Dec 5, 2018

Got it. I would vote to get the test fixes into this PR. There's no pending release, so this is not an emergency fix.

Comment thread GVFS/GVFS.Common/GVFSEnlistment.cs Outdated
string value;
string error;
if (!configResult.TryParseAsString(out value, out error, defaultValue: string.Empty))
if (configResult.TryParseAsString(out value, out error, defaultValue: string.Empty))
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.

Because the configResult relies on a Git process, this is hard to unit test. Is it possible to mock out GetGitProcess() to inject a custom GitProcess class that returns certain values for GetFromLocalConfig()?

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.

Yes that is the purpose of Enlistment.CreateGitProcess. It is already overridden by MockGVFSEnlistment to return a MockGitProcess.

I'm not sure when GVFSEnlistment.GetGitProcess was added, but it looks like we can probably drop it as a duplicate.

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.

Good point. I didn't see those mocks initially, so I recreated these things to get a proof of concept. @jeschu1 you could take those ideas and do them correctly by using the existing mocks.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks @sanoursa and @derrickstolee !

This was a good opportunity to clean the class up (dropped GetGitProcess) and add tests. The MockGVFSEnlistment works nicely here.

Let me know what you think.

@jeschu1 jeschu1 force-pushed the fix branch 2 times, most recently from a4bbb9a to 9cbe856 Compare December 5, 2018 21:24
Copy link
Copy Markdown
Contributor

@sanoursa sanoursa left a comment

Choose a reason for hiding this comment

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

Looks good overall!

Comment thread GVFS/GVFS.Common/GVFSEnlistment.cs Outdated
[TestFixture]
public class GVFSEnlistmentTests
{
public const string MountId = "85576f54f9ab4388bcdc19b4f6c17696";
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.

Why are these public?

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.

We are very inconsistent here. We have public constants in MoveRenameFileTests but private constants in MoveRenameFileTests_2 and protected constants in GitRepoTests.

It does seem like we use private more often. This could be something to add to the contributor style guide (#537) and to consolidate into a cleanup PR during an expert week. (not in scope for this PR, except to change this variable.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

They shouldn't be private, updated :-).

And yes @derrickstolee we can consider fixing scopes that are wrong across the board, my only concern with those types of changes is how it make the history look.

[TestCase]
public void CanGetMountId()
{
MockGVFSEnlistment enlistment = this.CreateEnlistment();
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.

It's a little bit odd to use a mock object as the object under test. The more pure answer would be to update GVFSEnlistment to take a factory method as an argument, but that is overkill here, and would unnecessarily complicate the product code.

You might consider creating a private class here named TestGVFSEnlistment that derives from GVFSEnlistment and use that instead, so that future enhancements to the common mock object don't interfere with these unit tests.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@sanoursa you're correct here. I created my own TestGVFSEnlistment, so we're protected against future changes to the MockGVFSEnlistment.

@derrickstolee
Copy link
Copy Markdown
Contributor

@jeschu1 I requeued your unit test build because the failure was due to a race condition I wrote. The fix is in #586.

@jeschu1 jeschu1 merged commit ca5afcc into microsoft:master Dec 6, 2018
derrickstolee added a commit that referenced this pull request Dec 6, 2018
I saw [a broken unit test build](https://gvfs.visualstudio.com/ci/_build/results?buildId=4499) in #581, but it wasn't due to a change there. It was due to an incorrect handling of a `null` member in `GitMaintenanceQueue` and how it returned `true` if the blocking collection was `null`. If the timing is just right, that value wasn't `null` and the output was `false`.

Fix this by doing the right thing: return `false` when the collection is `null`, and change the test to expect this.
@jrbriggs jrbriggs added this to the S147 milestone Feb 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants