HandmadeNetwork / hmn

The handmade website for https://handmade.network/
7 stars 2 forks source link

Fix Logging Race Condition #8

Closed jcalabro closed 1 week ago

jcalabro commented 1 week ago

I noticed this when running the site locally.

I wanted to run the test suite, but that was not working? I'm getting duplicate main() issues under fishbowl-tools, and if I just to go test ./src/..., I get:

--- FAIL: TestRouteCoverage (0.36s)
    coverage_test.go:61: The following url Build functions were not covered by tests:
    coverage_test.go:63: BuildJamGuidelines2024_Learning
    coverage_test.go:63: BuildJamIndex2024_Visibility
    coverage_test.go:63: BuildJamFeed2024_Visibility
    coverage_test.go:63: BuildJamGuidelines2024_Visibility
    coverage_test.go:63: BuildJamIndex2024_WRJ
    coverage_test.go:63: BuildJamFeed2024_WRJ
    coverage_test.go:63: BuildJamGuidelines2024_WRJ
    coverage_test.go:63: BuildJamIndexAny
    coverage_test.go:63: BuildCalendarIndex
    coverage_test.go:63: BuildCalendarICal
    coverage_test.go:63: BuildNewsletterSignup
    coverage_test.go:63: BuildDiscordBotDebugPage
    coverage_test.go:63: BuildFollowingTest
    coverage_test.go:63: BuildFollowUser
    coverage_test.go:63: BuildFollowProject
    coverage_test.go:63: BuildPerfmon
    coverage_test.go:63: BuildEsBuild
FAIL
FAIL    git.handmade.network/hmn/hmn/src/hmnurl/test    0.365s

Is that expected?

bvisness commented 1 week ago

Oh wow, we really need to get tests running in CI so we don't get backlogged like this...and we probably need to make a metaprogramming system to spare us some of the pain of our URL system.

What's happening here is that we have a collection of regexes for routing, and each regex has a corresponding Build function. We have a special coverage test that ensures that all our Build functions are covered, and therefore that we never generate URLs that we can't route. But because the tests currently don't run automatically we just fall behind.

You don't have to worry about that here. Your code looks good. Thanks!