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

Broken tests related to time comparison #238

Closed
brendon opened this issue Nov 15, 2016 · 3 comments
Closed

Broken tests related to time comparison #238

brendon opened this issue Nov 15, 2016 · 3 comments
Assignees

Comments

@brendon
Copy link
Owner

brendon commented Nov 15, 2016

We're getting failures like this:

TouchTest#test_moving_item_to_top_touches_all_other_items [/home/travis/build/swanandp/acts_as_list/test/test_list.rb:723]:
No visible difference in the Time#inspect output.
You should look at the implementation of #== on Time or its members.

I implemented timecop to try and alleviate the occasional failure of tests due to millisecond creep. I know there is a way to build in allowance for the time to change slightly (milliseconds) in the test comparison but would rather not since we shouldn't have to.

Would one of you be able to take a quick look if you've had experience with these kinds of tests before? I've tried everything I can think of to make sure that the times are the same.

@fabn
Copy link
Contributor

fabn commented Nov 15, 2016

Are you able to reproduce the failures locally? I tried but wasn't able to do that. Ideally, as you told these issues are solved using Timecop and/or assert_in_delta but timecop alone should be enough.

It would be interesting to see time differences in failures using Time.now.to_f to make the comparison, and also to put a sleep to see if for some reason timecop is not working.

In this moment I cannot try it because I just upgraded my laptop to OsX Sierra and I'm having some troubles when building native extension. As soon as I fix these issues I'll try to reproduce the issue locally.

@brendon
Copy link
Owner Author

brendon commented Nov 15, 2016

Thanks @fabn, I can't reproduce locally either. Might be something to do with Ubuntu/Linux itself. I tried adding the sleep and the tests still pass locally so I think timecop is working. I like your idea of converting them to floats (or to_i) first.

@brendon
Copy link
Owner Author

brendon commented Nov 26, 2016

Fixed this in #240 and #241. The tests are green on master again :)

@brendon brendon closed this as completed Nov 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants