我已经为我的应用程序创建了一个Erlang - config描述的配置文件,该文件由多个子应用程序组成,每个子应用程序都有自己的公共测试套件目录。为了构建和测试我使用的钢筋,我的目录结构如下所示
.
├── 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 -外部配置日期中描述的那样,以某种方式将信任加载到公共测试中,但我认为,如果我已经拥有了apps.config
,将会有一种更容易的方法。
更新: ct_run -dir apps/app1/test -pa deps/*/ebin -pa apps/*/ebin -erl_args -config rpm
也按预期工作。我猜问题在于,在为每个应用程序运行测试时,rebar会更改cwd,因此-config rpm
选项不会指向现有文件。反正我也没能找到解决办法。
发布于 2015-05-11 12:21:34
我现在创建了一个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
运行测试了。不管怎么说,如果有人知道我怎么能用钢筋来做这件事,请回答!
https://stackoverflow.com/questions/30161772
复制相似问题