【问题标题】:Rebar eunit skips all app tests if root app is not included如果不包含根应用程序,Rebar eunit 会跳过所有应用程序测试
【发布时间】:2014-04-12 16:04:18
【问题描述】:

我的问题是我无法在不包含根应用程序的情况下为单个应用程序或模块运行 eunit 测试。我的目录布局看起来有点像这样:

├── apps
│   ├── app1
│   └── app2
├── deps
│   ├── amqp_client
│   ├── meck
│   ├── rabbit_common
│   └── ranch
├── rebar.config
├── rel
└── src
    ├── rootapp.app.src
    ├── rootapp.erl
    ├── rootapp.erl
    └── rootapp.erl

现在,我能做的是:

$ rebar eunit skip_deps=true

它为所有应用程序运行测试。另外,我可以这样做:

$ cd apps/app1/
$ rebar eunit skip_deps=true

它为 app1 运行测试(我在 apps/app1 中也有一个 rebar.config。

但是,如果我尝试

$ rebar eunit skip_deps=true apps=app1

……什么都没有。没有输出。尝试详细模式给了我:

$ rebar -vv eunit skip_deps=true apps=app1
DEBUG: Consult config file "/Users/myuser/Development/erlang/rootapp/rebar.config"
DEBUG: Rebar location: "/usr/local/bin/rebar"
DEBUG: Consult config file "/Users/myuser/Development/erlang/erlactive/src/rootapp.app.src"
DEBUG: Skipping app: rootapp

当我包含根应用程序时,它可以工作:

$ rebar eunit skip_deps=true apps=rootapp,app1

尽管我实际上想测试app1,而不是rootapp,这真的很不舒服,因为SublimeText 2 的SublimeErl 插件总是会将应用程序设置为包含被测模块的应用程序in. 所以测试总是会失败,因为实际上根本不会运行任何测试。

长话短说:我可以在任何 rebar.config 文件中进行配置,以便在不包括根应用的情况下运行 /apps 中的一个应用的测试吗?

【问题讨论】:

    标签: erlang rebar eunit


    【解决方案1】:

    我个人更喜欢将主应用程序放入 apps 中自己的 OTP 兼容文件夹中。只需在apps 中创建一个新应用rootapp 并将其包含在您的rebar.config 中:

    {sub_dirs, ["apps/app1",
                "apps/app2",
                "apps/rootapp"]}.
    

    您可能还必须将 apps 目录包含到您的 lib 路径中:

    {lib_dirs, ["apps"]}.
    

    您可能想看看 Fred Herbert 的博文 “As bad as anything else”

    有了这个设置,你应该可以运行了:

    rebar skip_deps=true eunit 
    

    它将运行 apps 中应用程序的所有 eunit 测试。

    【讨论】:

    • 我认为需要有一个“根应用程序”,但这是有道理的。感谢分享 Fred 的帖子。
    猜你喜欢
    • 2012-02-28
    • 2012-10-29
    • 1970-01-01
    • 2014-05-27
    • 2015-01-21
    • 2020-06-22
    • 2014-11-03
    • 2012-11-09
    • 2011-09-04
    相关资源
    最近更新 更多