Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for reseting the Eunit environment after each test #385

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

bowrocker
Copy link

Overview

Add a command-line parameter, reset_after_each_eunit=[true|false], that if true runs each eunit suite individually and employs @slfritchie logic to reset the enviroment after each one.

This was done because tests within replication were found to be polluting the environment of subsequent tests.

Configuration

Added new property to eunit_opts option list:

reset_after_each_eunit::boolean() - default = false.
If true, try to "reset" VM state to approximate state prior to
running each EUnit test:
* Stop net_kernel if it was started
* Stop OTP applications not running before EUnit tests were run
* Kill processes not running before EUnit tests were run
* Reset OTP application environment variables

Related PR

#107

fixed type and case statement ordering

removed unecessary ?DEBUG statement
@lordnull
Copy link

lordnull commented Nov 6, 2013

Tests pass and code is readable. I'd like to see a test for this specific feature, though.

@lordnull
Copy link

lordnull commented Nov 6, 2013

Further testing shows this may not work as expected.

rebar eunit skip_deps=true reset_after_eunit=true
ERROR: eunit failed while processing /Users/micahw/src/riak_repl: {'EXIT',{{case_clause,"true"},
         [{rebar_eunit,maybe_cleanup,2,
                       [{file,"src/rebar_eunit.erl"},{line,207}]},
          {rebar_eunit,perform_eunit,4,
                       [{file,"src/rebar_eunit.erl"},{line,426}]},
          {rebar_eunit,run_eunit,3,[{file,"src/rebar_eunit.erl"},{line,182}]},
          {rebar_core,run_modules,4,[{file,"src/rebar_core.erl"},{line,446}]},
          {rebar_core,execute,5,[{file,"src/rebar_core.erl"},{line,371}]},
          {rebar_core,process_dir1,6,[{file,"src/rebar_core.erl"},{line,235}]},
          {rebar_core,process_commands,2,
                      [{file,"src/rebar_core.erl"},{line,90}]},
          {rebar,main,1,[{file,"src/rebar.erl"},{line,58}]}]}}

A similar crash happens if reset_after_eunit is set to false.

Also, trying to set the reset_after_each_eunit to false doesn't actually work as demonstrated by the debug output:

rebar -vvv eunit skip_deps=true reset_after_each_eunit=false
DEBUG: running cleanup after each testDEBUG: running tests:rt_source_eqc with options:[verbose]

Finally, note the lack of a newline before the second DEBUG.

perform_eunit(Config, Tests, StatusBefore, DoClean);
_IsTrue ->
?DEBUG("running cleanup after each test", []),
[perform_eunit(Config, T, StatusBefore, true) || T <- Tests]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put a newline in the above debug. the debug macro isn't nice enough to do one for you.

@jaredmorrow
Copy link
Contributor

@lordnull ping, did the new commits fix your issues?

@slfritchie
Copy link
Contributor

Re-ping?

@jaredmorrow
Copy link
Contributor

@slfritchie @lordnull I honestly just need a +1 and I'll put this through.

@slfritchie
Copy link
Contributor

I'm not an active reviewer (yet), I was dragged in by Jon. :-) I'm still catching up on a huge backlog of correspondence & to-do items from my vacation, so it's likely a couple of days before I can sneak in a review of this ticket.

Micah?

@bowrocker
Copy link
Author

This needs a little more work to be ready -- issues were uncovered by
Micah's testing in his environment that I do not hit. I will let you all
know when it's been fixed.

Sorry for the delay.

On Wed, Nov 20, 2013 at 10:32 PM, Scott Lystig Fritchie <
notifications@github.com> wrote:

I'm not an active reviewer (yet), I was dragged in by Jon. :-) I'm still
catching up on a huge backlog of correspondence & to-do items from my
vacation, so it's likely a couple of days before I can sneak in a review of
this ticket.

Micah?


Reply to this email directly or view it on GitHubhttps://github.com//pull/385#issuecomment-28955492
.

wcy123 pushed a commit to wcy123/rebar that referenced this pull request Mar 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants