[erlang-questions] Testing with EUnit

Matthias Lang matthias@REDACTED
Sun Apr 29 21:16:03 CEST 2007


Basically, you're missing a command to tell Erlang to exit. Here's an
example from the FAQ:

  | 5.7. ...run an Erlang program directly from the unix shell?
  | 
  | To run Erlang programs without running the Erlang shell, we just pass
  | some more switches to the Erlang virtual machine. Here's hello world
  | again:
  | 
  | 	-module(hello).
  | 	-export([hello_world/0]).
  | 	
  | 	hello_world() -> 
  | 		io:fwrite("hello, world\n").
  | 	
  | 
  | Save this as hello.erl, compile it and run it directly from the unix
  | (or msdos) command line:
  | 
  | 	matthias >erl -compile hello
  | 	matthias >erl -noshell -s hello hello_world -s init stop
  | 	hello, world

Note the "-s init stop".

You could also use Escript, but that's bleeding edge.

Matthias

----------------------------------------------------------------------

Sam Tregar writes:
 > Hello all.  I'm new to Erlang, just trying to figure out how best to
 > work in a new environment.  I've been writing tests with EUnit but I'm
 > having trouble finding a simple way to run the tests with a single
 > command.  Right now I've got a Makefile that says (where geocode.erl
 > is the module I'm testing, which uses EUnit):
 > 
 >     test: compile
 >  	 ${ERL} -s geocode test
 > 
 > So then when I want to run the tests I do:
 > 
 >     $ make test
 > 
 > This runs the test suite, giving me:
 > 
 >    Eshell V5.5.2  (abort with ^G)
 >    1>   Test successful.
 >    1>
 > 
 > Now I'm at an Eshell prompt and if I want to run the test suite again
 > I have to exit the shell before I can 'make test' again.  This is less
 > than ideal.
 > 
 > So my question is, how do I setup my environment so I can run 'make
 > test' and have the process exit when the tests are done?
 > 
 > Thanks,
 > -sam
 > _______________________________________________
 > erlang-questions mailing list
 > erlang-questions@REDACTED
 > http://www.erlang.org/mailman/listinfo/erlang-questions
 > 



More information about the erlang-questions mailing list