Skip to content

Commit b024db9

Browse files
authored
Merge pull request #126 from pact-foundation/feat/windows_binstubs
Feat/windows binstubs
2 parents 041a091 + ee4d44c commit b024db9

13 files changed

+112
-34
lines changed

bin/pact-provider-verifier.cmd

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
@ruby -x "%~f0" %*
2+
@exit /b %ERRORLEVEL%
3+
4+
#!/usr/bin/env ruby
5+
# frozen_string_literal: true
6+
7+
#
8+
# This file was generated by Bundler.
9+
#
10+
# The application 'pact-provider-verifier' is installed as part of a gem, and
11+
# this file is here to facilitate running it.
12+
#
13+
14+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
15+
16+
bundle_binstub = File.expand_path("bundle", __dir__)
17+
18+
if File.file?(bundle_binstub)
19+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
20+
load(bundle_binstub)
21+
else
22+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
23+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
24+
end
25+
end
26+
27+
require "rubygems"
28+
require "bundler/setup"
29+
30+
load Gem.bin_path("pact-provider-verifier", "pact-provider-verifier")

examples/test.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ res = `pact-provider-verifier --provider-base-url http://localhost:4567 --pact-u
1414
puts res
1515

1616
puts "=> Shutting down API"
17-
Process.kill 'TERM', pipe.pid
17+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
18+
system("taskkill /im #{pipe.pid} /f /t >nul 2>&1")
19+
else
20+
Process.kill 'TERM', pipe.pid
21+
end
1822

1923
puts "Test exit status: #{res}"
2024
puts

spec/integration_check_host_spec.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
describe "pact-provider-verifier", skip_windows: true do
1+
describe "pact-provider-verifier" do
22
before(:all) do
33
@pipe = IO.popen("bundle exec rackup -p 4569 spec/support/provider-echo-host.ru")
44
sleep 2
@@ -11,6 +11,10 @@
1111
end
1212

1313
after(:all) do
14-
Process.kill 'KILL', @pipe.pid
14+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
15+
system("taskkill /im #{@pipe.pid} /f /t >nul 2>&1")
16+
else
17+
Process.kill 'KILL', @pipe.pid
18+
end
1519
end
1620
end

spec/integration_spec.rb

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'json'
22
require 'fileutils'
33

4-
describe "pact-provider-verifier", skip_windows: true do
4+
describe "pact-provider-verifier" do
55
before(:all) do
66
@pipe = IO.popen("bundle exec rackup -p 4567 spec/support/config.ru")
77
sleep 2
@@ -77,15 +77,19 @@
7777
end
7878

7979
context "running verification with filtered interactions" do
80-
81-
subject { `PACT_DESCRIPTION="Provider state success" PACT_PROVIDER_STATE="There is a greeting" bundle exec bin/pact-provider-verifier ./test/me-they.json -a 1.0.100 --provider-base-url http://localhost:4567 --provider-states-setup-url http://localhost:4567/provider-state -v` }
80+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
81+
env_vars = 'set PACT_DESCRIPTION="Provider state success" && set PACT_PROVIDER_STATE="There is a greeting" && '
82+
else
83+
env_vars = 'PACT_DESCRIPTION="Provider state success" PACT_PROVIDER_STATE="There is a greeting" '
84+
end
85+
subject { `#{env_vars}bundle exec bin/pact-provider-verifier ./test/me-they.json -a 1.0.100 --provider-base-url http://localhost:4567 --provider-states-setup-url http://localhost:4567/provider-state -v` }
8286

8387
it "exits with a 0 exit code" do
8488
subject
8589
expect($?).to eq 0
8690
end
8791

88-
it "the output contains a message indicating that the interactions have been filtered" do
92+
it "the output contains a message indicating that the interactions have been filtered", skip_windows: true do
8993
expect(subject).to match /Filtering interactions by.*Provider state success.*There is a greeting/
9094
end
9195
end
@@ -148,6 +152,10 @@
148152
end
149153

150154
after(:all) do
151-
Process.kill 'KILL', @pipe.pid
155+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
156+
system("taskkill /im #{@pipe.pid} /f /t >nul 2>&1")
157+
else
158+
Process.kill 'KILL', @pipe.pid
159+
end
152160
end
153161
end

spec/integration_verify_message_pact_spec.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'pact/provider_verifier/app'
22

3-
RSpec.describe "verifying a message pact", skip_windows: true do
3+
RSpec.describe "verifying a message pact" do
44

55
before(:all) do
66
@pipe = IO.popen("rackup -p 9393 spec/support/message_producer_verifier.ru")
@@ -26,6 +26,10 @@
2626
end
2727

