Re: [Cucumber] [CPP] Getting started with cucumber-cpp - trouble running the examples

780 views
Skip to first unread message

aslak hellesoy

unread,
Sep 4, 2012, 5:31:23 PM9/4/12
to cu...@googlegroups.com
On Tue, Sep 4, 2012 at 10:13 PM, Daniel Rasmussen <d...@retro-tronics.com> wrote:
> Hi All,
>
> I'm new here. Trying to run the cucumber-cpp examples on Linux. I can build
> and run the BoostCalculatorSteps and it is listening on port 3902 (confirmed
> with telnet) but, when I run the cucumber cli like so:
>
> cucumber examples/Calc/CalcFeatures/features
>
> I get this for output:
>
> # language: en
> Feature: Addition
> In order to avoid silly mistakes
> As a math idiot
> I want to be told the sum of two numbers
>
>
> Scenario Outline: Add two numbers # addition.feature:7
> Given I have entered 25 into the calculator # addition.feature:8
> And I have entered 15 into the calculator # addition.feature:9
> When I press add # addition.feature:10
> Then the result should be 40 on the screen # addition.feature:11
>

Try with a Scenario instead of a Scenario Outline. More info here:

https://github.com/cucumber/cucumber/wiki/Scenario-Outlines

Aslak

>
> 0 scenarios
> 0 steps
> 0m0.002s
>
>
> Which is not what I expected. Any suggestions on how to debug this (either
> my installation, test, or expectation)?
>
> Thanks,
> Dan
>
> --
> -- Rules --
>
> 1) Please prefix the subject with [Ruby], [JVM] or [JS].
> 2) Please use interleaved answers
> http://en.wikipedia.org/wiki/Posting_style#Interleaved_style
> 3) If you have a question, don't reply to an existing message. Start a new
> topic instead.
>
> You received this message because you are subscribed to the Google Groups
> Cukes group. To post to this group, send email to cu...@googlegroups.com. To
> unsubscribe from this group, send email to
> cukes+un...@googlegroups.com. For more options, visit this group at
> https://groups.google.com/d/forum/cukes?hl=en
>
>

Paolo Ambrosio

unread,
Sep 5, 2012, 2:38:23 AM9/5/12
to cu...@googlegroups.com
On Tue, Sep 4, 2012 at 11:13 PM, Daniel Rasmussen <d...@retro-tronics.com> wrote:

> Which is not what I expected. Any suggestions on how to debug this (either
> my installation, test, or expectation)?

It looks like you have altered the "addition.feature" file (I can't
see the 25+15=40 example in the original file). As Aslak wrote, if you
remove the Examples section, you should not use a Scenario Outline (or
no scenarios will be run).

--
Paolo

Daniel Rasmussen

unread,
Sep 6, 2012, 8:47:04 AM9/6/12
to cu...@googlegroups.com
Yes! You have both detected my hacking.  I should have started with the original problem which reappeared when I fixed my hacked example to be a Scenario instead of a Scenario Ouline, 

The original problem is this:

cucumber examples/Calc/CalcFeatures/features/

# language: en
Feature: Addition
 
In order to avoid silly mistakes
 
As
a math idiot
  I want to be told the sum of two numbers


  Scenario: Add two numbers                     # examples/Calc/CalcFeatures/features/addition.feature:7
undefined method `strip' for nil:NilClass (NoMethodError)
/usr/lib/ruby/vendor_ruby/cucumber/wire_support/wire_packet.rb:8:in `
parse'
/usr/lib/ruby/vendor_ruby/cucumber/wire_support/connection.rb:45:in `fetch_data_from_socket'

/usr/lib/ruby/vendor_ruby/cucumber/wire_support/connection.rb:20:in `call_remote'
/usr/lib/ruby/vendor_ruby/cucumber/wire_support/request_handler.rb:10:in `
execute'
/usr/lib/ruby/vendor_ruby/cucumber/wire_support/wire_protocol/requests.rb:12:in `execute'

/usr/lib/ruby/vendor_ruby/cucumber/wire_support/wire_protocol.rb:9:in `step_matches'
/usr/lib/ruby/vendor_ruby/cucumber/wire_support/wire_language.rb:37:in `
step_matches'
/usr/lib/ruby/vendor_ruby/cucumber/wire_support/wire_language.rb:37:in `map'

/usr/lib/ruby/vendor_ruby/cucumber/wire_support/wire_language.rb:37:in `step_matches'
/usr/lib/ruby/vendor_ruby/cucumber/runtime/support_code.rb:153:in `
matches'
/usr/lib/ruby/vendor_ruby/cucumber/runtime/support_code.rb:152:in `map'

/usr/lib/ruby/vendor_ruby/cucumber/runtime/support_code.rb:152:in `matches'
/usr/lib/ruby/vendor_ruby/cucumber/runtime/support_code.rb:128:in `
step_match'
/usr/lib/ruby/vendor_ruby/cucumber/runtime.rb:65:in `step_match'

/usr/lib/ruby/vendor_ruby/cucumber/ast/step_invocation.rb:82:in `find_step_match!'
/usr/lib/ruby/vendor_ruby/cucumber/ast/step_invocation.rb:55:in `
invoke'
/usr/lib/ruby/vendor_ruby/cucumber/ast/step_invocation.rb:38:in `accept'

/usr/lib/ruby/vendor_ruby/cucumber/ast/tree_walker.rb:99:in `visit_step'
/usr/lib/ruby/vendor_ruby/cucumber/ast/tree_walker.rb:163:in `
broadcast'
/usr/lib/ruby/vendor_ruby/cucumber/ast/tree_walker.rb:98:in `visit_step'

/usr/lib/ruby/vendor_ruby/cucumber/ast/step_collection.rb:15:in `accept'
/usr/lib/ruby/vendor_ruby/cucumber/ast/step_collection.rb:14:in `
each'
/usr/lib/ruby/vendor_ruby/cucumber/ast/step_collection.rb:14:in `accept'

/usr/lib/ruby/vendor_ruby/cucumber/ast/tree_walker.rb:93:in `visit_steps'
/usr/lib/ruby/vendor_ruby/cucumber/ast/tree_walker.rb:163:in `
broadcast'
/usr/lib/ruby/vendor_ruby/cucumber/ast/tree_walker.rb:92:in `visit_steps'

/usr/lib/ruby/vendor_ruby/cucumber/ast/scenario.rb:55:in `accept'
/usr/lib/ruby/vendor_ruby/cucumber/runtime.rb:79:in `
with_hooks'
/usr/lib/ruby/vendor_ruby/cucumber/runtime.rb:95:in `before_and_after'

/usr/lib/ruby/vendor_ruby/cucumber/runtime.rb:78:in `with_hooks'
/usr/lib/ruby/vendor_ruby/cucumber/runtime/support_code.rb:115:in `
call'
/usr/lib/ruby/vendor_ruby/cucumber/runtime/support_code.rb:115:in `around'

/usr/lib/ruby/vendor_ruby/cucumber/language_support/language_methods.rb:13:in `around'
/usr/lib/ruby/vendor_ruby/cucumber/language_support/language_methods.rb:95:in `
call'
/usr/lib/ruby/vendor_ruby/cucumber/language_support/language_methods.rb:95:in `execute_around'

/usr/lib/ruby/vendor_ruby/cucumber/language_support/language_methods.rb:12:in `around'
/usr/lib/ruby/vendor_ruby/cucumber/runtime/support_code.rb:114:in `
around'
/usr/lib/ruby/vendor_ruby/cucumber/runtime/support_code.rb:112:in `call'

/usr/lib/ruby/vendor_ruby/cucumber/runtime/support_code.rb:112:in `around'
/usr/lib/ruby/vendor_ruby/cucumber/runtime.rb:90:in `
around'
/usr/lib/ruby/vendor_ruby/cucumber/runtime.rb:77:in `with_hooks'

/usr/lib/ruby/vendor_ruby/cucumber/ast/scenario.rb:53:in `accept'
/usr/lib/ruby/vendor_ruby/cucumber/ast/scenario.rb:108:in `
with_visitor'
/usr/lib/ruby/vendor_ruby/cucumber/ast/scenario.rb:47:in `accept'

/usr/lib/ruby/vendor_ruby/cucumber/ast/tree_walker.rb:51:in `visit_feature_element'
/usr/lib/ruby/vendor_ruby/cucumber/ast/tree_walker.rb:163:in `
broadcast'
/usr/lib/ruby/vendor_ruby/cucumber/ast/tree_walker.rb:50:in `visit_feature_element'

/usr/lib/ruby/vendor_ruby/cucumber/ast/feature.rb:43:in `accept'
/usr/lib/ruby/vendor_ruby/cucumber/ast/feature.rb:42:in `
each'
/usr/lib/ruby/vendor_ruby/cucumber/ast/feature.rb:42:in `accept'

/usr/lib/ruby/vendor_ruby/cucumber/ast/tree_walker.rb:20:in `visit_feature'
/usr/lib/ruby/vendor_ruby/cucumber/ast/tree_walker.rb:163:in `
broadcast'
/usr/lib/ruby/vendor_ruby/cucumber/ast/tree_walker.rb:19:in `visit_feature'

/usr/lib/ruby/vendor_ruby/cucumber/ast/features.rb:29:in `accept'
/usr/lib/ruby/vendor_ruby/cucumber/ast/features.rb:17:in `
each'
/usr/lib/ruby/vendor_ruby/cucumber/ast/features.rb:17:in `each'

/usr/lib/ruby/vendor_ruby/cucumber/ast/features.rb:28:in `accept'
/usr/lib/ruby/vendor_ruby/cucumber/ast/tree_walker.rb:14:in `
visit_features'
/usr/lib/ruby/vendor_ruby/cucumber/ast/tree_walker.rb:163:in `broadcast'

/usr/lib/ruby/vendor_ruby/cucumber/ast/tree_walker.rb:13:in `visit_features'
/usr/lib/ruby/vendor_ruby/cucumber/runtime.rb:45:in `
run!'
/usr/lib/ruby/vendor_ruby/cucumber/cli/main.rb:38:in `execute!'

/usr/lib/ruby/vendor_ruby/cucumber/cli/main.rb:15:in `execute'
/usr/bin/cucumber:14
[1]+  Segmentation fault      (core dumped) build/examples/Calc/BoostCalculatorSteps


I'm not a ruby guy but this feels like a ruby installation/version problem:

ruby --version
ruby
1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]

Thanks for the help.

Dan

Daniel Rasmussen

unread,
Sep 6, 2012, 11:56:12 AM9/6/12
to cu...@googlegroups.com
More, hopefully helpful, information.  

I ran BoostCalculatorSteps in gdb:

(gdb) run
Starting program: /home/dan/workspaceBugs/cucumber-cpp/build/examples/Calc/BoostCalculatorSteps
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Listening on port 3902


Program received signal SIGSEGV, Segmentation fault.
0x0000000000561040 in cuke::internal::CukeEngineImpl::stepMatches(std::string const&) const ()
(gdb) where
#0  0x0000000000561040 in cuke::internal::CukeEngineImpl::stepMatches(std::string const&) const ()
#1  0x00000000005a891c in cuke::internal::StepMatchesCommand::run(cuke::internal::CukeEngine*) const ()
#2  0x00000000005721f7 in cuke::internal::WireProtocolHandler::handle(std::string const&) const ()
#3  0x000000000056b35c in cuke::internal::SocketServer::processStream(boost::asio::basic_socket_iostream<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >&) ()
#4  0x000000000056b2cb in cuke::internal::SocketServer::acceptOnce() ()
#5  0x000000000055c9ba in acceptWireProtocol(int) ()
#6  0x000000000055cae5 in main ()

and some strace output:

