Skip to content

Commit 757796a

Browse files
committed
Waiting for listener in TCK steps
1 parent 69100f3 commit 757796a

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

features/step_definitions/cucumber_cpp_mappings.rb

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
require 'json'
2-
require 'os'
2+
require 'io/wait'
3+
require 'open3'
34

45
module CucumberCppMappings
56

@@ -292,13 +293,13 @@ def run_feature_with_params(params)
292293
compile_step_definitions
293294
create_wire_file
294295
run_cucumber_cpp
295-
if OS.mac?
296-
puts "wait a second"
297-
sleep(1)
298-
end
299296
run_cucumber_test_feature params
300-
Process.kill(9, @steps_out.pid) # for when there are no scenarios
301-
Process.wait @steps_out.pid
297+
begin
298+
# for when there are no scenarios
299+
Process.kill(:SIGTERM, @steps_thread.pid)
300+
Process.wait @steps_thread.pid
301+
rescue Errno::ESRCH
302+
end
302303
end
303304

304305
def write_main_step_definitions_file
@@ -318,7 +319,11 @@ def create_wire_file
318319
end
319320

320321
def run_cucumber_cpp
321-
@steps_out = IO.popen STEP_DEFINITIONS_EXE
322+
i, o, e, t = Open3.popen3(STEP_DEFINITIONS_EXE, "-v")
323+
@steps_out = o
324+
@steps_thread = t
325+
expect(e.wait(2)).not_to be_nil
326+
expect(e.readline).to start_with("Listening")
322327
end
323328

324329
def run_cucumber_test_feature(params)

src/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ void acceptWireProtocol(int port, bool verbose = false) {
1515
SocketServer server(&protocolHandler);
1616
server.listen(port);
1717
if (verbose)
18-
std::cout << "Listening on port " << port << std::endl;
18+
std::cerr << "Listening on port " << port << std::endl;
1919
server.acceptOnce();
2020
}
2121

@@ -28,14 +28,15 @@ int main(int argc, char **argv) {
2828
optionDescription.add_options()
2929
("help,h", "help for cucumber-cpp")
3030
("verbose,v", "verbose output")
31-
("port", value<int>(), "listening port of wireserver")
31+
("port,p", value<int>(), "listening port of wireserver")
3232
;
3333
boost::program_options::variables_map optionVariableMap;
3434
boost::program_options::store( boost::program_options::parse_command_line(argc, argv, optionDescription), optionVariableMap);
3535
boost::program_options::notify(optionVariableMap);
3636

3737
if (optionVariableMap.count("help")) {
3838
std::cout << optionDescription << std::endl;
39+
exit(0);
3940
}
4041

4142
if (optionVariableMap.count("verbose")) {

0 commit comments

Comments
 (0)