Skip to content

Conversation

@powercode
Copy link
Collaborator

@powercode powercode commented Oct 24, 2017

Fixes #4181
Adding a property Duration to HistoryInfo to end the {$_.EndExecutionTime - $_.StartExecutionTime} madness :)


This change is Reviewable

Copy link
Collaborator

@vors vors left a comment

Choose a reason for hiding this comment

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

sweet! any tests?

@iSazonov iSazonov self-assigned this Oct 25, 2017
@powercode
Copy link
Collaborator Author

Not really sure what to test. Testing

public TimeSpan Duration => EndExecutionTime - StartExecutionTime; 

will hardly give a lot.
But maybe a test that the formatting view is in place?

@vors
Copy link
Collaborator

vors commented Oct 28, 2017

Not really sure what to test

GetExecutionTimeString seems like a good candidate for unit tests

@iSazonov
Copy link
Collaborator

iSazonov commented Nov 8, 2017

@powercode Please resolve merge conflicts.

@powercode
Copy link
Collaborator Author

@vors You were so right. Added tests and fixed bugs

Copy link
Collaborator

@vors vors left a comment

Choose a reason for hiding this comment

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

Looks solid, but not a big fan of reflection in the tests. This is very fragile.
I guess it should not be a blocker, but maybe we can just do some unit testing from C#? Don't we have such tests?

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.

Leave a comment

Copy link
Collaborator

Choose a reason for hiding this comment

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

@SteveL-MSFT @PaulHigin Does this not break remoting?

Copy link
Member

Choose a reason for hiding this comment

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

There's a specific list of types and HistoryInfo isn't in that list

Copy link
Collaborator

Choose a reason for hiding this comment

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

These tests are very similar. Please use -TestCases.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good point

@powercode powercode changed the title Add ExecutionTime property to HistoryInfo Add Duration property to HistoryInfo Nov 9, 2017
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor comment - should we follow ToString() and use ToDurationString() for public?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, or Tostring(string). Thought about that a bit also, but never reach any real conclusion.

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.

Leave a comment

Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we remove the test?

Copy link
Collaborator

Choose a reason for hiding this comment

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

TimeSeparator can be culture sensitive. Could you please use TimeSpan constructor for duration?

Also in C# $@"{duration:d\.hh\:mm\:ss}"; should we be culture sensitive too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@iSazonov Excellent catch!
I will fix!

Copy link
Collaborator

@iSazonov iSazonov Jan 25, 2018

Choose a reason for hiding this comment

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

We keep the implementation as it is.
Closed.

@SteveL-MSFT
Copy link
Member

We're not holding the RC for this PR, if it makes it in soon, great! If not, it'll catch the next release.

@mi-hol
Copy link

mi-hol commented Dec 14, 2017

@SteveL-MSFT will it merge this time?

@SteveL-MSFT
Copy link
Member

@mi-hol if the maintainer @iSazonov believes there has been sufficient review, he can merge this, but we're limiting code changes we're taking for GA to avoid risk of regression. This will show up in 6.1.0 preview release which should happen early next year.

@SteveL-MSFT SteveL-MSFT removed this from the 6.0.0-NiceToHave milestone Dec 15, 2017
@iSazonov
Copy link
Collaborator

We have only one open comment about TimeSeparator.
I don't see any reason why we won't get it in 6.1.0.

@powercode
Copy link
Collaborator Author

I have looked a bit on how PowerShell treats timespans in other cases, and it seems to use the default formatting, which is not culture sensitive.
I think we should stick with consistency here, and keep the implementation as it is.

@iSazonov
Copy link
Collaborator

@powercode please resolve conflicts.

@iSazonov
Copy link
Collaborator

@SteveL-MSFT @daxian-dbw Have you any thoughts about the PR?

SteveL-MSFT
SteveL-MSFT previously approved these changes Feb 22, 2018
Copy link
Member

@SteveL-MSFT SteveL-MSFT left a comment

Choose a reason for hiding this comment

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

Regarding GetDurationString() vs ToDurationString(), looking in PS code, it seems Get*String() is used (although internal methods). I'm fine keeping GetDurationString() unless someone can point to some guidance otherwise.

@iSazonov
Copy link
Collaborator

iSazonov commented Feb 24, 2018

@TravisEz13 @daxian-dbw Have you any thoughts about GetDurationString() vs ToDurationString()?

@powercode powercode changed the title WIP: Add Duration property to HistoryInfo Add Duration property to HistoryInfo Jun 19, 2018
@powercode
Copy link
Collaborator Author

These build errors are not related to my changes.

Can anyone restart the build here?

@iSazonov iSazonov closed this Jul 4, 2018
@iSazonov iSazonov reopened this Jul 4, 2018
@iSazonov
Copy link
Collaborator

iSazonov commented Jul 4, 2018

Reopen the PR to restart CIs.

@TravisEz13 TravisEz13 dismissed SteveL-MSFT’s stale review July 6, 2018 00:41

Changes were recommended after approval

@iSazonov
Copy link
Collaborator

@powercode Is the PR ready for review?

@powercode
Copy link
Collaborator Author

Yes

@iSazonov
Copy link
Collaborator

@daxian-dbw @SteveL-MSFT @BrucePay Please review the PR.

Copy link
Member

@TravisEz13 TravisEz13 left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r4, 1 of 2 files at r5.
Reviewable status: :shipit: complete! all files reviewed

}

It "HistoryInfo calculates Duration" {
$ctor = [Microsoft.PowerShell.Commands.HistoryInfo].GetConstructors([Reflection.BindingFlags]::NonPublic -bor [Reflection.BindingFlags]::Instance).Where{$_.GetParameters().Length -eq 5}
Copy link
Member

Choose a reason for hiding this comment

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

Seems like this test should just get the first item from item from Get-History and validate that Duration = End - Start?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@SteveL-MSFT Am I guaranteed to have something in the history at that moment?

Copy link
Member

Choose a reason for hiding this comment

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

@powercode I think it's ok to use Add-History

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Member

@SteveL-MSFT SteveL-MSFT left a comment

Choose a reason for hiding this comment

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

LGTM

}
$history | Add-History
$h = Get-History -count 1
$h.Duration | Should Be $duration
Copy link
Collaborator

Choose a reason for hiding this comment

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

@powercode Sorry I lost the PR. Please fix Be -> -Be and we ready to merge.

@iSazonov iSazonov merged commit 1bfe96d into PowerShell:master Aug 28, 2018
@iSazonov
Copy link
Collaborator

@powercode Thank you for the contribution! Sorry for delay.

@TravisEz13 TravisEz13 added this to the v6.1.0 milestone Aug 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Committee-Reviewed PS-Committee has reviewed this and made a decision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants