-
Notifications
You must be signed in to change notification settings - Fork 42
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
Enhance testing experience #136
Conversation
Wow, this is quite a mouthful. I took a quick glance at it and I really like most of it. Thank you! 💚 Beside the conflict with Please do a rebase to the current state of master! |
Another thought: Are those
However, this approach fails for |
And something else: I like the various test targets. Please document them in the README.md. |
Will do!
I deliberately chose to implement that based on #114, because it was just easier to do and also I think we need to tackle configuration in a separate issue. I'd leave that as is, and change it once we unify configuration. Right now there are 5 ways to pass options to PropEr from PropCheck - three of which are somewhat "global".
No. It's just for testing PropCheck itself.
Right, DEBUG-output is used to inspect the property, so in most cases it's not useful to have it on.
Good point! I should have thought about that! |
Ahh, interesting. I did not see this. We should state that explicitly in the docs. This goes also for the
Valid point. I open a feature request for that. |
Maybe it would make sense to mark the module with |
ExDocs won't generate docs from |
I assume the conflict with |
That's a very good point! We should consider whether to choose between new user's experience and our convenience. Maybe it would be better pick the former and to undo use PropCheck, default_opts: &PropCheck.TestHelpers.config/0
import PropCheck.TestHelpers, except: [config: 0] Where Or we could also extract those examples to a separate |
At least we must run it regularly to ensure that it is still valid code. From that perspective it is still test code, but not optimised for our internal development processes. Removing |
The simplest solution would be to just comment out any |
e17fb88
to
4512fcf
Compare
Running tests in PropCheck isn't exactly easy. There are few tags tests that are intended to fail and some which are unstable, additionally there are few external tests that need be run form a bash shell. So simply doing `mix test` doesn't work and will just confuse users. This commit simplifies that by introducing new two Mix alias: * `test_ext` which runs external tests, * `tests` which runs both external and regular tests (limited only to reliable tests).
To accomplish that, this commit, replaces most printing with `debug/1` function and comment out unnecessary printouts (like `collect/3` or `aggregate/3`). Printing of debug information can now be controlled by setting `PROPCHECK_DEBUG` environment variable. Setting `PROPCHECK_DEBUG` to `1` or `TRUE` will enable printing of debug statements in the tests itself. In CI environment, both variables are set to preserver current output state.
Strange. All of my travis builds were OK while here all but one of the builds, which failed with erl_crash.dump. Probably memory consumption got too big when creating a tree in that last test. @alfert can you rerun the build? If this will keep happening, |
Rerunning the branch on my notebook works smoothly ( I would suggest to adjust the |
Default number of tests is reduced to 33 and tests which had hard coded number of tests are scaled based on their relation to PropEr's default of 100. That is, if test had hardcoded `numtests: 10`, it's now `scale_numtests(0.1)` because 10 is 0.1 of 100. This allows to keep the proportions of individual tests while globally controlling number of tests via `PROPCHECK_NUMTESTS` environment variable. The same was done to `search_steps`, but is controlled by `PROPCHECK_SEARCH_STEPS` environment variable and scaled by `scale_search_steps` function. This is meant to reduce time wait for completing tests on day-to-day development. To compensate for the potentially missed opportunities to generate failing examples on day-to-day development, number of tests is increased on CI.
Tests involving PingPong and Movie servers cannot be run safely in parallel, so only one in each group was chosen to be run asynchronously.
Increasing the number of tests increases the chances of find the correct path.
I've modified But, the VM I'm using to develop it has "only" 5.9GB RAM and half of it is used by firefox and emacs, and I didn't had any issue like that. I think the probabilistic nature of this tests will generate enormous structures on "rare" occasions. Will see how rare. |
Sorry for a big dump, but I didn't want to create a bunch of smaller but codependent PRs. Each commit message has some more description in it so please look there also.
The overall motive behind it is to make testing of PropCheck simpler and easier. As mentioned in #130, running tests is not straight forward:
Dispatching tests
I've disabled unstable and external tests by default and added two new aliases:
test_ext
for running external tests,tests
for running external and normal tests. CI uses this with--cover
and--trace
arguments like before.Noisy tests
Printing of debug information is now controller by
DEBUG
andVERBOSE
environment variables. To do that, I've introduced a new case templatePropCheck.TestCase
which imports few debug printing functions and sets default options for each module. From now on all tests need to usePropCheck.TestCase
instead ofExUnit.Case
(not counting external tests).The only thing that is still creating noise are doctest, but changing that would either make them less comprehensible or need copying doctests to own separate tests.
Flaky tests
I've isolated 2 flaky tests and increased the number of tests or search steps to increase the probability that the generated examples had the "correct" path in them (both of them were checking for at least one correct example). I've been increasing the number of
numtests
/search_steps
then running each test 3000 times to check if they fail, until I was not able make them fail.Slow tests
I've reduce the
numtests
to 33 and search steps to 333, and introducedNUMTESTS
andSEARCH_STEPS
env variables, that control those options (viaPropCheck.TestCase
). Some tests with hard coded number of tests, are now scaled proportionally. Additionally, most tests are now run asynchronously. This reduced time ofmix test
from ~28 seconds (on my computer), to ~3.7 seconds. Running external and regular tests takes now around 12 seconds.To offset the reduced numbers, CI builds have them increased to 200 and 1000 (for
numtests
andsearch_steps
). CI also disables asynchronous test by using--trace
.