Skip to content

Refactor the Reflog entries datetime comparisons #999

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

Merged
merged 1 commit into from
Jun 10, 2015
Merged

Conversation

nulltoken
Copy link
Member

We actually rely on Assert.InRange for this and usually ensure the entry has been created within the range of [DateTimeOffset.Now - 5 seconds, DateTimeOffset.Now].

A better alternative (courtesy of @jamill), would be to retrieve the DateTimeOffset.Now before the action generating the reflog entry and ensuring the logged datetime uses this as the lower bound (ie. recordedOffset, DateTimeOffset.Now]).

@nulltoken
Copy link
Member Author

Definitely 👍

I've been seeing such test failures in the past and it happened again with @sitereactor's latest build.

@nulltoken
Copy link
Member Author

This little bugger failed one too many builds. Throwing some code at it.

@nulltoken
Copy link
Member Author

@dahlbyk @jamill Ready for review

{
public static DateTimeOffset TruncateMilliseconds(this DateTimeOffset dto)
{
// From http://stackoverflow.com/a/1005222/335418
Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

/cc @ethomson

@dahlbyk
Copy link
Member

dahlbyk commented Jun 10, 2015

👍

@dahlbyk
Copy link
Member

dahlbyk commented Jun 10, 2015

I almost wonder if we should capture before in a BaseFixture field. Not sure the slightly better accuracy of inline initialization is worth the extra noise in the tests.

@nulltoken
Copy link
Member Author

@dahlbyk I thought about that, but there are tests that actually perform multiple operations, each of them generating a reflog entry, with a potential different lower boundary. For this kind of cases, we'd need some kind of call to reinitialize what before would contain.

We may end up with some tests having no time related variables at all, magically asserting durations and some others with a strange call to ReinitHiddenTimer() that might be difficult to understand to the reader.

I agree that this adds a ton of noise, but my main goal for this PR was to avoid restarting failed builds because of the way it was previously implemented.

Long story short, I'm very far from being against this proposal, but I'm miserably falling short at imagining a code piece that would make sense. Any ideas?

/cc @jamill

@dahlbyk
Copy link
Member

dahlbyk commented Jun 10, 2015

A small objection, let's :shipit: and revisit if we find the noise unbearable?

nulltoken added a commit that referenced this pull request Jun 10, 2015
Refactor the Reflog entries datetime comparisons
@nulltoken nulltoken merged commit 8008e2d into vNext Jun 10, 2015
@nulltoken nulltoken deleted the ntk/inrange branch June 10, 2015 19:03
@nulltoken
Copy link
Member Author

:shipit:'d!

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.

2 participants