在 TeamCity 上构建和测试命令行 Gem
我在 TeamCity 构建环境中测试命令行 gem 时遇到一些问题。
我正在开发一个用于构建各种类型的清单文件的 gem,elf_manifesto。它从命令行运行,我已经成功使用 Cucumber 和真正有用的 Aruba gem 对其进行了测试。在本地,我正在使用 RVM、ruby 1.9.2 开发 Lion MBP。一切都很美好。
当将构建过程转移到工作中的 TeamCity 环境时,就会出现问题。 TeamCity 代理在 Windows 盒子上运行,问题似乎是当从 Aruba 触发命令行可执行文件时,在 Windows 盒子的路径环境中找不到脚本。这是构建日志中的 Cucumber 输出片段。
[13:46:37]: [Scenario: Start manifesto with no parameters] When I run `manifesto`
[13:46:37]: [When I run `manifesto`] ChildProcess::LaunchError: The system cannot find the file specified. (2)
Aruba gem 旨在在运行测试时将可执行文件(位于 bin 目录中)添加到路径中。这在我的本地设置上工作正常,但在 Windows 上失败。我尝试将 RUBYPATH 环境变量添加到 TeamCity 中的构建参数中,但到目前为止还没有成功。
有人有任何指点吗?
提前致谢。
I'm having some trouble testing a command line gem in a TeamCity build environment.
I'm working on a gem for building various types of manifest files, elf_manifesto. It runs from the command line and I've successfully tested it with Cucumber, and the really useful Aruba gem. Locally I'm working on a Lion MBP, using RVM, ruby 1.9.2. Everything's hunky dory.
The problem's arisen when moving the build process to the TeamCity environment at work. The TeamCity agent is running on a windows box and the problem seems to be that when triggering the command line executable from Aruba the script isn't found in the path environment on the windows box. Here's a snippet of Cucumber output from the build log.
[13:46:37]: [Scenario: Start manifesto with no parameters] When I run `manifesto`
[13:46:37]: [When I run `manifesto`] ChildProcess::LaunchError: The system cannot find the file specified. (2)
The Aruba gem is meant to take care of adding the executable (which is in the bin dir) to the path when running the tests. This works fine on my local set up, but fails on Windows. I've tried adding a RUBYPATH environment variable to the build parameters in TeamCity, but so far no luck.
Does anyone have any pointers?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据我的经验,Aruba 不会将您的 gem 从
bin/
添加到路径中。即使在基于 UNIX 的项目上,我也必须自己完成:在
env.rb
中:话虽如此,我从未让 Aruba 在 Windows 上像在 UNIX 上那样工作。
为了帮助诊断,请在您的功能上使用
@announce
标记(这会导致打印 stderr 和 stdout),甚至可能在自定义步骤中放入您自己的日志语句。In my experience, Aruba does not add your gem from
bin/
into the path. Even on UNIX-based projects, I've had to do it myself:In
env.rb
:That being said, I have never gotten Aruba to work on Windows the same way as it did on UNIX.
To help diagnose, make use of the
@announce
tag on your features (which causes stderr and stdout to be printed), and possibly even drop in your own log statements in your custom steps.在 Windows 中,仅当具有某些扩展名的文件(如
.COM
、.EXE
(及其他))才可执行。您可以将
manifesto
更改为ruby manifesto
,就像使用manifesto
的正确路径一样,它应该在 Windows 上工作。如果你也想在 Unix 平台上工作,你需要在 Aruba 的
support\env.rb
中进行如下更改希望它有帮助
In Windows, only if file with some extension like
.COM
,.EXE
(and others) is executable.You can change
manifesto
toruby manifesto
like with correct path tomanifesto
, it should work on windows.If you want to work in Unix platform also, you need to change in
support\env.rb
for Aruba like belowHope it helps
您应该知道,Aruba 运行它测试的应用程序,并在其自己的工作目录 (awd) 中创建所有本地输出。 awd 默认为 tmp/aruba,并由 Aruba 在每个场景开始时清除和创建。不过,最后一个 Scenario 创建的内容会留在 awd 中供您检查。
解决方案 #1
Aruba 会在每个 Cucumber 场景持续时间内自动将项目的 bin 目录添加到 PATH 环境变量中。
您可以在项目根目录下创建一个
bin
目录,然后将二进制文件复制到那里解决方案 #2
您可以使用 aruba-jbb,它提供了
@no-aruba-tmpdir
标记来处理这种情况。You should be aware that Aruba runs the application it tests and creates all local output in its own working directory (awd). The awd defaults to tmp/aruba and is purged and created by Aruba at the beginning of every Scenario. However, the contents created by the last Scenario are left in the awd for your inspection.
Solution #1
Aruba will automatically add the bin directory of your project to the PATH environment variable for the duration of each Cucumber scenario.
You can create a
bin
dir under your project root, and copy you binaries thereSolution #2
You can use aruba-jbb, which provide a
@no-aruba-tmpdir
tag to handle this case.