MantisBT - CMake
View Issue Details
0013887CMakeCTestpublic2013-02-02 17:512013-12-02 08:51
don bright 
Rolf Eike Beer 
normalminoralways
closedfixed 
AllAllAll
CMake 2.8.10.2 
CMake 2.8.12CMake 2.8.12 
0013887: CTEST_CUSTOM_POST_TEST doesn't allow command line arguments anymore
CTEST_CUSTOM_POST_TEST used to allow the user to run a command with arguments passed to it.

It doesn't allow command line arguments anymore.

Write a CTestCustom.cmake file that does this:

set(CTEST_CUSTOM_POST_TEST "echo hello")


It should actually print 'hello' after the tests are run.

If you use an older version of ctest, this will be fine.
If you use a newer version, you will get an error when you run ctest.

We are having issues with this with OpenSCAD:

https://github.com/openscad/openscad/issues/260 [^]

And a recent patch to cmake seems to be the cause

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6187876dea89618044e200808bcae75a18bd4043 [^]

Thanks

No tags attached.
Issue History
2013-02-02 17:51don brightNew Issue
2013-02-02 18:12don brightNote Added: 0032187
2013-02-03 03:58Rolf Eike BeerNote Added: 0032188
2013-02-03 07:28don brightNote Added: 0032189
2013-07-16 07:22Baptist BENOISTNote Added: 0033546
2013-07-16 07:22Baptist BENOISTNote Edited: 0033546bug_revision_view_page.php?bugnote_id=33546#r1215
2013-07-16 08:14Baptist BENOISTNote Added: 0033548
2013-07-16 09:19Mathias GaunardNote Added: 0033552
2013-07-16 12:09Baptist BENOISTNote Added: 0033558
2013-07-23 02:25Rolf Eike BeerNote Added: 0033578
2013-07-23 07:57Mathias GaunardNote Added: 0033579
2013-07-23 09:13Robert MaynardNote Added: 0033580
2013-07-25 05:03Baptist BENOISTNote Added: 0033599
2013-07-27 16:12Rolf Eike BeerNote Added: 0033621
2013-07-27 16:12Rolf Eike BeerAssigned To => Rolf Eike Beer
2013-07-27 16:12Rolf Eike BeerStatusnew => resolved
2013-07-27 16:12Rolf Eike BeerResolutionopen => fixed
2013-07-27 16:12Rolf Eike BeerFixed in Version => CMake 2.8.12
2013-07-27 16:12Rolf Eike BeerTarget Version => CMake 2.8.12
2013-12-02 08:51Robert MaynardNote Added: 0034660
2013-12-02 08:51Robert MaynardStatusresolved => closed

Notes
(0032187)
don bright   
2013-02-02 18:12   
Actually now that I think about it is probably breaks CTEST_CUSTOM_PRE_TEST as well, although I haven't tested.
(0032188)
Rolf Eike Beer   
2013-02-03 03:58   
I'm pretty sure it will.

Until now it would have not worked if the program passed was something like "c:/program files/...". As a workaround I would say use a script as post-command, although that may not really work if the command is composed from variables.
(0032189)
don bright   
2013-02-03 07:28   
my question is can a script be made executable on all platforms?

a .py file for example... will it 'execute' under windows, linux, and mac, just by itself when passed to CTEST_CUSTOM_POST_TEST('posttest.py') ? how does it know which python executable it will be using?

we were using something like this '${PYTHON_EXECUTABLE} posttest.py ${CMAKE_CURRENT_BIN_DIR}'... but that is using an argument.
(0033546)
Baptist BENOIST   
2013-07-16 07:22   
@Rolf Eike Beer:
I must understand correctly the reasons you made such a commit before pushing a reversal of it 6187876dea89618044e200808bcae75a18bd40 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6187876dea89618044e200808bcae75a18bd40 [^]

What exactly was the problem which forced you to make such a commit?

I think that a command such as C:/Dir with spaces/any.exe (per example) worked before your commit if quoted properly in its definition:
set (CTEST_CUSTOM_POST_TEST "\"C:/Dir with spaces/any.exe\" one arg")

