Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extending a TestCase to a base class then extended again doesn't work for me #465

Open
ekluzek opened this issue May 30, 2024 · 3 comments

Comments

@ekluzek
Copy link

ekluzek commented May 30, 2024

I wanted to have a base class that I extend so I can test different types that themselves extends a base class into two specific

So the base class has this structure...

test_DustEmisBase.F90:

  type, extends(TestCase) :: TestDustEmisBase
     integer, allocatable :: filter_nolakep(:)      ! non-lake filter (patches)
     integer :: num_nolakep              ! number of patches in non-lake filter
     type(atm2lnd_type) :: atm2lnd_inst
     type(soilstate_type) :: soilstate_inst
     type(canopystate_type) :: canopystate_inst
     type(temperature_type) :: temperature_inst
     type(unittest_water_type_factory_type) :: water_factory
     type(water_type) :: water_inst
     type(frictionvel_type) :: frictionvel_inst
   contains
     procedure :: setUp_base
     procedure :: setUp_before_subgrid
     procedure :: clean
     procedure :: setupEnvironment
     procedure :: create_atm2lnd
     procedure :: create_fv
     procedure :: print_values
  end type TestDustEmisBase

And the extended class looks like this:

test_DustEmisZender2024.pf

  @TestCase
  type, extends(TestDustEmisBase) :: TestDustEmisZender2003
     type(dust_type) :: dust_emis
   contains
     procedure :: validate_patch
  end type TestDustEmisZender2003

I started this with everything in the extended class and that works fine. It's when I tried to make a base class that it appears that the base class methods don't seem to do anything. So I've got it building, linking and running, but the base methods in the base class don't seem to do anything.

To get it to build I had to have the base class a .F90 file rather than .pf

@ekluzek
Copy link
Author

ekluzek commented May 30, 2024

The workaround I'm going to go to is to have the baseclass as a separate object to handle the input for the objects that I want to have different tests for. So this still doesn't require code duplication, it's just not quite as slick as using an OO base class for both.

@ekluzek
Copy link
Author

ekluzek commented May 30, 2024

This somewhat relates to #343. But, I did get my case to build and link. Although the base class had to be a .F90 to get CMake to work with it.

@tclune
Copy link
Member

tclune commented Jun 18, 2024

I am sorry for the delay in responding. Lots of travel (and then catching up).

I'm not sure that I understand what your particular failure is.

I started this with everything in the extended class and that works fine. It's when I tried to make a base class that it appears that the base class methods don't seem to do anything. So I've got it building, linking and running, but the base methods in the base class don't seem to do anything.

Can you elaborate? How did you invoke the base class methods? Did they return without executing your code?

The CMake issue is presumably separate so let's deal with that once you've got something in true Fortran working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants