在 TeamCity 上构建和测试命令行 Gem

发布于 2024-12-28 02:37:09 字数 852 浏览 0 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

南风几经秋 2025-01-04 02:37:09

根据我的经验,Aruba 不会将您的 gem 从 bin/ 添加到路径中。即使在基于 UNIX 的项目上,我也必须自己完成:

env.rb 中:

PROJECT_ROOT = File.join(File.dirname(__FILE__),'..','..')
ENV['PATH'] = "#{File.join(PROJECT_ROOT,'bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"

话虽如此,我从未让 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:

PROJECT_ROOT = File.join(File.dirname(__FILE__),'..','..')
ENV['PATH'] = "#{File.join(PROJECT_ROOT,'bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"

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.

初见终念 2025-01-04 02:37:09

在 Windows 中,仅当具有某些扩展名的文件(如 .COM.EXE(及其他))才可执行。

您可以将 manifesto 更改为 ruby manifesto,就像使用 manifesto 的正确路径一样,它应该在 Windows 上工作。

如果你也想在 Unix 平台上工作,你需要在 Aruba 的 support\env.rb 中进行如下更改

require 'aruba/cucumber'
module ArubaOverrides
  def detect_ruby(cmd)
    processor, platform, *rest = RUBY_PLATFORM.split("-")
    #puts platform
    if platform =~ /w32$/ && cmd =~ /^manifesto /
      "ruby -I../../lib -S ../../bin/#{cmd}"
    else
      "#{cmd}"
    end
  end
end

World(ArubaOverrides)

希望它有帮助

In Windows, only if file with some extension like .COM,.EXE (and others) is executable.

You can change manifesto to ruby manifesto like with correct path to manifesto, 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 below

require 'aruba/cucumber'
module ArubaOverrides
  def detect_ruby(cmd)
    processor, platform, *rest = RUBY_PLATFORM.split("-")
    #puts platform
    if platform =~ /w32$/ && cmd =~ /^manifesto /
      "ruby -I../../lib -S ../../bin/#{cmd}"
    else
      "#{cmd}"
    end
  end
end

World(ArubaOverrides)

Hope it helps

趁微风不噪 2025-01-04 02:37:09

您应该知道,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 there

Solution #2

You can use aruba-jbb, which provide a @no-aruba-tmpdir tag to handle this case.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文