Hands-on Rust: How is output_harness supposed to be used?

Title: Hands-On Rust (Chapter 11 : Test Harnesses)

I understand the point of the test harness, but the aside left me scratching my head as to how to use it. I looked at the downloaded source and it appears that this is an independent Rust project. Is that correct? If so, does that mean we would be replicating the source files across two different projects (I know, cut/paste…simple).

At any rate, either I’m a bit dense, or it could use a bit more explanation as to how to leverage the harness.

1 Like

I did a cargo run in that directory. That “works”, but I’m not sure that was the intention. Had to play around a minute to see that I needed to hit “Enter” to continue etc.

1 Like

Hmmm… noticed the Architect constructors in the out_harness directory.

Kind of looks like some of the things I’m tripping over are possibly due to inconsistencies in keeping the files synced up(???)

example:
drunkards.rs in the output_harness uses self.map.tiles.iter() for instance, while drunkards in the drunkard dir uses mb.map.tiles.iter() (since it doesn’t have a map in the DrunkardsWalkArchitect anymore.)

1 Like

Thanks! I’ve filed the architect constructors under a separate issue in the book bug tracker, that one seems to be me forgetting to merge some code. I’ll make sure that’s in there.

I agree that the harness could use a better introduction. The intent is to show how useful it can be to write code against a separate tool that shows how algorithms work before moving the code into a useful build. I think I got part way there, but didn’t really manage to show the working as well as I should have. I’ll see if I can rework that a bit for a smoother reader experience.

(As an aside, I highly recommend making little test harness programs when you try something new. It really helps to distill what’s important and makes testing a lot easier)

1 Like