Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Allow skipping of initial tests with an environmental variable #12
First, I'm not sure this is the perfect way to do this, so absolutely use your judgement on whether or not this is the way you want to do it - if it isn't, I'm glad to rework this if you would like a different method of doing something like this. This is one implementation to provide the feature asked for in https://rt.cpan.org/Ticket/Display.html?id=84153 - "I have a project that has a lot of tests, and I'd like to only run the tests as I change code, not a big initial run[.] Could I add a "--watch_only" or some other flag to autoprove that would skip the initial _run_once() call? Would that be an acceptable solution to my problem?"
I thought that the command line already had a lot of stuff on it, so I chose an environmental variable. I structured it so that you could add additional options at a later time, by simply allowing the options in the TEST_CONTINUOUS environmental variable to be separated by commas. The only option defined right now is "SKIP_INITIAL". I also changed documentation to reflect how this works, with a strong suggestion to not do this (since it probably generally shouldn't be done), but there are likely valid uses in really large systems, or in systems where tests take a very long time to run.
I also added a set of new tests in env_variable.t, which try the various combinations of valid and invalid environmental variables, and validate that they do what they should. These tests use Test::Exception, which seems to support all versions of Perl that Test::Continuous does - I added Test::Exception to the tests section of cpanfile (you may want to move Test::More to there; you may also want to add a devel section to cpanfile with Module::Build::AuthorTests and Module::Build::CPANfile listed, since these are required to build the module from the Git repo).
I didn't update the change log, as I don't know if other changes would go out with this, should you agree with this pull request.
I see that this is a patch for RT 84153 -- thank you very much!
Personally I'm like arguments more than introducing one env var for each new features... may I suggest that we take the following approach:
This idea is just a shameless copy from what cpanm does, and I think it is a brilliant approach to make it convenient for daily uses and still keep all feature easily organized for developers.