As the documentation states http://cmake.org/Wiki/CMake/Testing_With_CTest#Customizing_CTest, [^] the properties CTEST_CUSTOM_POST_TEST, CTEST_CUSTOM_PRE_TEST, CTEST_CUSTOM_POST_MEMCHECK and CTEST_CUSTOM_PRE_MEMCHECK can be used to execute a complete command, not simply the path of an executable.
Considering this, the commit that I would like to revert should not have been coded and merged to the official repository because the functionality is no more working as expected.

@don bright:
Your workaround may be useful to me if I am wrong in my commit reversal attempt; thank you for this.

(0033548)
Baptist BENOIST   
2013-07-16 08:14   
For more information about my motivations on this problem, here is the related issue for the distribution on which I am working on: https://github.com/NixOS/nixpkgs/issues/762 [^]
(0033552)
Mathias Gaunard   
2013-07-16 09:19   
I think the commit in question tried to change the code so that the following code:
SET(CTEST_CUSTOM_POST_TEST "/path\\ with\\ spaces/lapack_testing.py -s -d TESTING")

Should be written like so instead:
SET(CTEST_CUSTOM_POST_TEST "/path with spaces/lapack_testing.py" -s -d TESTING)

Obviously this was done wrong, as even that doesn't work.
The suggested change, if implemented correctly, would also prevent from having several commands in CTEST_CUSTOM_POST_TEST. I think the person who did the change didn't fully understand how this property was supposed to be used.

Reverting to the old behaviour is the correct fix IMHO. For this property, the responsibility of escaping slashes lies with the user. To change this, we'd have to introduce COMMAND prefixes like execute_process.
(0033558)
Baptist BENOIST   
2013-07-16 12:09   
@Mathias Gaunard: It's clearer now. This comfort my opinion on a reversal of the problematic commit.
Also, I totally agree with you about the COMMAND prefix already used in execute_process. To my mind, CTEST_CUSTOM_POST_TEST and similar properties should have been macros having the same behavior than execute_command.
(0033578)
Rolf Eike Beer   
2013-07-23 02:25   
Would a list (separated by ";") work for you? So you would set the property to be "/some path/program;arg;other arg"?
(0033579)
Mathias Gaunard   
2013-07-23 07:57   
Isn't
"/some path/program;arg;other arg"
just another way to write
"/some path/program" arg "other arg"
?

This still has the obvious issue that you cannot have multiple commands.
(0033580)
Robert Maynard   
2013-07-23 09:13   
I believe the original behavior of being able to run a single command like "python pretty_print.py --color" should be valid. I think treating the full string as a single path is undesired behavior.
(0033599)
Baptist BENOIST   
2013-07-25 05:03   
@Rolf: I do not agree with your proposal of using "/some path/program;arg;other arg" as it prevents from executing multiple commands.

Ultimately, and that how CMake worked before, such a command string should work:
"echo hello world>/path\\ with\\ spaces/file;echo done"
or on Windows (under the responsibility of the end-developer)
"echo hello world>\"C:/path with spaces/file\";echo done"
the following one should also be acceptable:
"echo hello world>/path\\ with\\ spaces/file" "echo done"

As previously said, the most convenient solution for me would be to have the exact same behavior than the execute_process macro which combines the best of both needs. Until such a change is not being released, I would prefer to keep the previous one by reverting the commit 6187876dea89618044e200808bcae75a18bd40.

@Mathias:
> Isn't
> "/some path/program;arg;other arg"
> just another way to write
> "/some path/program" arg "other arg"
> ?
Accordingly to the CMake syntax guidelines, yes it is : http://www.cmake.org/cmake/help/syntax.html [^]
(0033621)
Rolf Eike Beer   
2013-07-27 16:12   
Fix merged to next:

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c0756b6dd67b7f2e113dafde398cec597537068c [^]

This also fixes a testcase that would fail on a path with spaces now, so exactly your use case is tested now as I also added command line args to that pre and post commands.
(0034660)
Robert Maynard   
2013-12-02 08:51   
Closing resolved issues that have not been updated in more than 4 months.