Commit 0c80f99
committed
test(windows): redirect now/nowTime to time.Now() in tests
On Windows, var now points to GetSystemTimePreciseAsFileTime() via a
direct Windows syscall. This syscall bypasses testing/synctest's fake
clock, which only intercepts time.Now(). As a result, synctest-wrapped
tests fail on Windows: span durations read the real wall clock (a few
µs) instead of the fake 2 ms advance, and span-age strings diverge
between the test and the code under test.
Add an init() in time_windows_test.go that overrides now and nowTime to
call time.Now() for the test binary. Production code keeps its
high-precision syscall; tests gain fake-clock compatibility without any
change to production behavior.
Signed-off-by: Kemal Akkoyun <kemal.akkoyun@datadoghq.com>1 parent ee27909 commit 0c80f99
1 file changed
+11
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
14 | 25 | | |
15 | 26 | | |
16 | 27 | | |
| |||
0 commit comments