Skip to content

Commit

Permalink
fix tmarshalsegfault depending on execution time (#24153)
Browse files Browse the repository at this point in the history
Added in #24119, the test checks if every string produced is equal, but
the value of the strings depend on the `now()` timestamp of when they
were produced. 30 of them are produced in a for loop in sequence with
each other, but the first one is set after the data is marshalled into
and unmarshalled from a file. This means the timestamp strings can
differ depending on the execution time and causes this test to be flaky.
Instead we just make 2 strings from the same data and check if they
equal each other.
  • Loading branch information
metagn authored Sep 22, 2024
1 parent 7da2ffb commit a55c15c
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions tests/stdlib/tmarshalsegfault.nim
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ removeFile("tmarshalsegfault_data")
state.shows.aired[ 0 ] = AiredEpisodeState( airedAt: now(), tvShowId: "1", seasonNumber: 1, number: 1, title: "string" )

# 4. And formatting the airedAt date will now trigger the exception
var s = ""
for ep in state.shows.aired:
let x = $ep.seasonNumber & "x" & $ep.number & " (" & $ep.airedAt & ")"
if s.len == 0: s = x
else: doAssert s == x
let y = $ep.seasonNumber & "x" & $ep.number & " (" & $ep.airedAt & ")"
doAssert x == y

0 comments on commit a55c15c

Please sign in to comment.