December 2017 Archives

Verifying your distribution's revdeps still work after a change

In one of my pieces of software, Mock::Sub, I recently found that I wanted to add a new feature, and as always, I wrote a test file for the new work before modifying code. After making the first round of changes, I stumbled upon a previously unknown bug, so I opened an issue, and decided to tackle that before adding the new feature, to ensure all previous tests would run.

The new feature is quite minor and actually requires a specific parameter to be sent in to change existing behavour (ie. no existing code that uses the distribution should have been affected), but the bug was a little more complex, and did change things internally.

After I got the bug and new feature added, and before just blindly uploading it to the CPAN, I of course wanted to know whether the reverse dependencies (down-river distributions) would not be adversely affected, which would cascade Testers failure emails to the poor souls who's distributions I broke (most are mine in this case, but I digress).

A long time ago, I went about writing a completely autonomous testing platform to do extensive testing on my repos against all Perlbrew/Berrybrew installations installed (it can dispatch out to remote systems as well). This distribution is Test::BrewBuild. One of the core features I built into this software, is to automatically perform unit tests on all reverse dependencies as they currently sit on the CPAN against the changed code in the local distribution.

I'll get right to it; it's pretty straightforward:

First, ensure you're in your repository directory, and ensure all tests pass on the distribution you've just updated:

~/devel/repos/mock-sub$ make test

t/00-load.t .................... ok     
t/01-called.t .................. ok   
t/02-called_count.t ............ ok   
t/03-instantiate.t ............. ok    
t/04-return_value.t ............ ok     
t/05-side_effect.t ............. ok     
t/06-reset.t ................... ok     
t/07-name.t .................... ok   
t/08-called_with.t ............. ok     
t/09-void_context.t ............ ok     
t/10-unmock.t .................. ok     
t/11-state.t ................... ok     
t/12-mocked_subs.t ............. ok   
t/13-mocked_objects.t .......... ok     
t/14-core_subs.t ............... ok   
t/15-remock.t .................. ok   
t/16-non_exist_warn.t .......... ok   
t/17-no_warnings.t ............. ok   
t/18-bug_25-retval_override.t .. ok   
t/19-return_params.t ........... ok   
t/manifest.t ................... skipped: Author tests not required for installation
t/pod-coverage.t ............... skipped: Author tests not required for installation
t/pod.t ........................ skipped: Author tests not required for installation
All tests successful.
Files=23, Tests=243,  1 wallclock secs ( 0.05 usr  0.02 sys +  0.72 cusr  0.07 csys =  0.86 CPU)
Result: PASS

So far, so good (of course, I had already ensured the "skipped" tests pass as well). Now, after installing Test::BrewBuild, and ensuring you've got at least one instance of Perlbrew/Berrybrew installed, simply run the brewbuild binary, with the -R or --revdep flag. In the example below, for brevity, I've limited the testing against only the version of Perl I'm currently using. If I had tested against more versions (or left off the -o or --on flag it tests against all installed versions by default), each version would be listed under each revdep with the PASS or FAIL status:

~/devel/repos/mock-sub$ brewbuild -R -o 5.24.1

reverse dependencies: App::RPi::EnvUI, RPi::DigiPot::MCP4XXXX, 
Devel::Examine::Subs, PSGI::Hector, File::Edit::Portable, Devel::Trace::Subs

App::RPi::EnvUI
5.24.1 :: PASS

RPi::DigiPot::MCP4XXXX
5.24.1 :: PASS

Devel::Examine::Subs
5.24.1 :: PASS

PSGI::Hector
5.24.1 :: PASS

File::Edit::Portable
5.24.1 :: PASS

Devel::Trace::Subs
5.24.1 :: PASS

That's all there is to it. Now I am confident that my changes will absolutely not break any of my down-river distributions.

Note: If there had of been failures, a bblog directory will be created, and the full test output of that distribution located into its own file for easy review as to what went wrong. The file contains everything related to the test run that you'd normally see output by the cpanm command. Example:

~/devel/repos/mock-sub$ ll bblog

drwx------ 2 steve steve 4096 Dec 28 10:53 .
drwxrwxr-x 8 steve steve 4096 Dec 28 10:53 ..
-rw-rw-r-- 1 steve steve 8128 Dec 28 10:26 App-RPi-EnvUI-5.24.1-FAIL.bblog

About Steve Bertrand

user-pic Just Another Perl Hacker