Boost logo

Boost-Build :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2006-02-14 07:23:54


Hi Jaroslav,

> Actually, I don't need to set it globally. It is enough for me to set it
> just for a unit test process invoked by bjam. I thought of something like
> this:
>
> rule set-env-var ( properties * )
> {
> local variant = [ feature.get-values <variant> : $(properties) ]
> #something like: set MY_ENV_VAR =/some_dir/$(variant)
> }
>
> unit-test my-test
>
> : test.cpp
> : <conditional>@set-env-var
>
> ;
>
> Is something like this achievable?

Try this:

  import testing ;
  import feature ;

  rule set-env-var ( properties * )
  {
      local v = [ feature.get-values <variant> : $(properties) ] ;
      return <testing.launcher>MY_ENV_VAR=/some/dir/$(v) ;
  }

  unit-test a : a.cpp : <conditional>@set-env-var ;

Running this, I get:

  testing.unit-test bin/gcc/debug/a.passed

    MY_ENV_VAR=/some/dir/debug bin/gcc/debug/a
                && touch bin/gcc/debug/a.passed

which does the right effect on Unix. For windows you might need to use
"set ..... &&" as the value of <testing.launcher>

- Volodya


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk