--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/e78d75b2-7511-4605-bdaf-122214fac38e%40chromium.org.
I recently wrote a unittest that used Time::Now() and it started failing the day after daylights savings time. It assumed the current day would have 24 hours, which in retrospect is clearly not safe. But at the time, I didn't even consider the possibility.
It seems to me like putting Time::Now() in tests is dangerous and should be stopped by a global PRESUBMIT. The disadvantages of Time::Now() that I see in tests are:
- Each test run is slightly different.
- Daylight Savings Time can cause temporary failures.
- Leap Year can cause temporary failures.
If you want your tests and impl to agree on the time, they should be sharing a base::Clock. Or, seemingly more often, use base::TimeTicks instead of base::Time.There's been a thread (Testing base::OneShotTimer / "waiting" in a browser test) and a bug about process wide mocking of base::TimeTicks. But I don't this changes not wanting Time::Now() in tests. And it doesn't sound like there are plans to process wide mock base::Time::Now().Does anyone have concerns about this?Thanks,Sky
--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAHtyhaQZCMe-aWj2tZ81CatD3jQ%3DdbAMNw2VB_H5STCV%3DbO%2B2A%40mail.gmail.com.
~/chromium/src$ git grep -P '(Time|TimeTicks|ThreadTicks)::Now' | wc -l
7628
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/aa1eb417-dcc9-4606-b063-d258675de547%40chromium.org.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CA%2BN%2BEKYbmv%2Bxj9T1rRLqHrv3p%2BKxeC8%2B-Bx9m%2BO7QZR%2BUqXp%2BQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/34b0aa61-9c97-4f74-b04e-8e13f653d82c%40chromium.org.