Building and Testing Command Line Gem on TeamCity

1k views Asked by At

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.

3

There are 3 answers

2
davetron5000 On

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.

0
Quanlong On

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.

1
Larry Cai On

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