我为我的应用程序创建了一个配置文件,如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
选项不会指向现有文件。无论如何我无法找到解决方法。
答案 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
运行测试。无论如何,如果有人知道如何用钢筋做这件事,请回答!