@José I thought about that at first but I *think* it means pulling the 
`after_suite` callback execution out from `ExUnit.Runner` into the main 
`ExUnit` module, and possibly calling the callbacks with no args, or empty 
stats, since when the mix task finds no files it exits with non-0 status 
and we end up here 
<https://github.com/elixir-lang/elixir/blob/v1.11.3/lib/ex_unit/lib/ex_unit.ex#L213>?
 
I could be wrong, wasn't able to figure my way around the tests yet.

If the above is true this might be a more meaningful change, but happy to 
pursue it with guidance.

On Friday, February 19, 2021 at 1:07:45 PM UTC José Valim wrote:

> Thanks for the proposal.
>
> Perhaps it makes sense to run after_run in said cases as well. This way we 
> can skip adding before_suite and make after_suite more consistent. WDYT?
>
> On Fri, Feb 19, 2021 at 12:57 PM João Ferreira <[email protected]> 
> wrote:
>
>> Hey all,
>>
>> I'd like to propose the complement to ExUnit.after_suite/1 which runs a 
>> set of callbacks immediately before the test suite starts.
>>
>> We can set up code that's run before the test suite in test_helper.exs 
>> but, unlike ExUnit.after_suite/1, this code runs regardless of there being 
>> any actual tests to run as part of the suite. So if we *need* to tear 
>> down some code that was set up in test_helper.exs but no tests are run, 
>> we're out of luck.
>>
>> Here's a particular example: 
>>
>>    1. Running an umbrella project with 2 apps
>>    2. mix test specific/file/in/app/1.ex
>>    3. Setup & tear-down happen correctly in app 1 suite
>>    4. Setup happens in app 2, but tear-down does not, because no files 
>>    match the given path, and after_suite callbacks don't run.
>>
>> Adding before_suite callbacks with the same semantics as after_suite 
>> would be helpful here, since setup would only happen if there were any 
>> tests to run.
>>
>> Cheers,
>> João
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "elixir-lang-core" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/elixir-lang-core/884211ef-56dc-4a4b-b493-e8b67445e094n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/elixir-lang-core/884211ef-56dc-4a4b-b493-e8b67445e094n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/b073fc21-ac5c-4ceb-bb20-275f3c823e0bn%40googlegroups.com.

Reply via email to