Fixing the test suite for my recent refactorings ended up being quite
the trip through the looking glass.
I ended up making the run-test phase not enabled by default due to
always filtering it out in the test suite. So naturally I just add it
back in if we're using the run-tests option. But naturally *that* change
warrants test suite coverage, and testing it out gave me error about
finding main::list_has, since list_has is really test::list_has when the
test suite is being run.
Using Perl's caller function allows me to reset the package to main at
the start of kdesrc-build and still detect when it's being activated as
part of the test suite, but then the functions in the test suite don't
work until I switch *its* package to match.
It all does seem to work now though.
The logging subsystem test case was passing because of an old log
directory I still had on my system. I've fixed the test case to use the
existing temporary test directory and to not use any existing log
directories.
I've gone over the code one more time, this should hopefully be the last
reference to anything on my system. :-/
The test suite comments hint around the fact that an exception should be
thrown if --resume-from and --resume-after are both set, it's not
actually that hard to verify an exception is raised, so go ahead and add
a simple test for that.
Pino Toscano noted that there were several tests failing on his system
after (well, and before ;) he changed the source directory setting in
the test suite to be under the home directory.
Indeed he is right, although I removed references to my home directory
when uploading my test suite, I did not remove references to my source
and build directories, which naturally did not contain svn sources on
Pino's system, which caused several tests to fail.
Now the testsuite will do a svn checkout (of kdesupport at this point as
I feel it is most likely to hang out in svn) before running tests on
functions requiring a svn source directory. The checkout is constrained
to avoid checking out any files or referencing any external svn
checkouts and is only run when running the test suite, so hopefully this
doesn't represent any significant load on the KDE svn servers.
In addition the base directory for all operations is under a temporary
directory, cleaned up when the test suite completes. Right now the
temporary directory is created under the normal temp dir (/tmp on my
system), the Temp::File docs seem to indicate this can be changed by
specifying DIR => /path/to/dir when running tempdir() if desired.
Finally, I ended up adding a test for the directory creation function in
the process of testing the test suite, which I left it because it's a
good idea anyways.
All tests pass on my system now with these changes, hopefully that will
be the case elsewhere.
1) updateModulePhases is supposed to act mostly like a
functional-language type of function, where it returns a filtered list
based on the input list. However, since every element in the list is a
reference to an object, doing a copy-then-modify still means you're
working on the original object. For now I solve it just be cloning the
entire input list, but I'll probably want to add a real copy-ctor or
clone method in the future. Not many functions handle Module objects yet
so this seems to be the only case requiring a change. This was found
when trying to add a test case for:
2) Ensure that using --no-src at the command line doesn't also clear out
the build/install phases (as is supposed to happen when e.g.
manual-update is specified in the rc file).
kdesrc-build-test.pl has always given me a warning about redefining
some note subroutine. Turns out Test::More includes a subroutine called
note, but we don't need it, so exclude it.