crashappsec / chalk

Chalk allows you to follow code from development, through builds and into production.
https://crashoverride.com/
GNU General Public License v3.0
322 stars 11 forks source link

test(fd_cache): make tests self-contained, and enable in CI #276

Closed ee7 closed 2 months ago

ee7 commented 2 months ago

Commit 46ffecdfff56 added testament-based unit testing, but didn't migrate the fd_cache tests because they relied on files to be manually created. On main, we would see the error:

$ nim r src/fd_cache.nim
fatal.nim(53)            sysFatal
Error: unhandled exception: fd_cache.nim(272, 11) `one1 != two`  [AssertionDefect]

Make those tests self-contained, and migrate them to the new testament-based system so they now run in CI.

Also prefer doAssert as Nim itself recommends, and use {.all.} to avoid adding the export marker in source files only for testing purposes. From the Nim 1.6.0 release post:

A new import syntax import foo {.all.} now allows importing all symbols (public or private) from foo. This can be useful for testing purposes or for more flexibility in project organization.

Closes: https://github.com/crashappsec/chalk/issues/275