Otherwise, if third-party plugins extend newenviron by more than
3 entries, we could overflow the array. It seems unlikely that any
third-party plugin manipulates newenviron in practice, so this
is mostly theoretical. Just in case, I have deliberately avoided
using "i" as the variable name, so that any third-party plugin
that was manipulating newenviron directly will now result in the
wrapper failing to compile.
I have not assumed that realloc(NULL, ...) works as an equivalent of
malloc(...), in case there are still operating systems where that
doesn't work.
In test, set up the post-commit hook for more realism (and bugs!).
To make wrappers work in test, set PERL5LIB, and allow the wrappee's
path to be overridden. Meta-test that post-commit is really hooked
up by verifying that content is getting generated in destdir.
About the longstanding bug, which as far as I know was harmless:
CVS can't operate outside a srcdir, so we're always setting $CWD.
"local $CWD" restores the previous value when we go out of scope.
Usually that's correct. But if we're removing the last file from a
directory, the post-commit hook will exec in a working directory
that's about to not exist (CVS will prune it).
The fix: chdir() manually in cvs_runcvs(), so we can selectively
not chdir() back.
* Test that adding a text file under a name formerly tracked as
binary (and vice versa) gets the right keyword-substitution
behavior.
* Explicitly set -kkv for text files to make the tests pass.
* CVS warns in these cases about "changing keyword expansion mode",
but this is correct behavior, so filter it from stderr. Filter
stdout the same way in case we ever want to keep any of it.
* In rcs_add(), replace comments with obviousness.
a bunch more tests (that wind up exercising rcs_commit(),
rcs_commit_staged(), and rcs_recentchanges()). Extract some support
routines for brevity. Most is_in_keyword_substitution_mode() tests
are commented out because there's a bug -- non-binary files are
being added with "cvs add -kb".
Move tests that inspect recentchanges after direct CVS operations
into test_rcs_recentchanges().
In the code:
* general plugin API calls (in plugins/write order),
* VCS plugin API calls (in plugins/write order), then
* internal support routines (in alphabetical order).
In the tests:
* general meta-behavior (in no particular order, yet),
* general plugin API calls (in plugins/write order),
* VCS plugin API calls (in plugins/write order), then
* internal support routines (in semi-logical order).
* Add setup and teardown methods, called before and after every test sub.
* In setup, make a fresh repo; in teardown, throw it out.
* Extract runtests method and define default test methods at top.
* Move reflection routines near the xUnit-style subs they support.
Adapt existing test subs to run independently:
* In test_manual_add_and_commit(), assume a fresh repo.
While here, plan a bit better:
* Check for all modules used by cvs.pm.
* Check for program existence more generally.
* Check that we can rmdir after mkdir.
* Run all subs matching /^test_*/ (for which we can plan)...
* Unless TEST_METHOD is set, in which case run matching subs (sans plan).
* Define total number of tests very near 'use Test::More', where expected.
* Define test tempdir where it's declared, no longer any reason why not.
* Move most comments from TODO.cvs into t/cvs.t.
* Add a whole bunch more comments describing the needed test cases.
XXX existing tests are order-dependent, but currently happen to pass
* Call readfile() directly from writefile().
* Parameterize commit message for the web-commit case.
* Describe intent of test cases.
* Rename test subs to match what they actually do.
* To prove extra path slashes don't cause trouble, instead of running
the same tests a second time, just assert that checkconfig()
strips the slashes.
the test plan at runtime. Use IkiWiki unconditionally too (as that's
not what I'm testing here) to avoid the TAP error of printing a
test result before having printed the plan.
Using named parameters for these is overdue. Passing the session in a
parameter instead of passing username and IP separately will later allow
storing other session info, like username or part of the email.
Note that these functions are not part of the exported API,
and the prototype change will catch (most) skew, so I am not changing
API versions. Any third-party plugins that call them will need updated
though.
calls are warranted. They shouldn't modify the caller's working directory,
though. Use File::chdir to keep the scope of the changes subroutine-local.
The tests now pass without resetting the working directory.