Homunculus Devlog 2018-04-14

Tags:
By Max Woerner Chase

In this post:


I'm trying to develop a game, actually finish a project. While a roguelike may not be, like, the best genre for "I'm going finally ship a game", I think it's going well so far, sort of.

The tutorial (GitHub link because the main site has been coughing up gateway errors for a while now) I'm using is, I think, better about code style than the version it's updated from, but it's still not up to my usual standards in some respects. The key issue is the lack of tests. No tests, no protection against bugs. Which is pretty fucking wild for a tutorial series that has you hand-applying diffs. I have architectural and stylistic niggles, but I'd rather actually execute what I have in mind, than pontificate about it. Which needs tests, so I don't break everything.

Let's get tests set up. Well, I don't remember exactly what I have, so let's start with just invoking the test runner.

Huh.

The MANIFEST.in was all kinds of messed up.

I guess that's what happens if you only ever run in editable mode. Anyway, it ran, and everything is on fire. Step one is to add a test. I usually have a "test that it's actually importable" test. To my mind, having broken imports should blow up when you run the tests, not when you're doing test discovery. So there should be no top-level imports from the module under test, in the test code. Anyway, it's at 1% coverage currently. Let's see, what are quick hits... The constants file looks like a good bet. With that, and some other low-hanging fruit, I'm at 5% coverage. I think at this point, I should just add an import test for every module and see what I can soak up like that. And when I do that, it gets up to 29%.

Okay, I pushed through some slightly less low-hanging fruit, and got to 31%. There's some other stuff that I could write tests for, but the big annoying bit of this is the "main" module, which accounts for fully one fourth of the missing coverage.

I can render code testable by isolating the tdl calls, and isolating everything else into its own function. For now, though, I'm just going to finish up this blog post.


Next week, I'm going to focus on lowering the cyclomatic complexity of the game loop. I usually think focusing on cyclomatic complexity is kind of silly, but this monstrosity has to go down.