[vtk-developers] Single test file used for more than one test?
Cory Quammen
cory.quammen at kitware.com
Mon Sep 29 11:19:01 EDT 2014
Just to follow up, I put in some changes in VTK that enable you to
specify a test name in front of the test source file in
vtk_add_test_*.
Author: Cory Quammen <cory.quammen at kitware.com> 2014-09-12 09:00:52
Committer: Cory Quammen <cory.quammen at kitware.com> 2014-09-15 09:50:11
Enabled easier specification of custom test name
A custom test name can be specified by giving a name followed by a
comma before the test file name, .e.g.,
CustomTestName,TestSource.cxx
CustomTclTestName,TestSource.tcl
CustomPyTestName,TestSource.py
Support for custom test names is available in:
vtk_add_test_cxx
vtk_add_test_mpi
vtk_add_test_python
vtk_add_test_python_mpi
vtk_add_test_tcl
This way to specify a custom name is more straightforward and less
verbose than the vtk_test_prefix mechanism or custom calls to
ExternalData_add_test.
Example:
vtk_add_test_cxx(${vtk-module}CxxTests tests
TestClass,TestClass.cxx --arg0 --arg1 --arg2
)
vtk_add_test_cxx(${vtk-module}CxxTests tests
TestClass2,TestClass.cxx --arg3 --arg4 --arg5
)
The baseline for a test with custom name 'TestClass2' is expected to
be 'TestClass2.png'.
Note that currently, every test defined from the same source file
must be defined in a separate call to vtk_add_test_*. For example,
vtk_add_test_cxx(${vtk-module}CxxTests tests
TestClass,TestClass.cxx --arg0 --arg1 --arg2
TestClass2,TestClass.cxx --arg3 --arg4 --arg5
)
does not work correctly - it passes --arg0 through --arg5 to both the
TestClass and TestClass2 test instances. Instead, tests with arguments
must be specified with different calls to vtk_add_test_*.
Change-Id: I88fabc4c5eca5898e257887f3e161fd9c4ee0864
On Thu, Sep 11, 2014 at 5:38 PM, Cory Quammen <cory.quammen at kitware.com> wrote:
> Burlen,
>
> Thanks for the pointer. I like that your example is explicit in what
> is being passed to the tests.
>
> To use the more "magic" vtk_add_test_cxx() function, it turns out you
> can do the following:
>
> set(vtk_test_prefix Second)
> vtk_add_test_cxx(${vtk-module}CxxTests tests
> SurfacePlusEdges.cxx --arg1 --arg2 --arg3
> )
> unset(vtk_test_prefix)
>
> And this will define a test named $(vtk-module}Cxx-SecondSurfacePlusEdges.
>
> In it's current form, this test will point to a baseline named
> SurfacePlusEdges.png. To point it to a baseline for just this test, I
> had to modify vtkTestingMacros.cmake to include vtk_test_prefix in the
> baseline path. The modifications are on gerrit:
>
> http://review.source.kitware.com/#/t/4648/
>
> This specifies the baseline file name as SecondSurfacePlusEdges.png.
>
> Reviews for this topic are appreciated :-)
>
> I'm not sure if I'm thrilled with defining the test name this way. It
> would be nicer to do something like
>
> vtk_add_test_cxx(${vtk-module}CxxTests tests
> SurfacePlusEdges.cxx --arg0 --arg1 --arg2
> SurfacePlusEdges.cxx,CUSTOM_NAME SurfacePlusEdges2 --arg3 --arg4 --arg5
> )
>
> where if CUSTOM_NAME is specified, the first argument is the test name.
>
> Thanks,
> Cory
>
> On Thu, Sep 11, 2014 at 11:22 AM, Burlen Loring <burlen.loring at gmail.com> wrote:
>> Hi Cory,
>>
>> That's how the surface LIC tests are written. Take a look at
>> VTK/Rendering/LIC/Testing/Cxx/CMakeLists.txt
>>
>> Burlen
>>
>>
>> On 09/11/2014 08:07 AM, Cory Quammen wrote:
>>>
>>> Hi all,
>>>
>>> I'm writing a VTK test that takes some command-line arguments to
>>> control some options in a filter. What I would like to do is define
>>> several tests in the CMakeLists.txt file that run this same code but
>>> which pass different arguments in through argv[].
>>>
>>> I haven't found an example of this kind of test in VTK. Most tests are
>>> defined by passing to vtk_add_test_cxx the name of the source file for
>>> the test.
>>>
>>> Can anyone point me to an example similar to what I want to do?
>>>
>>> Thanks!
>>> Cory
>>> _______________________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://public.kitware.com/mailman/listinfo/vtk-developers
>>>
>>
More information about the vtk-developers
mailing list