How to pass command line arguments to CTest at run time

I am using CTest and want to pass command line arguments for basic tests at runtime. I know that there are ways to enter command line arguments in a CMake / CTest script, but I want to specify command line arguments at run time and pass these arguments through CTest to the base test.

Is it possible?

+6
source share
2 answers

I'm not sure I fully understand what you want, but I can still give you a way to pass arguments for tests to CTest at runtime.

I will give you an example with CTK (Common Toolkit, https://github.com/commontk/CTK ):

In the dir assembly (for example: CTK-build / CTK-build, this is a superboyle) if I ran: ('-V' for Verbose and '-N' for view mode only)

ctest -R ctkVTKDataSetArrayComboBoxTest1 -V -N 

I get:

 UpdateCTestConfiguration from : /CTK-build/CTK-build/DartConfiguration.tcl Parse Config file:/CTK-build/CTK-build/DartConfiguration.tcl Add coverage exclude regular expressions. Add coverage exclude: /CMakeFiles/CMakeTmp/ Add coverage exclude: .*/moc_.* Add coverage exclude: .*/ui_.* Add coverage exclude: .*/Testing/.* Add coverage exclude: .*/CMakeExternals/.* Add coverage exclude: ./ctkPixmapIconEngine.* Add coverage exclude: ./ctkIconEngine.* UpdateCTestConfiguration from :/CTK-build/CTK-build/DartConfiguration.tcl Parse Config file:/CTK-build/CTK-build/DartConfiguration.tcl Test project /CTK-build/CTK-build Constructing a list of tests Done constructing a list of tests 178: Test command: /CTK-build/CTK-build/bin/CTKVisualizationVTKWidgetsCppTests "ctkVTKDataSetArrayComboBoxTest1" Labels: CTKVisualizationVTKWidgets Test #178: ctkVTKDataSetArrayComboBoxTest1 Total Tests: 1 

You can copy the β€œtest command” to your terminal:

 /CTK-build/CTK-build/bin/CTKVisualizationVTKWidgetsCppTests "ctkVTKDataSetArrayComboBoxTest1" 

And add arguments, for example, "-I" for interactive testing:

 /CTK-build/CTK-build/bin/CTKVisualizationVTKWidgetsCppTests "ctkVTKDataSetArrayComboBoxTest1" "-I" 

Tell me if this helps.

+1
source

matthieu's answer gave me a key to make it work for me.

For my code, I did the following:

Enter the command ctest -V -R TestMembraneCellCrypt -N to get the result:

 ... 488: Test command: path/to/ctest/executable/TestMembraneCellCrypt Labels: Continuous_project_ChasteMembrane Test #488: TestMembraneCellCrypt ... 

Then I copied the Test command and provided the arguments there:

 path/to/ctest/executable/TestMembraneCellCrypt -e 2 -em 5 -ct 10 

I note that the package I use ( Chaste ) is quite large, so things that I don’t know about can happen.

0
source

Source: https://habr.com/ru/post/983223/


All Articles