From: Edward G. <edw...@ra...> - 2009-06-29 15:52:13
|
On Sat, 2009-06-27 at 13:59 -0500, Garrett Smith wrote: > I'm working on an app that uses various appmods. I'm wondering what the > typical developer workflow for this type of development is. > Do folks typically do this the > long/obvious way (e.g. run make:all()/make + restart yaws) or are > there some common shortcuts? Typically (at least for me) the game is getting a specific test to pass, so I'm usually only interested to compile and load a couple of modules before running my test: 1> c(foo). ok 2> c(foo_test). ok 3> foo_test:current_test(). The c() built-in compiles, purges and loads the module it's passed so there's no need to additionally `l(foo)'. And like Steve mentioned, the above can execute in an erlang shell that started yaws in interactive mode so yaws reloads the changes. It can get tiring to keep re-typing c(foo) and c(foo_test) and c(whatever_else) and foo_test:current_test() so I often use a wrapper: 3> F = fun() -> c(foo), c(foo_test), foo_test:current_test() end. Then all you need is: 4> F(). I use this a lot; it's extremely quick and convenient, not to mention having a REPL in which to perform exploratory testing. Occasionally a test will affect several modules in which case you want to reload all your modules (as you allude to above). We have a quick and dirty utility function for this, it reloads all the modules under the current working directory: load_all() -> {ok, Cwd} = file:get_cwd(), ModulesUnderCwd = [ Module || {Module,Path} <- code:all_loaded(), is_list(Path) andalso string:str(Path, Cwd) > 0 andalso Module =/= error ], log("Reloading: ~n"), [ shell_default:l(M) || M <- ModulesUnderCwd ]. So we can just do a 5> util:load_all(). That function only reloads modules, we use rake to build our code so we issue a `rake' prior to calling the above. Hope this helps, Edward P.S. I would also like to hear from more experienced Erlangers how they approach some of these micro-tasks. *********************************************************************** This e-mail and its attachments are confidential, legally privileged, may be subject to copyright and sent solely for the attention of the addressee(s). Any unauthorized use or disclosure is prohibited. Statements and opinions expressed in this e-mail may not represent those of Radialpoint. Le contenu de ce courriel est confidentiel, privilégié et peut ętre soumis ŕ des droits d'auteur. Il est envoyé ŕ l'intention exclusive de son ou de ses destinataires. Il est interdit de l'utiliser ou de le divulguer sans autorisation. Les opinions exprimées dans le présent courriel peuvent diverger de celles de Radialpoint. |