使用钢筋将Erlang配置文件(用于多个应用程序)应用于Common Test

时间:2015-05-11 07:21:59

标签: configuration erlang rebar common-test

我为我的应用程序创建了一个配置文件,如Erlang -- config所述,该应用程序由多个子应用程序组成,每个子应用程序都有自己的Common Test suites目录。对于构建和测试我使用rebar,我的目录结构看起来像这样

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

其中apps.config包含所有应用的配置。当我用erl -pa deps/*/ebin -pa apps/*/ebin -config apps启动我的VM时,一切正常。我已将{ct_extra_params, "-erl_args -config rpm"}.添加到rebar.config,但当我运行rebar ct时,调用application:get_env/1,2时会出错。

如果用钢筋不可能做到这一点,那么如果有人可以告诉我如何在那里完成它,也可以使用make。我知道我可以按照Erlang -- External Configuration Date中的描述以某种方式将配置加载到Common Test中,但我认为如果我已经拥有apps.config,那么会有更简单的方法。

更新: ct_run -dir apps/app1/test -pa deps/*/ebin -pa apps/*/ebin -erl_args -config rpm也可按预期工作。我想问题是,在为每个应用程序运行测试时,rebar会更改cwd,因此-config rpm选项不会指向现有文件。无论如何我无法找到解决方法。

1 个答案:

答案 0 :(得分:0)

我现在创建了一个Makefile来解决我的问题:

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

现在我可以使用make test运行测试。无论如何,如果有人知道如何用钢筋做这件事,请回答!

相关问题