[erlang-questions] Paths in Common Test app.config

Roger Lipscombe roger@REDACTED
Fri Nov 17 21:06:37 CET 2017


That doesn't seem to be what I want. Let me clarify...

I run my tests with "rebar3 ct", and I have an app.config file
containing the following (for example):

[{my_app, [{cert_path, "relative/path/to/cert.crt"}]}].

It can't be an absolute path, because the project might be checked out
in different locations on different machines.

In my suite, I run my application as follows:

application:ensure_started(my_app)

I have, in my application:

CertPath = application:get_env(my_app, cert_path)

But, when "rebar3 ct" runs my test, the current directory is set to
somewhere like "/home/roger/Projects/my_app/_build/test/logs/ct_run.nonode@REDACTED/",
which means that these relative paths are wrong, and my application
doesn't start correctly.

When using rebar3, or CT itself, how do I control the initial working
directory for the suite, so that I can put my cert files in a sensible
location, and refer to them with relative paths?

I'm considering using file:set_cwd(?config(data_dir, Config) ++ "/..")
in each suite's init_per_testcase, but that feels awkward.

To reiterate: I'm not trying to configure the test. I'm trying to
configure the application under test.

On 17 November 2017 at 19:50, Éric Pailleau <eric.pailleau@REDACTED> wrote:
> Hi,
>
> Use config to set external things available
>
> http://erlang.org/doc/apps/common_test/config_file_chapter.html#id84119
>
> Regards
>
>



More information about the erlang-questions mailing list