
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 <build_dir> - cd <build_dir> - cmake <source_dir> - cmake --build . 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. Best Mike

AMDG On 09/28/2018 02:38 PM, mike via Boost wrote:
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:
You can't. It will complain about a circular dependency.
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.
In Christ, Steven Watanabe

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