3

I have created a configuration file as described in Erlang -- config for my application that consists of multiple sub-apps of which each has its own Common Test suites directory. For building and testing I use rebar, my directory structure looks like this

.
├── apps
│   ├── app1
│   │   ├── ebin
│   │   └── src
│   ├── app2
│   │   ├── ebin
│   │   ├── logs
│   │   ├── rebar.config
│   │   ├── src
│   │   └── test
│   ├── ...
├── deps
├── rebar.config
├── apps.config

where apps.config contains the configuration for all apps. When I start my VM with erl -pa deps/*/ebin -pa apps/*/ebin -config apps everything works fine. I've added {ct_extra_params, "-erl_args -config rpm"}. to my rebar.config but when I run rebar ct an error occurs when application:get_env/1,2 is called.

If it is not possible to do this with rebar, it would also be possible to use make instead if someone could tell me how I can accomplish it there. I know that I can somehow load configs into Common Test as described in Erlang -- External Configuration Date but I thought there would be an easier way if I already have apps.config.

Update: ct_run -dir apps/app1/test -pa deps/*/ebin -pa apps/*/ebin -erl_args -config rpm also works as expected. I guess the problem is that rebar changes the cwd when running the tests for each application and therefore the -config rpm option does not point to a existing file. I was anyway not able to find a workaround.

Luis
  • 201
  • 3
  • 11

1 Answers1

0

I now created a Makefile that solves the problem for me:

SUBDIRS = ./apps/app1 \
    ./apps/app2 \
    ./apps/app3

all: compile

compile:
    rebar compile

test:
    for dir in $(SUBDIRS); do \
        mkdir -p $$dir/logs; \
        ct_run -dir $$dir -logdir $$dir/logs -pa deps/*/ebin -pa apps/*/ebin -erl_args -config rpm; \
    done

.PHONY: all compile test

Now I can run the tests with make test. Anyway, if anyone knows how I can do this with rebar, please answer!

Luis
  • 201
  • 3
  • 11