Boost logo

Boost :

Subject: Re: [boost] [test] How to execute shell commands
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2018-09-28 21:30:49


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.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 ;
>

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


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