3

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.

DDubyah
  • 53
  • 7

3 Answers3

1

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.

davetron5000
  • 24,123
  • 11
  • 70
  • 98
  • Cheers @davetron5000. Aruba does that for you in the latest version, but I've tried it manually too with no joy I'm afraid. The announce tag was really useful, thanks. I've just tried passing in the RUBYPATH env variable and confirmed it's set in the logs. In theory, the RUBYPATH should be appended to the PATH when searching for executable scripts. Still didn't do the job unfortunately. Do I need to do anything special to make the file executable on Windows? – DDubyah Jan 24 '12 at 10:02
  • I'm not sure; I don't use windows much and don't have regular access to it, but I believe there was an option when installing Ruby to associate .rb files with Ruby. I suppose you could try making a .bat file that does "ruby your_app". Cheesy, but it might work? – davetron5000 Jan 26 '12 at 17:32
0

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.

Quanlong
  • 24,028
  • 16
  • 69
  • 79
0

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

Larry Cai
  • 55,923
  • 34
  • 110
  • 156
  • Ahh, that makes sense. Thanks Larry. I think davetron5000's suggestion to use a .bat file above, alongside yours may do the trick. Now I can't wait to try it. I'll let you know how I get on later in the week. – DDubyah Mar 13 '12 at 17:42