Testing functions in ./private subdirectory

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

Testing functions in ./private subdirectory

PhilipNienhuis
Given this discussion:

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=672756 [1]

and as a corollary of [1], this bug report:
http://savannah.gnu.org/bugs/index.php?38755 [2]

about failure to run tests in functions scripts in ./private subdirectories for Octave-Forge packages, I was wondering if this issue has ever been considered in some detail by the Octave developers community before.

A. IMO it is quite useful to have tests for functions living in ./private subdirs as well, also for OF packages.

B. Indeed, when functions live in ./private directories, they're not in the PATH and a test script won't find them (obviously, provided that the testscript is written so that it'll only look in the PATH).

In [1] and [2] it is suggested to move test blocks of functions in ./private to other functions in the ./inst directory (we're talking about OF here).
I'm less inclined to be in favor of this, as I think tests should be kept together in one place with the function they're supposed to test. IMO, having bits and pieces of functions scattered around various places doesn't help keeping code transparent and easy to manage.

I would rather think it more logical for a test script to temporarily extend the PATH with ./private subdirs if it finds those.

Now the Debian devs asked me to apply their solution (=moving test blocks) to functions in the ./private subdir of the io package so that the tests for those ./private/<functions> can be run by their test script.
I'm hesitating because I think it's rather their test script that has to be improved to look in ./private subdirs as well. And maybe/probably for core Octave a solution already exists (? I think so)

So:  what's the opinion of the Octave devs?

Philip
Reply | Threaded
Open this post in threaded view
|

Re: Testing functions in ./private subdirectory

John W. Eaton
Administrator
On 04/18/2013 03:20 PM, PhilipNienhuis wrote:

> Given this discussion:
>
> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=672756 [1]
>
> and as a corollary of [1], this bug report:
> http://savannah.gnu.org/bugs/index.php?38755 [2]
>
> about failure to run tests in functions scripts in ./private subdirectories
> for Octave-Forge packages, I was wondering if this issue has ever been
> considered in some detail by the Octave developers community before.
>
> A. IMO it is quite useful to have tests for functions living in ./private
> subdirs as well, also for OF packages.
>
> B. Indeed, when functions live in ./private directories, they're not in the
> PATH and a test script won't find them (obviously, provided that the
> testscript is written so that it'll only look in the PATH).
>
> In [1] and [2] it is suggested to move test blocks of functions in ./private
> to other functions in the ./inst directory (we're talking about OF here).
> I'm less inclined to be in favor of this, as I think tests should be kept
> together in one place with the function they're supposed to test. IMO,
> having bits and pieces of functions scattered around various places doesn't
> help keeping code transparent and easy to manage.
>
> I would rather think it more logical for a test script to temporarily extend
> the PATH with ./private subdirs if it finds those.
>
> Now the Debian devs asked me to apply their solution (=moving test blocks)
> to functions in the ./private subdir of the io package so that the tests for
> those ./private/<functions>  can be run by their test script.
> I'm hesitating because I think it's rather their test script that has to be
> improved to look in ./private subdirs as well. And maybe/probably for core
> Octave a solution already exists (? I think so)
>
> So:  what's the opinion of the Octave devs?

Private functions serve the same purpose as subfunctions.  The only
real difference is that the scope of private functions is any function
in the parent directory instead of just a single parent function.

Would you also propose to strip out the subfunctions and test them
individually?

I don't think either of those things is necessary.  It seems
good enough to me to test only the main functions and to write those
tests in a way that also tests the internal functions.

jwe
Reply | Threaded
Open this post in threaded view
|

Re: Testing functions in ./private subdirectory

PhilipNienhuis
John W. Eaton wrote
On 04/18/2013 03:20 PM, PhilipNienhuis wrote:
> Given this discussion:
>
> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=672756 [1]
>
> and as a corollary of [1], this bug report:
> http://savannah.gnu.org/bugs/index.php?38755 [2]
>
> about failure to run tests in functions scripts in ./private subdirectories
> for Octave-Forge packages, I was wondering if this issue has ever been
> considered in some detail by the Octave developers community before.
>
> A. IMO it is quite useful to have tests for functions living in ./private
> subdirs as well, also for OF packages.
>
> B. Indeed, when functions live in ./private directories, they're not in the
> PATH and a test script won't find them (obviously, provided that the
> testscript is written so that it'll only look in the PATH).
>
> In [1] and [2] it is suggested to move test blocks of functions in ./private
> to other functions in the ./inst directory (we're talking about OF here).
> I'm less inclined to be in favor of this, as I think tests should be kept
> together in one place with the function they're supposed to test. IMO,
> having bits and pieces of functions scattered around various places doesn't
> help keeping code transparent and easy to manage.
>
> I would rather think it more logical for a test script to temporarily extend
> the PATH with ./private subdirs if it finds those.
>
> Now the Debian devs asked me to apply their solution (=moving test blocks)
> to functions in the ./private subdir of the io package so that the tests for
> those ./private/<functions>  can be run by their test script.
> I'm hesitating because I think it's rather their test script that has to be
> improved to look in ./private subdirs as well. And maybe/probably for core
> Octave a solution already exists (? I think so)
>
> So:  what's the opinion of the Octave devs?

Private functions serve the same purpose as subfunctions.  The only
real difference is that the scope of private functions is any function
in the parent directory instead of just a single parent function.

Would you also propose to strip out the subfunctions and test them
individually?
You're opening a can of worms :-)

In principle every function should be amenable to testing whether it works correctly in all foreseen circumstances.

Functions in a private subdir can be called by more than one main function in the parent dir, including functions that didn't exist at the time the private function was written. So IMO for private functions correctness is more important than for subfunctions whose rough edges can be/are often catched by the main function in the same file.

I found a commented-out stanza in /scripts/miscellaneous/private/__xzip__.m saying:
## FIXME -- reinstate these tests if we invent a way to test private
## functions directly.
...so apparently this issue has been touched upon before.

Running tests isn't part of normal usage of a program like Octave. IMO that is a viable motive to alleviate scoping rules in the special case of ./private subdirs, obviously only temporarily, during testing of the functions in that specific ./private subdir.

I don't think either of those things is necessary.  It seems
good enough to me to test only the main functions and to write those
tests in a way that also tests the internal functions.
That's more or less the situation at hand.
In the io package there are two test scripts that implicitly test the private functions as well. All main spreadsheet functions are tested (which is no claim that all bugs are catched). But the low-level things in /private *must* function correctly to get meaningful results in those test scripts at all.
I can't vouch for other OF packages containing tests in private functions (IIRC statistics, financial, geometry and maybe more).

Now, as I understand the Debian devs want a smooth execution of their packaging test script. The fact that there are uncommented tests in functions in the private subdir hampers that smoothness.
I think that is a Debian problem rather than an Octave problem. It's them who made their tests more rigid than ours. Yet they do raise a valid point.

Given the Debian devs request and the stanza in ./scripts/miscellaneous/private/__xzip__.m, I'll file a bug report about tests in private functions not being run with test scripts (bug # 38776)

Philip