Skip to content

ENH: Increase Review module classes' code coverage#2653

Merged
dzenanz merged 1 commit intoInsightSoftwareConsortium:masterfrom
jhlegarreta:IncreaseReviewModuleCoverage
Jul 21, 2021
Merged

ENH: Increase Review module classes' code coverage#2653
dzenanz merged 1 commit intoInsightSoftwareConsortium:masterfrom
jhlegarreta:IncreaseReviewModuleCoverage

Conversation

@jhlegarreta
Copy link
Copy Markdown
Member

Increase Review module classes' code coverage:

  • Exercise the basic object methods using the
    ITK_EXERCISE_BASIC_OBJECT_METHODS macro.
  • Test the Set/Get methods using the ITK_TEST_SET_GET_VALUE macro.
  • Test the boolean ivars using the ITK_TEST_SET_GET_BOOLEAN macro.

PR Checklist

@github-actions github-actions Bot added type:Coverage Code coverage impacts type:Enhancement Improvement of existing methods or implementation type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct labels Jul 18, 2021
@jhlegarreta
Copy link
Copy Markdown
Member Author

To be rebased on master once PR #2652 gets merged.

@jhlegarreta jhlegarreta marked this pull request as ready for review July 18, 2021 21:28
@jhlegarreta
Copy link
Copy Markdown
Member Author

The coverage increase is not meant to be exhaustive. Further increases can be made in a separate PR.

@jhlegarreta
Copy link
Copy Markdown
Member Author

/azp run ITK.macOS

@jhlegarreta
Copy link
Copy Markdown
Member Author

A note on the CI checks: they do not test the Review module. I have not tested the PR locally. So let's hope one of the bots submitting to CDash does test the Review module.

@dzenanz
Copy link
Copy Markdown
Member

dzenanz commented Jul 20, 2021

Please rebase

Copy link
Copy Markdown
Member

@thewtex thewtex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💚 🙏

@dzenanz dzenanz force-pushed the IncreaseReviewModuleCoverage branch from d36df41 to e1f7f5c Compare July 20, 2021 18:02
@dzenanz
Copy link
Copy Markdown
Member

dzenanz commented Jul 20, 2021

I rebased and pushed to your branch. Also, I am doing a local build with legacy removed and review module on.

@dzenanz dzenanz force-pushed the IncreaseReviewModuleCoverage branch from e1f7f5c to db7162d Compare July 20, 2021 19:02
@dzenanz
Copy link
Copy Markdown
Member

dzenanz commented Jul 20, 2021

The force-push fixes unused variable warning, and wrong class name test failure. Both were uncovered by local testing.

@dzenanz
Copy link
Copy Markdown
Member

dzenanz commented Jul 20, 2021

If the CI comes back green, this is good to merge. I will do so, unless someone raises an objection or beats me to it 😄

Increase `Review` module classes' code coverage:
- Exercise the basic object methods using the
  `ITK_EXERCISE_BASIC_OBJECT_METHODS` macro.
- Test the Set/Get methods using the `ITK_TEST_SET_GET_VALUE` macro.
- Test the boolean ivars using the `ITK_TEST_SET_GET_BOOLEAN` macro.
@dzenanz dzenanz force-pushed the IncreaseReviewModuleCoverage branch from db7162d to 319fd9e Compare July 20, 2021 19:06
@dzenanz
Copy link
Copy Markdown
Member

dzenanz commented Jul 20, 2021

The last force-push just rebases on current master.

@jhlegarreta
Copy link
Copy Markdown
Member Author

💯 Thanks Dženan.

@dzenanz dzenanz merged commit 230d319 into InsightSoftwareConsortium:master Jul 21, 2021
@jhlegarreta jhlegarreta deleted the IncreaseReviewModuleCoverage branch July 21, 2021 14:06
@jhlegarreta
Copy link
Copy Markdown
Member Author

jhlegarreta commented Jul 23, 2021

Looks like this introduced a regression failure in itkLabelGeometryImageFilterTest:
https://open.cdash.org/viewBuildError.php?onlydeltap&buildid=7354628

