Skip to content

Conversation

@mklement0
Copy link
Contributor

@mklement0 mklement0 commented May 18, 2017

Fix #3706

@msftclas
Copy link

@mklement0,
Thanks for having already signed the Contribution License Agreement. Your agreement was validated by Microsoft. We will now review your pull request.
Thanks,
Microsoft Pull Request Bot

Copy link
Collaborator

@iSazonov iSazonov left a comment

Choose a reason for hiding this comment

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

@mklement0 It seems you don't fix "tail".

/cc @jeffbi Could you please review?

@iSazonov iSazonov requested a review from jeffbi May 18, 2017 11:03
@mklement0
Copy link
Contributor Author

@iSazonov Thanks for catching the -tail issue - oddly, the tests pass on macOS (which is where I ran them before submitting the PR). I'll look into it.

@iSazonov
Copy link
Collaborator

I believe the problem is in platform difference of Newline.

@mirichmo mirichmo self-assigned this May 24, 2017
Copy link
Member

Choose a reason for hiding this comment

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

Can this be converted to use the -TestCase parameter for It? That would make the test much more readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't write these tests (and the only modification I made was to resolve aliases to their full cmdlet names), but I can look into it.

Copy link
Member

Choose a reason for hiding this comment

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

Rather than change it here, I suggest we open a new issue to refactor these test cases to use -TestCase

Copy link
Member

Choose a reason for hiding this comment

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

I filed Issue #3945 to cover this comment.

Copy link
Member

Choose a reason for hiding this comment

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

Any reason to skip on Linux or OSX?

Copy link
Contributor Author

@mklement0 mklement0 May 24, 2017

Choose a reason for hiding this comment

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

Again, I can't speak to these tests, but perhaps BugId(BugDatabase.WindowsOutOfBandReleases, 906022) holds the key?

Separately, if you have any pointers as to why the PR doesn't work on Windows (have yet to dig into it), that would be helpful.

@iSazonov thinks that it may be the difference in newline sequences, though that's not immediately obvious to me.

Copy link
Member

Choose a reason for hiding this comment

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

unfortunately, I don't know if that bug database even exists anymore. that comment is basically worthless now.

@mirichmo
Copy link
Member

mirichmo commented Jun 6, 2017

@adityapatwardhan I don't see any more outstanding comments. Do you have any additional concerns?

@mirichmo
Copy link
Member

mirichmo commented Jun 6, 2017

@mklement0 Please address the failing test:

[-] should Get-Content with a variety of -Tail and -ReadCount values 68ms
Expected: {2}
But was: {3}
at line: 104 in C:\projects\powershell\test\powershell\Modules\Microsoft.PowerShell.Management\Get-Content.Tests.ps1
104: $result.Length | Should Be 2

@mklement0
Copy link
Contributor Author

@mirichmo: I'll take a look soon. In the meantime, if you have a high-level pointer as to how the platform-specific newline sequence might come into play here (it works in the Unix world, but not on Windows), please let me know.

@iSazonov
Copy link
Collaborator

iSazonov commented Aug 24, 2017

@mklement0 Test failed for -Tail parameter. If we use the parameter we call ReadDelimited() twice - (1) to seek start position - backward read, (2) read forward from the start position and parse the file. In the case we can not simply remove the delimiter character from the stream because we use it in SeekItemsBackward() to correct start position. It seems there is still problem places - leave the research to you 😄 Please continue the PR.

Also I see the code is not optimal and we should refactor this in another PR.

@mklement0
Copy link
Contributor Author

Thanks for the tips, @iSazonov.
I hope to get to this soon (I know, deja vu).

@mklement0 mklement0 force-pushed the get-content-delimiter-fix branch from 65c0a5f to 906a276 Compare August 30, 2017 19:40
@mklement0
Copy link
Contributor Author

Note that the only changes to Get-Content.Tests.ps1 since the original commit were whitespace normalization (conversion to all-spaces, though I now realize that there are some inconsistencies).

Thanks to @iSazonov for pointing me to what I hope is the right fix, which turned out to be simple in the end.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Here we evaluate content.ToString() twice - maybe do this one before block.Add().

@iSazonov
Copy link
Collaborator

@mklement0 Could you please split functional and formatting changes to two commits? This will help us avoid error skipping.
Use soft reset, then git add -p.

@mklement0 mklement0 force-pushed the get-content-delimiter-fix branch from 906a276 to c50f3f8 Compare August 31, 2017 18:16
@mklement0
Copy link
Contributor Author

@iSazonov: I've made the changes and split them into 2 commits (functional vs. formatting) that replaced the earlier ones.

I think the Travis CI failure is a transient one, unrelated to my changes (it got stuck while setting up the environment).

Is there a way to re-initiate the test?

@SteveL-MSFT
Copy link
Member

@mklement0 I restarted that job for you

@daxian-dbw daxian-dbw self-assigned this Sep 1, 2017
@iSazonov
Copy link
Collaborator

iSazonov commented Sep 1, 2017

@mklement0 Tip: You can "rename" last commit to restart CI jobs.

@mklement0
Copy link
Contributor Author

Thanks, @iSazonov, but how do you rename a commit? Amend the commit message and push again?

@daxian-dbw
Copy link
Member

Thanks all! Since we got 2 approvals and @iSazonov's comments are also addressed, I will rebase and merge this PR soon (in about one hour). Please let me know if there are any concerns.

@daxian-dbw daxian-dbw added the Breaking-Change breaking change that may affect users label Sep 1, 2017
@daxian-dbw daxian-dbw changed the title Fix for Get-Content -Delimiter including the delimiter in the array … Fix 'Get-Content -Delimiter' to not include the delimiter in the returned lines Sep 1, 2017
@daxian-dbw daxian-dbw merged commit 803395b into PowerShell:master Sep 1, 2017
@mklement0 mklement0 deleted the get-content-delimiter-fix branch September 1, 2017 20:30
@iSazonov
Copy link
Collaborator

iSazonov commented Sep 2, 2017

@mklement0 Yes, you can amend or rebase+reword.

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

Labels

Breaking-Change breaking change that may affect users

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants