如何获得特定耙任务的帮助?

问题描述 投票:6回答:3

是否有针对单个耙任务的标准帮助命令?

[rake -h显示耙的选项。

[rake -D描述了瑞克任务。

[rake mytask运行我的任务。

是否有类似rake -h mytask的东西来描述我的任务,并列出其可选和/或必需的参数?

例如,以下代码将在rails中运行单个测试:

rake test TEST=path_to_test

我如何发现TEST = path_to_test是瑞克测试的可选参数?

ruby-on-rails ruby rake rake-task
3个回答
4
投票

命令rake -D test在我的系统上不存在。相反,您可以使用

# list test command with details
rake test -D 

# list all test tasks with description
rake test -T

# list all test tasks even without description(Recommened)
rake test -T -A

1
投票

-D接受格式。因此您可以使用它。

示例:

rake -D db

rake -D db:migrate

0
投票

TEST=path_to_test正在设置环境变量。因此,如果rake -D test没有提供有关rake任务中如何使用环境变量的任何信息,则您必须求助于源代码或替代文档。再看一下源代码,Rails瑞克测试中只检查了两个环境变量:TESTTESTOPTS,后者在与Ruby打包在一起的Minitest中使用,并在Rails测试中使用。

Rails中的文档提供了一个示例:rake test TEST=path/to/test.rb TESTOPTS="--name=test_something"

其他选项包括--color--fail-fast(参考:https://github.com/rails/rails/blob/df74da026b9210a9cb6258e7029cafcc02aa6d15/guides/source/testing.md

((我已经为以后像我这样的人添加了这个答案。)

或者,您可以在rake之外运行测试。不确定是否可以加快速度。

例如,可以通过以下方式在MailLayoutTest中运行“显式类布局”测试:ruby -Itest test/mail_layout_test.rb -n test_explicit_class_layout

(参考:https://github.com/rails/rails/blob/2f1fefe456932a6d7d2b155d27b5315c33f3daa1/guides/source/contributing_to_ruby_on_rails.md

© www.soinside.com 2019 - 2024. All rights reserved.