In file included from /home/kitware/DashboardsITK/Modules/Nonunit/Review/test/itkLabelGeometryImageFilterTest.cxx:26:0:
/home/kitware/Dashboards/src/ITK/Modules/Nonunit/Review/test/itkLabelGeometryImageFilterTest.cxx: In function 'int LabelGeometryImageFilterTest(std::__cxx11::string, std::__cxx11::string, std::__cxx11::string, std::__cxx11::string, std::__cxx11::string)':
/home/kitware/DashboardsITK/Modules/Core/TestKernel/include/itkTestingMacros.h:69:51: error: 'Superclass' has not been declared
   std::cout << "Name of Superclass = " << object->Superclass::GetNameOfClass() << std::endl;                           \
                                                   ^
[CTest: warning matched] /home/kitware/DashboardsITK/Modules/Core/TestKernel/include/itkTestingMacros.h:69:51: note: in definition of macro 'ITK_EXERCISE_BASIC_OBJECT_METHODS'
   std::cout << "Name of Superclass = " << object->Superclass::GetNameOfClass() << std::endl;                           \
                                                   ^~~~~~~~~~
/home/kitware/DashboardsITK/Modules/Core/TestKernel/include/itkTestingMacros.h:79:28: error: 'Superclass' has not been declared
   if (!std::strcmp(object->Superclass::GetNameOfClass(), #SuperclassName))                                             \
                            ^
[CTest: warning matched] /home/kitware/DashboardsITK/Modules/Core/TestKernel/include/itkTestingMacros.h:79:28: note: in definition of macro 'ITK_EXERCISE_BASIC_OBJECT_METHODS'
   if (!std::strcmp(object->Superclass::GetNameOfClass(), #SuperclassName))                                             \
                            ^~~~~~~~~~

I tried reproducing the issue locally but the test is passing on my Windows 10+VS 2019. The CDash Windows ryzenator site did not complain about it either; only Linux and Mac sites complain about it.

I was hesitant to submit a patch set adding an #include "itkImageToImageFilter.h" as a fix, since it should be already included when calling #include "itkLabelGeometryImageFilter.h", so I'm wondering whether anyone has a better guess.

@dzenanz
Copy link
Copy Markdown
Member

dzenanz commented Jul 23, 2021 via email

@Leengit
Copy link
Copy Markdown
Contributor

Leengit commented Jul 23, 2021

Because Superclass is an alias rather than the actual name of the base class, that could be causing trouble for some compilers. For example, often we have to use the typename keyword to refer to an alias defined with using within a class so that the compiler knows that the alias is a type rather than a data member or member function. So, instead of

object->Superclass::GetNameOfClass()

I might have written

static_cast<const typename decltype(*object)::Superclass *>(object)->GetNameOfClass()

with the explicit typename (and perhaps without the const if we are guaranteed that object won't be const).

@jhlegarreta
Copy link
Copy Markdown
Member Author

jhlegarreta commented Jul 23, 2021

@Leengit thanks for chiming in and for the explanation 👍.

One thing that still I do not understand is why the failure does not happen for each and every class' test where the macro is called.

I do not have a Linux machine on which I would be at ease developing ITK at the moment, so I cannot check whether your proposal would work. So it would be great if someone could check it and submit a PR.

@Leengit
Copy link
Copy Markdown
Contributor

Leengit commented Jul 26, 2021

I've tried my own suggestion static_cast<const typename decltype(*object)::Superclass *>(object)->GetNameOfClass() on my Ubuntu 20.04 machine with gcc-10.3.0 and it does not work. The issue appears to be that decltype(*object) is not well defined during the declaration of object; for example when an (inline) method is defined within a class declaration rather than as a separate definition, which is quite common for ITK's templated classes.

@jhlegarreta
Copy link
Copy Markdown
Member Author

jhlegarreta commented Jul 26, 2021

@Leengit thanks for giving it a try. Unfortunately, I haven't got an alternative proposal. There is still something elusive in the issue; also still puzzled as to why it is not present in virtually all tests.

@dzenanz
Copy link
Copy Markdown
Member

dzenanz commented Aug 3, 2021

I created #2676 to track this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:Coverage Code coverage impacts type:Enhancement Improvement of existing methods or implementation type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants