Does the boost unit test frame work provide a way to write a test that executes a couple of shell commands?
Specifically, I want to write a test that compiles a cmake project:
https://github.com/boostorg/vmd/pull/4
https://github.com/boostorg/preprocessor/pull/20
what I need to do for that is essentially (on Linux):
- mkdir
-----Original Message----- From: Boost
On Behalf Of Raffi Enficiaud via Boost Sent: Friday, September 28, 2018 10:09 PM On 28.09.18 10:15, Mike Dev via Boost wrote:
Does the boost unit test frame work provide a way to write a test that executes a couple of shell commands?
Specifically, I want to write a test that compiles a cmake project:
Nope, you have to use cmake tools for that.
I'm not asking b2 / boost test to understand and process a cmake file. Just to execute some shell commands and run a executable that is installed on the system. Best Mike
AMDG On 09/28/2018 02:38 PM, mike via Boost wrote:
-----Original Message----- From: Boost
On Behalf Of Raffi Enficiaud via Boost Sent: Friday, September 28, 2018 10:09 PM On 28.09.18 10:15, Mike Dev via Boost wrote:
Does the boost unit test frame work provide a way to write a test that executes a couple of shell commands?
Specifically, I want to write a test that compiles a cmake project:
Nope, you have to use cmake tools for that.
I'm not asking b2 / boost test to understand and process a cmake file. Just to execute some shell commands and run a executable that is installed on the system.
Your question was unclear, as it sounded like you were asking about the Boost.Test library, which has no specific integration with b2 beyond any other separately compiled Boost library. To run shell commands with b2 see: https://boostorg.github.io/build/manual/develop/index.html#bbv2.builtins.raw In Christ, Steven Watanabe
Mike Dev wrote:
Of course I can write a cpp program that uses std::system to execute those commands but I was wondering if there was a more direct way to do it.
That would be the way. You can pass input files to the `run` rule: run my_cmake_test.cpp : : myfile1 myfile2 ; (https://boostorg.github.io/build/manual/develop/index.html#bbv2.builtins.tes...) If these are targets, they will refer to files in the bindir; if not, to source dir. Relative paths are relative to the current Jamfile. I'm not sure if you could do run my_cmake_test.cpp : : my_cmake_test ; to obtain a path to my_cmake_test.exe though. It would probably be easier to infer the directory corresponding to where the test executable is placed from argv[0] (but I haven't tried that this works.) If not, you could perhaps use a dummy obj target obj cmake_test_obj : cmake_test_source.cpp ; and then run my_cmake_test.cpp : : cmake_test_obj ;
AMDG On 09/28/2018 03:07 PM, Peter Dimov via Boost wrote:
Mike Dev wrote:
Of course I can write a cpp program that uses std::system to execute those commands but I was wondering if there was a more direct way to do it.
That would be the way.
You can pass input files to the `run` rule:
run my_cmake_test.cpp : : myfile1 myfile2 ;
(https://boostorg.github.io/build/manual/develop/index.html#bbv2.builtins.tes...)
If these are targets, they will refer to files in the bindir; if not, to source dir. Relative paths are relative to the current Jamfile.
I'm not sure if you could do
run my_cmake_test.cpp : : my_cmake_test ;
You can't. It will complain about a circular dependency.
to obtain a path to my_cmake_test.exe though. It would probably be easier to infer the directory corresponding to where the test executable is placed from argv[0] (but I haven't tried that this works.)
You can probably get away with it in this case, but this method isn't reliable in general. Maybe Boost.Process or Boost.Filesystem has something? I remember seeing code for this somewhere... Oh here it is: https://github.com/boostorg/build/blob/develop/src/engine/jam.c#L702 That's not really reusable, however.
If not, you could perhaps use a dummy obj target
obj cmake_test_obj : cmake_test_source.cpp ;
and then
run my_cmake_test.cpp : : cmake_test_obj ;
In Christ, Steven Watanabe
Steven Watanabe wrote:
It would probably be easier to infer the directory corresponding to where the test executable is placed from argv[0] (but I haven't tried that this works.)
You can probably get away with it in this case, but this method isn't reliable in general.
I know, but if b2 passes the correct argv[0], it will be reliable in this specific case. -)
Steven Watanabe wrote:
Maybe Boost.Process or Boost.Filesystem has something?
Stack Overflow says https://www.boost.org/doc/libs/1_68_0/doc/html/boost/dll/program_location.ht...
participants (5)
-
Mike Dev
-
mike.dev@gmx.de
-
Peter Dimov
-
Raffi Enficiaud
-
Steven Watanabe