ianmiell/shutit — pull request #19 by aidanhs (2014-05-10 02:42:49+00:00)
Title: Modules are now given a shutit object, move some functions into shutit object

All modules need to be updated to be aware they're being passed a shutit object rather than cfg/cfg_dict now. I've done it for everything in the shutit repo, you just need to run this on any shutit modules directories...

grep -rl 'def \(check_ready\|is_installed\|build\|start\|stop\|cleanup\|remove\|test\|finalize\|get_config\)([^,]*,[^,]*):' * | xargs sed -i 's/\(^.*def \(check_ready\|is_installed\|build\|start\|stop\|cleanup\|remove\|test\|finalize\|get_config\)([^,]*,\)\([^,]*\)):/\1shutit):\n\t\t\3 = shutit.cfg/'

I.e. rewrite method definitions in classes to accept a shutit object, then make the first line of the function set the variable they use for cfg in the rest of the method.

Additionally, I've started moving methods into the shutit object, allowing shutit.send_and_expect etc.
The most notable change is making the child param the third param and making it optional (so you can omit it for send_and_expect and add_line_to_file), because setup now initialises a default child to run stuff in.
But it's all backwards compatible, so this can be done incrementally. I've not even updated all the repo modules yet.

I ran a couple of tests given the massive scope of this change and it provisionally seems fine.
Worth reiterating - any shutit modules directories must be updated at the same time.