Goddard-Fortran-Ecosystem / pFUnit

Parallel Fortran Unit Testing Framework
Other
169 stars 45 forks source link

Using `funitproc` with `MpiTestCase` - Can this work? #448

Closed MatthewHambley closed 5 months ago

MatthewHambley commented 7 months ago

I'm looking to migrate an existing suite of unit tests implemented using pFUnit v3 to v4.

Our MpiTestCase tests are failing to compile with the error Error: Derived type ‘mpitestparameter’ at (1) is being used before it is defined. This is being thrown from the generated portion of the source code. Sure enough the wrapper is importing Funit which doesn't have the parallel support of pFUnit.

Since this seems to be hardwired in the processor there doesn't seem a way this could ever work.

Minimal test case attached. mtc.tar.gz

This highlights a second issue which is that I couldn't find any good user documentation which explains how to use the framework. There are a few bits and pieces here and there but nothing comprehensive. I ended up having to scrutinise the framework source code.

The examples also look to be the same as the ones which were somewhat out of date for v3. Do these give a good starting point for the neophyte user?

tclune commented 7 months ago

My apologies for my slow response on this issue. I have replicated the issue and am looking into it. The test should have been detected as requiring MPI, but somehow that is being lost by the time the boiler plate is being generated.

Documentation? Guilty. The documentation from pfunit-3 is horribly outdated and realistically I'm never going to get around to writing good documentation for the current pfunit. Just juggling too many different bits of software these days. I do try to maintain a decent set of useful examples in the parallel repository pFUnit_demos. There I have an mpi demo and a parameterized demo, but not anything at the intersection. A 1st step would be to build your reproducer (once working) into such an example there.

tclune commented 7 months ago

OK - I see now. When you define your own pFUnit TestCase extension, you need to indicate to the preprocessor that you've done that. Otherwise it just assumes a simple test case. The preprocessor is not smart enough to see your declaration class(example_test_type) and infer that it extended the MpiTestCase vs anything else.

A few other issues:

  1. private is generally not a good thing to put in the test suite. It interferes with accessibility. If you use it be sure to declare all the actual tests to be public.
  2. It would be nice to have the actual tests be type-bound-procedures for a TestCase extension, but alas that cannot be made to work within the framework for obscure technical Fortran reasons. Instead, they are accessed as procedure pointers. But more to the point, the framework takes care of that association - you only need to declare the test procedures with the @test anntation.

I have attached a suitably updated version with a few comments about what changes. This compiles for me. my_mtc.tar.gz

tclune commented 7 months ago

hmm. Circling back, and realized that maybe the constructor=... is not needed in your simple example. It now compiles without that bit after making the other changes.

I suspect you'll run into more issues as you make this more fully featured. Should be quiet this week (AGU fall meeting takes away many of the scientists in the org), so hope for a faster turnaround in communication.

MatthewHambley commented 5 months ago

I have made some progress so the specific issues noted here are resolved. I will raise other issues for further related problems.