Unit tests for package oct-files

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Unit tests for package oct-files

Oliver Heimlich
I added unit tests to the *.cc files of a package. After installing the
package I was not able to execute the tests, because the sources could
not be found by the test.m script.

I found the following solution (workaround?): I can save a list of *.cc
and *.oct file names in a src/FILES file of the package. Then, during
package installation the complete sources of the OCT-files will be
copied into the package's installation directory, where the test script
can perfectly find them.

Without the src/FILES list, the *.cc sources are lost during package
installation, this is the part of the configure_make.m file that ignores
them:

     else
       m = dir (fullfile (src, "*.m"));
       oct = dir (fullfile (src, "*.oct"));
       mex = dir (fullfile (src, "*.mex"));

       filenames = cellfun (@(x) fullfile (src, x),
                            {m.name, oct.name, mex.name},
                            "uniformoutput", false);
     endif

How should unit tests from packages be installed?

A) The package maintainer has to maintain a src/FILES list, and *.cc
sources are installed to the package installation directory. This
requires no code changes.

B) The configure_make.m script will be extended and also copy *.cc
sources automatically during package installation. There will be no
general need for a src/FILES.

C) During OCT-file compilation (package's Makefile), the relevant test
cases have to be extracted into separate *.cc-tst files. The
configure_make.m script will be extended and also copy *.cc-tst files
automatically during package installation. The test.m script will be
extended and also look for *.cc-tst files, if it is called with “test
<function>”.

Option B is the most simple solution for the package maintainer.

However, with option C life can be made easier for downstream distros,
which do not want to include unnecessary source code in binary package
releases.

Oliver

Reply | Threaded
Open this post in threaded view
|

Re: Unit tests for package oct-files

Mike Miller
On Wed, Feb 18, 2015 at 19:59:34 +0100, Oliver Heimlich wrote:
> I added unit tests to the *.cc files of a package. After installing the
> package I was not able to execute the tests, because the sources could not
> be found by the test.m script.
[...]
> How should unit tests from packages be installed?

That is correct, there is not currently a solution for tests in source
files of Octave packages.

See (and help resolve!) the following open bugs:

  https://savannah.gnu.org/bugs/?41215
  https://savannah.gnu.org/bugs/?41298

I believe that your option C is what I described in bug #41298, and I
believe that is the right way to go.

IMHO, I will still write my tests in .cc files and use them while
doing development, with the understanding that the tests are not
available to be run after the package is installed.

--
mike