Boost logo

Boost :

Subject: Re: [boost] [test] How to execute shell commands
From: Peter Dimov (lists_at_[hidden])
Date: 2018-09-28 21:07:30


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.testing)

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 ;


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk