RSpec through Ant

Hello,

I'm currently trying to get RSpec running through Ant to have more configuration and flexibility.
I've managed to fire up RSpec properly with Ant now, but I don't succeed in getting all output back into TeamCity.

This is my build.xml:

<?xml version="1.0"?>
<project name="rubycas" default="init">
     <description>
         This buildfile is used to build the RubyCAS project under TeamCity and run the required tasks to validated
         whether the project is stable and fully functional.
     </description>
     <property name="test_type" value="cucumber" />
     <target name="init">
         <echo message="##teamcity[testStarted name='Rubycas']" />
         <condition property="cucumberBool">
             <equals arg1="${test_type}" arg2="cucumber" />
         </condition>
         <condition property="rspecBool">
             <equals arg1="${test_type}" arg2="rspec" />
         </condition>
     </target>
     <target name="rspec" if="rspecBool" depends="init">
         <exec executable="rspec" outputproperty="result">
             <arg value="--require teamcity/spec/runner/formatter/teamcity/formatter" />
             <arg value="--format Spec::Runner::Formatter::TeamcityFormatter" />
         </exec>
         <echo message="${result}" />
     </target>
     <target name="cucumber" if="cucumberBool" depends="init">
         <exec executable="cucumber" outputproperty="result">
             <arg value="--format junit" />
             <arg value="--out results" />
             <arg value="features" />
         </exec>
         <echo message="${result}" />
     </target>
</project>

How can I get the result from RSpec into TeamCity?
1 comment
Comment actions Permalink

Ok,

managed to get further with this, and get output, but its not working as expected, because of the TeamCity formatter.
I would like to attach the TeamCityFormatter to my RSpec and Cucumber tasks, so I tried this:

<?xml version="1.0"?>
<project name="rubycas" default="init">
    <description>
        This buildfile is used to build the RubyCAS project under TeamCity and run the required tasks to validated
        whether the project is stable and fully functional.
    </description>
    <property name="test_type" value="cucumber" />
    <target name="init">
       <echo message="##teamcity[message text='starting Rubycas tests']" />
    </target>
    <target name="rspec" depends="init">
        <echo message="##teamcity[message text='Starting RSpec' timestamp='yyyy-MM-dd HH:mm:ss']" />
        <exec executable="rspec" outputproperty="result">
            <arg value="--require teamcity/spec/runner/formatter/teamcity/formatter" />
            <arg value="--format Spec::Runner::Formatter::TeamcityFormatter" />
        </exec>
        <echo message="${result}" />
    </target>
    <target name="cucumber" depends="init">
       <exec executable="cucumber" outputproperty="result">
            <arg value="--format junit" />
            <arg value="--out results" />
            <arg value="features" />
        </exec>
        <echo message="${result}" />
    </target>
</project>

This gives me the following output:


[11:11:40]Checking for changes

[11:11:43]Publishing internal artifacts

[11:11:43][Publishing internal artifacts] Sending build.start.properties.gz file

[11:11:43]Clearing temporary directory: /home/morn/TeamCity/buildAgent/temp/buildTmp

[11:11:43]Checkout directory: /home/morn/TeamCity/buildAgent/work/20aeb5b580847da

[11:11:43]Updating sources: server side checkout

[11:11:43][Updating sources] Building incremental patch for VCS root: RubyCAS

[11:11:43][Updating sources] Repository sources transferred

[11:11:43][Updating sources] Updating /home/morn/TeamCity/buildAgent/work/20aeb5b580847da

[11:11:43]Starting: /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java -Dagent.home.dir=/home/morn/TeamCity/buildAgent -Dagent.name=Default Agent -Dagent.ownPort=9090 -Dagent.work.dir=/home/morn/TeamCity/buildAgent/work -Dant.home=/home/morn/TeamCity/buildAgent/plugins/ant -Dbuild.number=10 -Dbuild.vcs.number=37175e910c44af42fa237481531a13776fab3e7c -Dbuild.vcs.number.1=37175e910c44af42fa237481531a13776fab3e7c -Dbuild.vcs.number.RubyCAS=37175e910c44af42fa237481531a13776fab3e7c -Dfile.encoding=UTF-8 -Dfile.separator=/ -Djava.io.tmpdir=/home/morn/TeamCity/buildAgent/temp/buildTmp -Dos.arch=amd64 -Dos.name=Linux -Dos.version=3.2.0-23-generic -Dpath.separator=: -Dteamcity.agent.cpuBenchmark=645 -Dteamcity.agent.dotnet.agent_url=http://localhost:9090/RPC2 -Dteamcity.agent.dotnet.build_id=55 -Dteamcity.auth.password=nwg0wreGnbhgb17Y5MBfn4OxvbilQdOj -Dteamcity.auth.userId=TeamCityBuildId=55 -Dteamcity.build.changedFiles.file=/home/morn/TeamCity/buildAgent/temp/buildTmp/changedFiles9208105501990696562.txt -Dteamcity.build.checkoutDir=/home/morn/TeamCity/buildAgent/work/20aeb5b580847da -Dteamcity.build.id=55 -Dteamcity.build.properties.file=/home/morn/TeamCity/buildAgent/temp/buildTmp/teamcity.build1148073363253777394.properties -Dteamcity.build.tempDir=/home/morn/TeamCity/buildAgent/temp/buildTmp -Dteamcity.build.workingDir=/home/morn/TeamCity/buildAgent/work/20aeb5b580847da -Dteamcity.buildConfName=RubyCAS Ant -Dteamcity.buildType.id=bt7 -Dteamcity.configuration.properties.file=/home/morn/TeamCity/buildAgent/temp/buildTmp/teamcity.config764939865072499243.properties -Dteamcity.projectName=Ruby -Dteamcity.runner.properties.file=/home/morn/TeamCity/buildAgent/temp/buildTmp/teamcity.runner1546075997806046406.properties -Dteamcity.runtime.props.file=/home/morn/TeamCity/buildAgent/temp/agentTmp/ant2421789482610529294runtime -Dteamcity.tests.recentlyFailedTests.file=/home/morn/TeamCity/buildAgent/temp/buildTmp/testsToRunFirst1231794120607935972.txt -Dteamcity.version=7.1 (build 23907) -Duser.country=US -Duser.home=/home/morn -Duser.language=en -Duser.name=morn -Duser.timezone=Europe/Berlin -classpath /home/morn/TeamCity/buildAgent/plugins/ant/lib/ant-launcher.jar org.apache.tools.ant.launch.Launcher -lib /home/morn/TeamCity/buildAgent/plugins/antPlugin/ant-runtime.jar:/home/morn/TeamCity/buildAgent/lib/runtime-util.jar -listener jetbrains.buildServer.agent.ant.AgentBuildListener -buildfile /home/morn/TeamCity/buildAgent/work/20aeb5b580847da/build.xml rspec

[11:11:43]in directory: /home/morn/TeamCity/buildAgent/work/20aeb5b580847da

[11:11:43]init

[11:11:43][init] echo

[11:11:43][echo] starting Rubycas tests

[11:11:43]rspec

[11:11:43][rspec] echo

[11:11:43][echo] ##teamcity[message text='Starting RSpec' timestamp='yyyy-MM-dd HH:mm:ss']

[11:11:44][echo] Unparseable date: "yyyy-MM-dd HH:mm:ss"

[11:11:43][rspec] exec

[11:11:44][exec] Result: 1

[11:11:44][rspec] echo

[11:11:44][echo] /home/morn/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/option_parser.rb:21:in `parse!': invalid option: --require teamcity/spec/runner/formatter/teamcity/formatter (OptionParser::InvalidOption)

[11:11:44][echo] from /home/morn/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/option_parser.rb:7:in `parse!'

[11:11:44][echo] from /home/morn/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/configuration_options.rb:82:in `command_line_options'

[11:11:44][echo] from /home/morn/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/configuration_options.rb:112:in `custom_options_file'

[11:11:44][echo] from /home/morn/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/configuration_options.rb:74:in `file_options'

[11:11:44][echo] from /home/morn/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/configuration_options.rb:70:in `all_configs'

[11:11:44][echo] from /home/morn/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/configuration_options.rb:27:in `parse_options'

[11:11:44][echo] from /home/morn/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:58:in `run'

[11:11:44][echo] from /home/morn/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8:in `block in autorun'

[11:11:44]Process exited with code 0

[11:11:44]Publishing internal artifacts

[11:11:44][Publishing internal artifacts] Sending build.finish.properties.gz file

[11:11:44]Publishing artifacts

[11:11:44][Publishing artifacts] Collecting files to publish: [coverage => coverage.zip]

[11:11:44][Publishing artifacts] Creating archive coverage.zip

[11:11:44][Creating archive coverage.zip] Creating /home/morn/TeamCity/buildAgent/temp/buildTmp/ZipPreprocessor3028313975612714688/coverage.zip

[11:11:44][Creating archive coverage.zip] Archive was created, file size 184290 bytes

[11:11:44][Publishing artifacts] Sending coverage

[11:11:44]Build finished


So how can I get this properly working?

0

Please sign in to leave a comment.