.
.
.
write
(2, "Listening on port ", 18Listening on port )      = 18
write
(2, "3902", 43902)                     = 4
write
(2, "\n", 1
)                       = 1
epoll_create
(20000)                     = 3
timerfd_create
(CLOCK_MONOTONIC, 0)      = 4
eventfd2
(0, 0)                          = 5
fcntl
(5, F_SETFL, O_RDONLY|O_NONBLOCK)  = 0
epoll_ctl
(3, EPOLL_CTL_ADD, 5, {EPOLLIN|EPOLLERR|EPOLLET, {u32=22274160, u64=22274160}}) = 0
write
(5, "\1\0\0\0\0\0\0\0", 8)         = 8
epoll_ctl
(3, EPOLL_CTL_ADD, 4, {EPOLLIN|EPOLLERR, {u32=22274156, u64=22274156}}) = 0
socket
(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 6
epoll_ctl
(3, EPOLL_CTL_ADD, 6, {EPOLLIN|EPOLLPRI|EPOLLOUT|EPOLLERR|EPOLLHUP|EPOLLET, {u32=22274416, u64=22274416}}) = 0
setsockopt
(6, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
bind
(6, {sa_family=AF_INET, sin_port=htons(3902), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
listen
(6, 1)                            = 0
epoll_create
(20000)                     = 7
timerfd_create
(CLOCK_MONOTONIC, 0)      = 8
eventfd2
(0, 0)                          = 9
fcntl
(9, F_SETFL, O_RDONLY|O_NONBLOCK)  = 0
epoll_ctl
(7, EPOLL_CTL_ADD, 9, {EPOLLIN|EPOLLERR|EPOLLET, {u32=22274800, u64=22274800}}) = 0
write
(9, "\1\0\0\0\0\0\0\0", 8)         = 8
epoll_ctl
(7, EPOLL_CTL_ADD, 8, {EPOLLIN|EPOLLERR, {u32=22274796, u64=22274796}}) = 0
accept
(6, 0, NULL)                      = 10
epoll_ctl
(7, EPOLL_CTL_ADD, 10, {EPOLLIN|EPOLLPRI|EPOLLOUT|EPOLLERR|EPOLLHUP|EPOLLET, {u32=22274896, u64=22274896}}) = 0
recvmsg
(10, {msg_name(0)=NULL, msg_iov(1)=[{"[\"begin_scenario\"]\n\372\377\177\0\0t\272\344Me\177\0\0"..., 504}], msg_controllen=0, msg_flags=0}, 0) = 19
sendmsg
(10, {msg_name(0)=NULL, msg_iov(1)=[{"[\"success\"]", 11}], msg_controllen=0, msg_flags=0}, MSG_NOSIGNAL) = 11
sendmsg
(10, {msg_name(0)=NULL, msg_iov(1)=[{"\n", 1}], msg_controllen=0, msg_flags=0}, MSG_NOSIGNAL) = 1
recvmsg
(10, {msg_name(0)=NULL, msg_iov(1)=[{"[\"step_matches\",{\"name_to_match\""..., 504}], msg_controllen=0, msg_flags=0}, 0) = 73
recvmsg
(10, {msg_name(0)=NULL, msg_iov(1)=[{"\n\"step_matches\",{\"name_to_match\""..., 504}], msg_controllen=0, msg_flags=0}, 0) = 1
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV (core dumped) +++
[1]+  Terminated              build/examples/Calc/BoostCalculatorSteps
Segmentation fault (core dumped)

Thanks,
Dan

Paolo Ambrosio

unread,
Sep 7, 2012, 3:17:40 AM9/7/12
to cu...@googlegroups.com
Dan,

I am relocating to London tomorrow, so it might take me a few days
before I'm able to tackle your problem. At the moment I have a 32-bit
Linux with gcc 4.6.3, boost 1.50, cucumber 1.2.1 and it runs correctly
the example in the master branch.

On Thu, Sep 6, 2012 at 5:56 PM, Daniel Rasmussen <d...@retro-tronics.com> wrote:

> I ran BoostCalculatorSteps in gdb:
>
> [...]
> --- SIGSEGV (Segmentation fault) @ 0 (0) ---
> +++ killed by SIGSEGV (core dumped) +++
> [1]+ Terminated build/examples/Calc/BoostCalculatorSteps
> Segmentation fault (core dumped)

This does not look good ;-)

Are you using the original example now? ("git status" to check that
there were no changes)

Can you print the full argument of the last recvmsg before the
segmentation fault?

What is your configuration? I see that you are using a 64-bit Linux
system and Ruby 1.8.7. Are you using the master branch of Cucumber-Cpp
or the 0.2 release? It would help to know the version of Boost, GCC
and perhaps Cucumber as well.

AFAIK, the error on the ruby side is just a side effect of not
receiving a response due to the connection being interrupted.


Paolo

Paolo Ambrosio

unread,
Sep 15, 2012, 4:33:03 AM9/15/12
to cu...@googlegroups.com
On Thu, Sep 6, 2012 at 4:56 PM, Daniel Rasmussen <d...@retro-tronics.com> wrote:

> I ran BoostCalculatorSteps in gdb:
> [...]
> Program received signal SIGSEGV, Segmentation fault.

Dan,

I've tried cucumber-cpp (master branch) on CentOS 6.3 64-bit with gcc
4.4.6, boost 1.51, cucumber 1.2.1 and I still can't reproduce the bug.

Paolo

Paolo Ambrosio

unread,
Nov 28, 2012, 9:50:37 AM11/28/12
to cu...@googlegroups.com
On Wed, Nov 28, 2012 at 3:09 PM, johan pretorius
<johan.p...@gmail.com> wrote:

> I'm not having much luck in compiling cucumber-cpp with Visual Studio 2012
> yet (required for a another project), any pointers will be appreciated.

Hi Johan,

are you creating the VS projects from CMake (cmake -G "Visual Studio
10" ...)? What kind of problems are you experiencing?


Paolo

johan pretorius

unread,
Nov 28, 2012, 11:33:10 AM11/28/12
to cu...@googlegroups.com
On Wed, Nov 28, 2012 at 4:50 PM, Paolo Ambrosio <pa...@ambrosio.name> wrote:
are you creating the VS projects from CMake (cmake -G "Visual Studio
10" ...)? What kind of problems are you experiencing?

I've tried that now (using Visual Studio 11), but I'm still getting the 'Cannot find Boost error', even after trying the StackOverflow solution [1]

That in turn causes cmake --build build to fail, since no .exe files are generated in the examples\Calc folder.


...Work\cucumber-cpp>cmake -G "Visual Studio 11"
-- Boost version: 1.52.0
-- Boost version: 1.52.0
-- Found the following Boost libraries:
--   thread
--   system
--   regex
--   date_time
-- Could NOT find Boost
-- Could NOT find CPPSPEC (missing:  CPPSPEC_LIBRARY CPPSPEC_INCLUDE_DIR)
-- Could NOT find GTest (missing:  GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LI
BRARY)
-- Could NOT find GMock (missing:  GMOCK_LIBRARY GMOCK_INCLUDE_DIR GMOCK_MAIN_LI
BRARY)
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/johanpretorius/Work/cucumber-cpp




Paolo Ambrosio

unread,
Nov 28, 2012, 11:57:40 AM11/28/12
to cu...@googlegroups.com
> ...Work\cucumber-cpp>cmake -G "Visual Studio 11"
> -- Boost version: 1.52.0
> -- Boost version: 1.52.0
> -- Found the following Boost libraries:
> -- thread
> -- system
> -- regex
> -- date_time
> -- Could NOT find Boost
> -- Could NOT find CPPSPEC (missing: CPPSPEC_LIBRARY CPPSPEC_INCLUDE_DIR)
> -- Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR
> GTEST_MAIN_LI
> BRARY)
> -- Could NOT find GMock (missing: GMOCK_LIBRARY GMOCK_INCLUDE_DIR
> GMOCK_MAIN_LI
> BRARY)
> -- Configuring done
> -- Generating done

The second "Could NOT find Boost" is printed when CMake tries to find
the static test libraries (since it's recommended to link them
statically on Windows). If you are not using Boost::Test, you can
safely disable it by specifying -DCUKE_DISABLE_BOOST_TEST=on.

I don't know what testing framework you want to use, but this is an
example to build the library for Google Test only:

cmake -DCUKE_DISABLE_BOOST_TEST=on -DCUKE_DISABLE_CPPSPEC=on
-DBOOST_ROOT=D:\Boost -D -DGTEST_ROOT=D:\SomeDir PathToCucumberCpp

This should create project files in the build directoty that you can
import with Visual Studio. AFAIK you don't need the "build" step with
this generator.


Paolo


P.S.
Please note that now Cucumber-Cpp needs Google Mock for its own tests,
but Google Test is enough to compile it.

Paolo Ambrosio

unread,
Nov 29, 2012, 5:20:00 AM11/29/12
to cu...@googlegroups.com
On Wed, Nov 28, 2012 at 5:57 PM, Paolo Ambrosio <pa...@ambrosio.name> wrote:

> [...] this is an example to build the library for Google Test only:
>
> cmake -DCUKE_DISABLE_BOOST_TEST=on -DCUKE_DISABLE_CPPSPEC=on
> -DBOOST_ROOT=D:\Boost -D -DGTEST_ROOT=D:\SomeDir PathToCucumberCpp

Just realized I forgot to add the option -G "Visual Studio 11" :-)


Paolo
Reply all
Reply to author
Forward
0 new messages