<div dir="ltr">Hi Nathan,<div><br></div><div>*Spolier alert* - I think you make a pretty strong case for ending the practice of yielding tests.  In particular, if this makes it easier for developers to debug failing or erroring tests, I'm definitely on board.  I agree that we should be encouraging people to run tests locally.  I know I should be doing more of that.</div><div><br></div><div>As for your points against doing this, I personally think they do not outweigh the benefits.  The PR may be large, but it should be confined to testing files and the changes should all be very straightforward.  Your second point against is probably the most compelling, but I think if one were to find themselves in a situation with a failing test, the best thing would be to just run that single test over and over again locally until it passed.</div><div><br></div><div>To conclude my own novella of a response to your Ulysses, I am +1 on this.</div><div><br></div><div>Britton</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 8, 2015 at 5:11 PM, Nathan Goldbaum <span dir="ltr"><<a href="mailto:nathan12343@gmail.com" target="_blank">nathan12343@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi all,<div><br></div><div>Sorry for the novel of an e-mail! I wanted to be as detailed as possible, I hope it isn't too much.<br></div><div><br></div><div>Right now our test suite does a lot of test yielding. Under this paradigm, every yielded test counts as a "dot" in the nose testing output and contributes to the number of tests printed at the end of the test suite. In addition, yielding tests makes it so that if a test function has a failing test, all of the tests yielded by that function will be run despite the fact that one or more tests failed.<br></div><div><br></div><div>It's definitely nice to see that we're running thousands of tests, and I'd happy with continuing to do it, except I've learned that this approach adds some technical hurdles for people who actually need to deal with the test suite.</div><div><br></div><div>Personally, I've noticed that it makes debugging failing tests much more annoying than it needs to be. Since a test is yielded, the traceback generated by a failing or erroring test ends up somewhere in nose rather than in the yt test suite function that actually yielded the test. This can make it difficult to determine where a failing test is coming from in the test suite, particularly if the test that gets yielded is just an assert.</div><div><br></div><div>In addition, Kacper tells me that our practice of yielding tests makes it difficult to simplify our jenkins setup since yielded tests are not parallel-safe.</div><div><br></div><div>I'd like to propose a modification to the yt codebase and developer guide. Rather than encouraging that all asserts and test classes be yielded, we should instead *not* yield them and just call them as regular functions or classes. To make that concrete, the following set of tests from the NMSU ART answer tests would go from looking like this:</div><div><br></div><div><a href="http://paste.yt-project.org/show/5944/" target="_blank">http://paste.yt-project.org/show/5944/</a><br></div><div><br></div><div>to looking like this:</div><div><br></div><div><a href="http://paste.yt-project.org/show/5946/" target="_blank">http://paste.yt-project.org/show/5946/</a><br></div><div><br></div><div>Each individual assert and test class instantiation would no longer count as an individual test in nose's test statistics.  Instead, referring to the example above, the test_d9p function would be the only test reported by nose, even though the test function does many asserts and instantiates many test class instances.<br></div><div><br></div><div>For me, the main win would be that it would be easier to determine which exact test failed, because the traceback reported by nose due to the test failure would include the line in the test file that produced a failing assert or caused an unhandled exception to be raised.</div><div><br></div><div>To make that concrete, I've just made the following modification to the `test_dimensionless` function to force a test to fail:</div><div><br></div><div><a href="http://paste.yt-project.org/show/5947/" target="_blank">http://paste.yt-project.org/show/5947/</a><br></div><div><br></div><div>Running `nosetests units` in the root of the repository, I get the following traceback:</div><div><br></div><div><a href="http://paste.yt-project.org/show/5948/" target="_blank">http://paste.yt-project.org/show/5948/</a><br></div><div><br></div><div>Note how the test traceback does *not* include the `test_dimensionless` function.  If I instead make it so the failing test is not yielded:</div><div><br></div><div><a href="http://paste.yt-project.org/show/5949/" target="_blank">http://paste.yt-project.org/show/5949/</a><br></div><div><br></div><div>I get a much nicer traceback:</div><div><br></div><div><a href="http://paste.yt-project.org/show/5950/" target="_blank">http://paste.yt-project.org/show/5950/</a><br></div><div><br></div><div>I can see a few reasons why we might not want to do this.</div><div><br></div><div>1. This is an invasive, large-scale change. It might be automatable (I think I could write an emacs macro to do this, for example), but it would in the end be difficult to review.</div><div><br></div><div>2. Since test functions would terminate on the first failure, it might lead to annoying debug cycles where one assert gets fixed but then the next assert fails, forcing people to wait for the full test suite to be rerun just to get to the next failing test.</div><div><br></div><div>For the second point, I think we can remedy this just by improving our testing docs to encourage people to run tests locally as much as possible and also explain better how to run only a specific test function from the command line.</div><div><br></div><div>If people are interested in making this modification globally, I think I could take it on as part of my general efforts to clean up the codebase.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>-Nathan</div><div><br></div></font></span></div>
<br>_______________________________________________<br>
yt-dev mailing list<br>
<a href="mailto:yt-dev@lists.spacepope.org">yt-dev@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org" rel="noreferrer" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org</a><br>
<br></blockquote></div><br></div>