如何让Rebar在发布目录中运行Common Test?

leg*_*cia 8 erlang rebar common-test

我有一个带有顶级版本目录的Rebar项目,该目录只包含组件应用程序作为依赖项,并包含reltool配置.

我的一些应用程序在test子目录中有Common Test suite ,我可以运行这些测试rebar ct.

现在我想为整个版本创建一个Common Test套件.但是,当我rebar ct skip_deps=true在顶级目录中运行时,我得到:

Command 'ct' not understood or not applicable
Run Code Online (Sandbox Code Playgroud)

如何让Rebar运行我的测试?

leg*_*cia 10

Rebar有三组模块(参见rebar.app):

  • any_dir_modules,适用于项目中的任何目录;
  • app_dir模块,仅适用于包含匹配src/*.app.srcebin/*.app(参见rebar_app_utils:is_app_dir/1)文件的目录; 和
  • rel_dir模块,仅适用于包含reltool.configreltool.config.script(请参阅rebar_rel_utils:is_rel_dir/1)的目录.

rebar_ct模块负责运行Common Test,属于该app_dir类别,因此您的顶级发布目录不符合条件.

您可以通过指定rebar_ct插件来解决此问题,因为插件会绕过模块类别机制.将以下行放入您的rebar.config:

{plugins, [rebar_ct]}.
Run Code Online (Sandbox Code Playgroud)

你会得到:

$ rebar ct skip_deps=true
==> foo (ct)
==> bar (ct)
==> my_rel (ct)
DONE.
Testing src.my_rel: TEST COMPLETE, 0 ok, 0 failed of 0 test cases
Run Code Online (Sandbox Code Playgroud)