hawkthorne/hawkthorne-journey — pull request #2053 by AlfonZ42 (2014-03-17 14:36:46+00:00)
Title: Testing maps for referential integrity

Hello.

I have created new test, which tests all reachable levels for referential integrity.
It starts in (hardcoded) `studyroom` and goes through all doors.

Checks performed (explicitly):

*	door points to a valid door in a valid level

Exception: doors can point to no door in other level, as in that case default position is used (position of door `main`); found in:
*	level _womens-bathroom_, door _secret_
*	level _valley_, unnamed door at \[149,0]
*	level _black-caverns-2_, unnamed door at \[133,7]
*	level _black-caverns-2_, door _seabluff_

There are couple of doors pointing to _overworld_ (in _new-abedtown_ and _seabluff_), so there is some special treatment of it (_seabluff_'s removed in #2047).
*	door's property `button` has to be recognized by _inputcontroller_ (currently one of `UP`, `DOWN`, `LEFT`, `RIGHT`, `SELECT`, `START`, `JUMP`, `ATTACK`, `INTERACT`)
*	door's property `sound` has to be `false`/`true` or name of valid sound
*	door's property `key` has to be loadable key, can't test if the key is also placed somewhere in the world, because some keys are loaded dynamically (e.g. white_crystal)
*	level's property `music` has to be name of valid music
*	breakable_block's property `sound` (if set) has to be name of valid sound

Loading a level checks references to other things implicitly, e.g. tilesets images.

Loading all levels significantly increases testing time and memory consumption.

*	before: 0.3s, 2.7MB
*	after: 19s, 119MB

On subsequent runs the time decreases to 10s, caused by OS caching the files, I guess.

Level's field `map` is currently not needed for testing, so it's being set to `nil`, lowering memory consumption to 30MB.

All levels are loaded first, then the checks are performed, so checking of doors doesn't cause multiple loads of the same level(s).
Also, this enables separating different tests (i.e. doors from music and possible future tests).

Another option I see would be to load a level, perform all possible checks immediately (except doors check), store information needed for doors check and load next level in the queue.
This should lower memory consumption even more, at the expense of new data structures.

I have tested it on Windows, hopefully it works on other OSes correctly as well.