2828
after(:all) do
29-
Process.kill 'KILL', @pipe.pid
29+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
30+
system("taskkill /im #{@pipe.pid} /f /t >nul 2>&1")
31+
else
32+
Process.kill 'KILL', @pipe.pid
33+
end
3034
end
3135
end

spec/integration_with_custom_header_spec.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
describe "pact-provider-verifier with basic auth", skip_windows: true do
1+
describe "pact-provider-verifier with basic auth" do
22
before(:all) do
33
@pipe = IO.popen({'USE_BASIC_AUTH' => 'true'}, %w{bundle exec rackup -p 4570 spec/support/config.ru})
44
sleep 2
@@ -25,6 +25,10 @@
2525
end
2626

2727
after(:all) do
28-
Process.kill 'KILL', @pipe.pid
28+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
29+
system("taskkill /im #{@pipe.pid} /f /t >nul 2>&1")
30+
else
31+
Process.kill 'KILL', @pipe.pid
32+
end
2933
end
3034
end

spec/integration_with_custom_middleware_spec.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
describe "pact-provider-verifier with basic auth", skip_windows: true do
1+
describe "pact-provider-verifier with basic auth" do
22
before(:all) do
33
@pipe = IO.popen({'USE_BASIC_AUTH' => 'true'}, %w{bundle exec rackup -p 4570 spec/support/config.ru})
44
sleep 2
@@ -22,6 +22,10 @@
2222
end
2323

2424
after(:all) do
25-
Process.kill 'KILL', @pipe.pid
25+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
26+
system("taskkill /im #{@pipe.pid} /f /t >nul 2>&1")
27+
else
28+
Process.kill 'KILL', @pipe.pid
29+
end
2630
end
2731
end

spec/integration_with_monkeypatch_spec.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
describe "pact-provider-verifier with monkeypatch", skip_windows: true do
1+
describe "pact-provider-verifier with monkeypatch" do
22
before(:all) do
33
@pipe = IO.popen({}, %w{bundle exec rackup -p 4870 spec/support/config.ru})
44
sleep 2
@@ -19,6 +19,10 @@
1919

2020

2121
after(:all) do
22-
Process.kill 'KILL', @pipe.pid
22+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
23+
system("taskkill /im #{@pipe.pid} /f /t >nul 2>&1")
24+
else
25+
Process.kill 'KILL', @pipe.pid
26+
end
2327
end
2428
end

spec/integration_with_prefix_spec.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'json'
22

3-
describe "pact-provider-verifier with a prefix path in the base URL", skip_windows: true do
3+
describe "pact-provider-verifier with a prefix path in the base URL" do
44
before(:all) do
55
@pipe = IO.popen("bundle exec rackup -p 5837 spec/support/config_with_prefix.ru")
66
sleep 2
@@ -18,6 +18,10 @@
1818
end
1919

2020
after(:all) do
21-
Process.kill 'KILL', @pipe.pid
21+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
22+
system("taskkill /im #{@pipe.pid} /f /t >nul 2>&1")
23+
else
24+
Process.kill 'KILL', @pipe.pid
25+
end
2226
end
2327
end
Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
require 'support/provider_with_self_signed_cert'
22
require 'find_a_port'
33

4-
describe "verifying a provider that uses a self signed certificate", skip_windows: true do
4+
describe "verifying a provider that uses a self signed certificate" do
55

6+
before(:all) do
7+
@port = FindAPort.available_port
8+
@pipe = IO.popen({}, %W{ruby spec/support/provider_with_self_signed_cert.rb #{@port}})
9+
sleep 2
10+
end
611
it "passes because it has SSL verification turned off" do
7-
begin
8-
@port = FindAPort.available_port
9-
@ssl_server_pid = fork do
10-
run_provider_with_self_signed_cert @port
11-
end
12-
sleep 2
13-
subject = `bundle exec bin/pact-provider-verifier ./test/me-they.json -a 1.0.0 --provider-base-url https://localhost:#{@port} --provider_states_setup_url https://localhost:#{@port}/provider-state -v`
14-
expect(subject).to include "2 interactions, 0 failures"
15-
ensure
16-
Process.kill('KILL', @ssl_server_pid)
12+
subject = `bundle exec bin/pact-provider-verifier ./test/me-they.json -a 1.0.0 --provider-base-url https://localhost:#{@port} --provider_states_setup_url https://localhost:#{@port}/provider-state -v`
13+
expect(subject).to include "2 interactions, 0 failures"
14+
end
15+
after(:all) do
16+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
17+
system("taskkill /im #{@pipe.pid} /f /t >nul 2>&1")
18+
else
19+
Process.kill 'KILL', @pipe.pid
1720
end
1821
end
1922
end

0 commit comments

Comments
 (0)