4/20/2026 at 3:50:50 PM
But still a kludge. Better: use something equivalent to Go's testing/synctest[0] package, which lets you write tests that run in a bubble where time is fixed and deterministic.by vocx2tx
4/19/2026 at 7:19:48 PM
by luu
4/20/2026 at 3:50:50 PM
But still a kludge. Better: use something equivalent to Go's testing/synctest[0] package, which lets you write tests that run in a bubble where time is fixed and deterministic.by vocx2tx
4/20/2026 at 3:09:07 PM
Interesting, from the title I thought it was intentional, as a "forced code review." Apparently not, but now I really like that idea!by andai
4/20/2026 at 3:21:12 PM
We've done that at a few places I've been at - it's tricky because if the failure is too short its just annoying toil, but if it's too long there's risk of losing context and having to remember what the heck we were thinking.Overall it's still net positive for me in certain cases of enforcing things to be temporary, or at least revisited.
by adrianpike
4/20/2026 at 2:50:23 PM
Just skimmed the PR, I'm sure the author knows more than I - but why hard code a date at all? Why not do something like `today + 1 year`?by Alupis
4/20/2026 at 3:02:29 PM
That introduces dependency of a clock which might be undesirable, just had a similar problem where i also went for hardcoding for that reason.by johanvts
4/20/2026 at 3:58:08 PM
There's already a clock dependency. The test fails because of that.by cogman10
4/20/2026 at 3:14:21 PM
Arguably you should have a fixed start date for any given test, but time is quite hard to abstract out like that (there's enough time APIs you'd want OS support, but linux for example doesn't support clock namespaces for the realtime clock, only a few monotonic clocks)by rcxdude
4/20/2026 at 3:02:19 PM
Because it should be `today + 1 year + randomInt(1,42) days`.Always include some randomness in test values.
by whynotmaybe
4/20/2026 at 3:25:52 PM
> Always include some randomness in test values.If this isn't a joke, I'd be very interested in the reasoning behind that statement, and whether or not there are some qualifications on when it applies.
by CoastalCoder
4/20/2026 at 3:32:35 PM
Must be some Mandela effect about some TDD documentation I read a long time ago.If you test math_add(1,2) and it returns 3, you don't know if the code does `return 3` or `return x+y`.
It seems I might need to revise my view.
by whynotmaybe
4/20/2026 at 3:59:53 PM
Randomness is useful if you expect your code to do the correct thing with some probability. You test lots of different samples and if they fail more than you expect then you should review the code. You wouldn't test dynamic random samples of add(x, y) because you wouldn't expect it to always return 3, but in this case it wouldn't hurt.by ajs1998
4/20/2026 at 3:57:47 PM
I vaguely remember the same advice, it's pretty old. How you use the randomness is test specific, for example in math_add() it'd be something like: jitter = random(5)
assertEqual(3 + jitter, math_add(1, 2 + jitter))
If it was math_multiply(), then adding the jitter would fail - that would have to be multiplied in.Nowadays I think this would be done with fuzzing/constraint tests, where you define "this relation must hold true" in a more structured way so the framework can choose random values, test more at once, and give better failure messages.
by Izkata
4/20/2026 at 3:10:25 PM
Not a good idea for CI tests. It will just make things flaky and gum up your PR/release process. Randomness or any form of nondeterminism should be in a different set of fuzzing tests (if you must use an RNG, a deterministic one is fine for CI).by rcxdude
4/20/2026 at 3:27:21 PM
That's why it's "randomInt(1,42)", not "randomLong()".by whynotmaybe
4/20/2026 at 3:09:32 PM
Are you joking? This is the kind of thing that leads to flaky tests. I was always counseled against the use of randomness in my tests, unless we're talking generative testing like quickcheck.by devin
4/20/2026 at 3:13:52 PM
`today` is random.by whynotmaybe
4/20/2026 at 3:30:18 PM
It's dynamic, but it certainly isn't random, considering it follows a consistent sequenceby Eldt
4/20/2026 at 3:08:16 PM
Interesting, haven't heard this before (I don't know much about testing). Is this kind of like fuzzing?by andai
4/20/2026 at 3:21:08 PM
I recently had race condition that made tests randomly fail because one test created "data_1" and another test also created "data_1".- Test 1 -> set data_1 with value 1
- Test 1 -> `do some magic`
- Test 1 -> assert value 1 + magic = expected value
- Test 2 -> set data_1 with value 2
But this can fail if `do some magic` is slow and Test 2 starts before Test 1 asserts.
So I can either stop parallelism, but in real life parallelism exists, or ensure that each test as random id, just like it would happen in real life.
by whynotmaybe
4/20/2026 at 1:39:59 PM
Any time constant will be exceeded someday.An impossibly short period of time after the heat death of the universe on a system that shouldn’t even exist: ERROR TIME_TEST FAILURE
by bombcar
4/20/2026 at 1:54:04 PM
Posted on HN in 2126: 100 years ago, someone wrote a test for servo that included an expiry in 2126by unkl_
4/20/2026 at 2:00:42 PM
I've got some tests in active code bases that are using the end of 32-bit Unix time as "we'll never get there". That's not because the devs were lazy, these tests date from when that was the best they could possibly do. They're on track to be cycled out well before then (hopefully this year), so, hopefully, they'll be right that their code "won't get there"... but then there's the testing and code that assumes this that I don't know about that may still be a problem."End of Unix time" is under 12 years now, so, a bit longer than the time frame of this test, but we're coming up on it.
by jerf
4/20/2026 at 3:26:12 PM
I seem to recall much smugness on Slashdot around the "idiot winblows users limited by DOS y2k" and how the time_t was "so much better". Even then a few were prophesying that it would come bite us eventually ...by bombcar
4/20/2026 at 1:58:08 PM
Now I feel bad for using (system foundation timestamp)+100 years as end of "forever" ownership relations in one of my systems. Looking now, it's only 89 years left. I think I should use nulls instead.by yetihehe
4/20/2026 at 1:57:02 PM
Who here remembers the fud of Y2K?by fny
4/20/2026 at 2:13:30 PM
Don't mistake a defused bomb for a dud.by acuozzo
4/20/2026 at 3:25:35 PM
Thanks! I think about this concept a lot, and now I know there's a name for it. "Preparedness paradox". I'll have to remember that.And to your point, Y2K is right there on the wiki page for it.
by arduanika
4/20/2026 at 2:08:21 PM
I remember the reality of all the work needed to avoid issues.by philipallstar
4/20/2026 at 2:35:08 PM
Made me think of Mark Fisher's Y2K Positive text:> At the Great Midnight at the century's end, signifying culture will flip over into a number-based counterculture, retroprocessing the last 100 years. Whether global disaster ensues or not, Y2K is a singularity for cybernetic culture. It's time to get Y2K positive.
Mark Fisher (2004). Y2K Positive in Mute.
by gom_jabbar
4/20/2026 at 2:08:49 PM
While there was a lot of FUD in the media, there were also a lot of scenarios that were actually possible but were averted due to a LOT of work and attention ahead of time. It should be looked at, IMO, as a success of communication, warnings, and a lot of effort that nothing of major significance happened.by LocalPCGuy
4/20/2026 at 2:17:33 PM
Yes, Y2K is a success story, similar to the alert and response related to ozone layer and CFCs.Dissimilar to the global climate catastrophe, unfortunately.
---
The 2024 state of the climate report: Perilous times on planet Earth
https://academic.oup.com/bioscience/article/74/12/812/780859...
"Tragically, we are failing to avoid serious impacts"
"We have now brought the planet into climatic conditions never witnessed by us or our prehistoric relatives within our genus, Homo"
"Despite six IPCC reports, 28 COP meetings, hundreds of other reports, and tens of thousands of scientific papers, the world has made only very minor headway on climate change"
"projections paint a bleak picture of the future, with many scientists envisioning widespread famines, conflicts, mass migration, and increasing extreme weather that will surpass anything witnessed thus far, posing catastrophic consequences for both humanity and the biosphere"
by tejohnso
4/20/2026 at 2:27:05 PM
I don't mean to lessen the impact of that statement. I think climate change is a serious problem. But also most of the geologic time that genus Homo has existed, Earth has been in an ice age. Much of which we'd consider a "snowball Earth". The last warm interglacial period, the Eemian, was 120,000 years ago.by timschmidt
4/20/2026 at 3:19:46 PM
this is the same style comment as "no offense, but <offensive thing>"if you didnt intend to lessen the impact of that statement, why say something that is specifically meant to lessen the impact of the statement? just say what you want to say without the hedging.
by john_strinlai
4/20/2026 at 3:20:37 PM
What you just wrote is the same as: 'the entire lifecycle of humanity has no precursor to the conditions' we are about to face.We aren't facing the ice age that has been the last 120,000 years.
I'm sure the rocky planet will survive just fine, maybe even some extreemophiles, even if we completely screw up the atmosphere. Not 6 billion humans though.
by philipwhiuk
4/20/2026 at 2:57:02 PM
[dead]by yfontana
4/20/2026 at 2:02:47 PM
Exciting times with an anticlimactic end; I was in middle school, relishing the chaos of the adult world.by NetOpWibby
4/20/2026 at 2:13:17 PM
Another victim of the preparedness paradox.by myself248
4/20/2026 at 3:35:10 PM
i had to plant a 10 year time bomb in our SAML SP certificate because AFAIK there is no other way to do it. It’s been 7 years since then. Dreading contacting all the IDPs and getting them to update the SAML config.by samlinnfer
4/19/2026 at 8:54:37 PM
Classic!But before you judge the fix too hashly, I bet it’s just a quick and easy fix that will suffice while a proper fix (to avoid depending on external state) is written.
by db48x
4/20/2026 at 2:43:18 PM
I'll bet you one US Dollar that this is a scenario where the temporary fix becomes the permanent one. (Well, at least, permanent for a hundred years.)Some day, Pham Nuwen is going to be bitching about this test suite between a pair of star systems.
by pavel_lishin
4/20/2026 at 3:49:49 PM
That’s one of my favorite books :)I agree that it’s plausible!
by db48x
4/20/2026 at 2:58:10 PM
of course it is just an easy fix. it's the kind of solution that even someone like me could write who has no understanding of the code a all. (i am not trying to imply that the submitter of the PR doesn't understand the code, just that understanding it is unlikely to be necessary, thus the change bears no risk.but, the solution now hides the problem. if i wanted to get someone to solve the problem i'd set the new date in the near future until someone gets annoyed enough to fix it for real.
and i have to ask, why is this a hardcoded date at all? why not "now plus one week"?
by em-bee
4/20/2026 at 2:49:53 PM
[flagged]by kristofferR
4/20/2026 at 3:28:37 PM
Please don't complain about tangential annoyances—e.g. article or website formats, name collisions, or back-button breakage. They're too common to be interesting.by tomhow
4/20/2026 at 3:11:05 PM
It was started by people who thought Twitter didn't have enough censorship (back when it had a lot more).I guess that's a matter of personal sensibilities, but it's pretty funny to me.
(Note: this is the only fact I know about it, happy to learn more.)
by andai
4/20/2026 at 3:22:15 PM
Any social space will break down upon reaching a critical point in representation of the general populace.I have no idea about the development however.
by rirze
4/20/2026 at 3:39:29 PM
Worked for me.by MBCook