EUnit setUp/tearDown question

Muharem Hrnjadovic muharem@REDACTED
Mon Oct 25 10:33:25 CEST 2010


Hello there!

I am trying to set up a suite of tests where a temporary directory is
created and torn down for each test.

{{{
  1 -module(eunit_tests).
  2
  3 -include_lib("eunit.hrl").
  4
  5 is_link(P) ->
  6     {ok, FIT} = file:read_link_info(P),
  7     element(3,FIT) =:= symlink.
  8
  9 test_is_link_with_regular(T) ->
 10     P = filename:join(T, "a"),
 11     ?cmd(io_lib:format("touch ~s", [P])),
 12     ?assert(not is_link(P)).
 13
 14 test_is_link_with_link(T) ->
 15     P = filename:join(T, "a"),
 16     ?cmd(io_lib:format("touch ~s", [P])),
 17     ?cmd(io_lib:format("ln -s ~s ~s.link", [P, P])),
 18     ?assert(is_link(P ++ ".link")).
 19
 20 is_link_test_() ->
 21     {foreach,
 22      fun() -> ?cmd("mktemp -d") end,
 23      fun(T) -> ?cmd("rm -rf " ++ T) end,
 24      ...
 25     }.
}}}

My question is: what should go into line 24 so that the two tests
(test_is_link_with_regular() and test_is_link_with_link()) are called
with T (the temporary directory path)?

Or is there a better way to achieve the same thing?

Best regards/Mit freundlichen Grüßen

-- 
Muharem Hrnjadovic <muharem@REDACTED>
Public key id   : B2BBFCFC
Key fingerprint : A5A3 CC67 2B87 D641 103F  5602 219F 6B60 B2BB FCFC

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 900 bytes
Desc: OpenPGP digital signature
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20101025/2693e929/attachment.bin>


More information about the erlang-questions mailing list