Permalink
Browse files

Add new integration testing framework.

[finishes #44818075]

* use a better IO#expect equivalent that tracks full output
* have travis run integration specs with 1.8.7 and 1.9.3 vmc
* don't run integration specs with ruby 1.8.x
  • Loading branch information...
1 parent 90a417a commit 279dc28712e0b429b58f0f6d7157de4ae5305e82 Alex Suraci, Chris Brown, Dennis Schmidt and Ian Baker committed with Alex Suraci and Chris Brown Feb 20, 2013
View
@@ -1,10 +1,23 @@
language: ruby
+
rvm:
- - "1.9.3"
- - "1.9.2"
- "1.8.7"
+ - "1.9.2"
+ - "1.9.3"
env:
+ matrix:
+ - INTEGRATE_WITH=default
+ - INTEGRATE_WITH=1.8.7
global:
- secure: "UE5QlcvsNEEIiaFVBThh9LFW3LyQG8endi10y1kislgdlVrkpx/b/REU0wwz\nLf1aPGMtKCWbRqBZk0zg8JYTQoig/2wXnct5IJuabOrtgcoWZl/pxGr/0U5A\n5/v0pEq1i3FtXBbOe4Oe2vQuJzhs/WrUXO6gGHsncwQsAreqJtw="
- secure: "IerTwFN0kvQ8zEXxoZJ/NQjwyRzSxh9HbDdr1IljNLyEgDIfx5i57ufemwlH\nVujsITuwg1Ut6b7OLfXFTmbdGHR21XhI3TMBoO34bLuChNlKFQaSkibVSXqe\nr1cTmnbsmVYM4IMImiS0c15WVpVZTYesZTB+P5EsIeQdFJ+j0cw="
- secure: "nZQ4n2D+pzOgWz9Rb75L0NQoKvHOOkms+EpRUlbpq/saSN1pITIpbwGtlbpm\nFGGZbilQxfmdgkp1Wg+3/BmRjgWbn7vjrmudZ5Y137uebmtFhI46/wcjaSTf\n3LBbxkxIQMnzNxGE6PgZgJBrow2pSJ6+ZGI6bk50n+PKQc0kVKY="
+
+before_script: ./script/setup_187
+
+matrix:
+ exclude:
+ - rvm: 1.8.7
+ env: INTEGRATE_WITH=1.8.7
+ - rvm: 1.9.2
+ env: INTEGRATE_WITH=1.8.7
View
@@ -7,7 +7,6 @@ source "http://rubygems.org"
gem "json_pure", "~> 1.6"
gem "multi_json", "~> 1.3"
gem "rake"
-gem "gem-release"
gem "interact", :git => "git://github.com/vito/interact.git"
gem "cfoundry", :git => "git://github.com/cloudfoundry/vmc-lib.git"
@@ -27,3 +26,8 @@ group :test do
gem "webmock", "~> 1.9"
gem "rr", "~> 1.0"
end
+
+group :development do
+ gem "pry"
+ gem "gem-release"
+end
View
@@ -1,16 +1,16 @@
GIT
remote: git://github.com/cloudfoundry/vmc-lib.git
- revision: fd4e4b0ad185a2385fc27079077b04ddd195c13c
+ revision: a88afeb94f31c94e12ef5ca0848eb192d9550a7d
specs:
- cfoundry (0.5.0)
+ cfoundry (0.5.1.rc1)
cf-uaa-lib (~> 1.3.3)
multi_json (~> 1.3)
multipart-post (~> 1.1)
rubyzip (~> 0.9)
GIT
remote: git://github.com/cloudfoundry/vmc-plugins.git
- revision: af0bba49b9e22b606c0085761e24eb6a12d555da
+ revision: 20efa01b9563460077674feeaf1d57b093d3795c
specs:
admin-vmc-plugin (0.1.0)
cfoundry (~> 0.5.0)
@@ -53,13 +53,19 @@ GEM
multi_json (~> 1.3)
cf-uaa-lib (1.3.7)
multi_json
+ coderay (1.0.8)
crack (0.3.2)
diff-lcs (1.1.3)
gem-release (0.4.1)
json_pure (1.7.7)
+ method_source (0.8.1)
mime-types (1.21)
- multi_json (1.6.0)
+ multi_json (1.6.1)
multipart-post (1.1.5)
+ pry (0.9.12)
+ coderay (~> 1.0.5)
+ method_source (~> 0.8)
+ slop (~> 3.4)
rake (10.0.3)
rest-client (1.6.7)
mime-types (>= 1.16)
@@ -73,10 +79,11 @@ GEM
diff-lcs (~> 1.1.3)
rspec-mocks (2.12.2)
rubyzip (0.9.9)
+ slop (3.4.3)
uuidtools (2.1.3)
- webmock (1.9.0)
+ webmock (1.9.3)
addressable (>= 2.2.7)
- crack (>= 0.1.7)
+ crack (>= 0.3.2)
PLATFORMS
ruby
@@ -93,6 +100,7 @@ DEPENDENCIES
mcf-vmc-plugin!
mothership!
multi_json (~> 1.3)
+ pry
rake
rr (~> 1.0)
rspec (~> 2.11)
View
@@ -10,6 +10,8 @@ require "bundler"
Bundler.require
+$stdout.sync = true
+
require "vmc"
require "vmc/plugin"
View
@@ -331,21 +331,22 @@ def targets_info
new_toks = File.expand_path(VMC::TOKENS_FILE)
old_toks = File.expand_path(VMC::OLD_TOKENS_FILE)
- info = if File.exist? new_toks
- YAML.load_file(new_toks)
- elsif File.exist? old_toks
- MultiJson.load(File.read(old_toks))
- else
- {}
- end
+ info =
+ if File.exist? new_toks
+ YAML.load_file(new_toks)
+ elsif File.exist? old_toks
+ MultiJson.load(File.read(old_toks))
+ end
+
+ info ||= {}
normalize_targets_info(info)
end
def normalize_targets_info(info_by_url)
info_by_url.reduce({}) do |hash, pair|
key, value = pair
- hash[key] = value.is_a?(String) ? {:token => value } : value
+ hash[key] = value.is_a?(String) ? { :token => value } : value
hash
end
end
View
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+if [ -z "$INTEGRATE_WITH" ]; then
+ INTEGRATE_WITH="default";
+fi;
+
+if [ "$INTEGRATE_WITH" != "default" ]; then
+ rvm $INTEGRATE_WITH@vmc --create do bundle install;
+fi;
@@ -0,0 +1,6 @@
+#!/usr/bin/env ruby
+
+$stdout.sync = true
+print "started"
+typed = gets
+print "received #{typed}"
@@ -0,0 +1,5 @@
+#!/usr/bin/env ruby
+
+print "started"
+sleep 0.5
+print " finished"
@@ -0,0 +1,152 @@
+require 'spec_helper'
+include ConsoleAppSpeckerMatchers
+
+describe ConsoleAppSpeckerMatchers, :ruby19 => true do
+ describe "#say" do
+ it "returns an ExpectOutputMatcher" do
+ say("").should be_a(ExpectOutputMatcher)
+ end
+
+ context "with an explicit timeout" do
+ it "returns an ExpectOutputMatcher" do
+ matcher = say("", 30)
+ matcher.should be_a(ExpectOutputMatcher)
+ matcher.timeout.should == 30
+ end
+ end
+ end
+
+ describe "#have_exited_with" do
+ it "returns an ExitCodeMatcher" do
+ have_exited_with(1).should be_a(ExitCodeMatcher)
+ end
+
+ it "has synonyms" do
+ exit_with(1).should be_a(ExitCodeMatcher)
+ end
+ end
+end
+
+describe ExpectOutputMatcher, :ruby19 => true do
+ let(:expected_output) { "expected_output" }
+ let(:timeout) { 1 }
+
+ subject { ExpectOutputMatcher.new(expected_output, timeout) }
+
+ describe "#matches?" do
+ context "with something that isn't a runner" do
+ it "raises an exception" do
+ expect {
+ subject.matches?("c'est ne pas une specker runner")
+ }.to raise_exception(InvalidInputError)
+ end
+ end
+
+ context "with a valid runner" do
+ context "when the expected output is in the process output" do
+ it "finds the expected output" do
+ run("echo -n expected_output") do |runner|
+ subject.matches?(runner).should be_true
+ end
+ end
+ end
+
+ context "when the expected output is not in the process output" do
+ let(:runner) { SpeckerRunner.new('echo -n not_what_we_were_expecting') }
+
+ it "does not find the expected output" do
+ run("echo -n not_what_we_were_expecting") do |runner|
+ subject.matches?(runner).should be_false
+ end
+ end
+ end
+ end
+ end
+
+ context "failure messages" do
+ it "has a correct failure message" do
+ run("echo -n actual_output") do |runner|
+ subject.matches?(runner)
+ subject.failure_message.should == "expected 'expected_output' to be printed, but it wasn't. full output:\nactual_output"
+ end
+ end
+
+ it "has a correct negative failure message" do
+ run("echo -n actual_output") do |runner|
+ subject.matches?(runner)
+ subject.negative_failure_message.should == "expected 'expected_output' to not be printed, but it was. full output:\nactual_output"
+ end
+ end
+ end
+end
+
+describe ExitCodeMatcher, :ruby19 => true do
+ let(:expected_code) { 0 }
+
+ subject { ExitCodeMatcher.new(expected_code) }
+
+ describe "#matches?" do
+ context "with something that isn't a runner" do
+ it "raises an exception" do
+ expect {
+ subject.matches?("c'est ne pas une specker runner")
+ }.to raise_exception(InvalidInputError)
+ end
+ end
+
+ context "with a valid runner" do
+ context "and the command exited with the expected exit code" do
+ it "returns true" do
+ run("true") do |runner|
+ subject.matches?(runner).should be_true
+ end
+ end
+ end
+
+ context "and the command exits with a different exit code" do
+ it "returns false" do
+ run("false") do |runner|
+ subject.matches?(runner).should be_false
+ end
+ end
+ end
+
+ context "and the command runs for a while" do
+ it "waits for it to exit" do
+ run("sleep 0.5") do |runner|
+ subject.matches?(runner).should be_true
+ end
+ end
+ end
+ end
+ end
+
+ context "failure messages" do
+ context "with a command that's exited" do
+ it "has a correct failure message" do
+ run("false") do |runner|
+ subject.matches?(runner)
+ runner.wait_for_exit
+ subject.failure_message.should == "expected process to exit with status 0, but it exited with status 1"
+ end
+ end
+
+ it "has a correct negative failure message" do
+ run("false") do |runner|
+ subject.matches?(runner)
+ runner.wait_for_exit
+ subject.negative_failure_message.should == "expected process to not exit with status 0, but it did"
+ end
+ end
+ end
+
+ context "with a command that's still running" do
+ it "waits for it to exit" do
+ run("ruby -e 'sleep 1; exit 1'") do |runner|
+ subject.matches?(runner)
+ subject.failure_message.should == "expected process to exit with status 0, but it exited with status 1"
+ end
+ end
+ end
+ end
+end
Oops, something went wrong.

0 comments on commit 279dc28

Please sign in to comment.