busser 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.cane ADDED
File without changes
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
@@ -0,0 +1,10 @@
1
+ SimpleCov.adapters.define 'gem' do
2
+ command_name 'Specs'
3
+
4
+ add_filter '.gem/'
5
+ add_filter '/spec/'
6
+ add_filter '/lib/vendor/'
7
+
8
+ add_group 'Libraries', '/lib/'
9
+ end
10
+ SimpleCov.start 'gem'
data/.tailor ADDED
@@ -0,0 +1,4 @@
1
+ Tailor.config do |config|
2
+ config.formatters "text"
3
+ config.file_set 'lib/**/*.rb'
4
+ end
@@ -0,0 +1,19 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 2.0.0
5
+ - 1.9.3
6
+ - 1.9.2
7
+ - ruby-head
8
+
9
+ env:
10
+ - RUBYGEMS_VERSION=2.0.3
11
+ - RUBYGEMS_VERSION=1.8.25
12
+
13
+ before_install:
14
+ - gem update --system $RUBYGEMS_VERSION
15
+ - gem --version
16
+
17
+ matrix:
18
+ allow_failures:
19
+ - rvm: ruby-head
@@ -0,0 +1,5 @@
1
+ ## 0.1.0 / 2013-03-28
2
+
3
+ * Initial release
4
+
5
+ [@fnichol]: https://github.com/fnichol
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem 'rb-inotify', :require => false
7
+ gem 'rb-fsevent', :require => false
8
+ gem 'rb-fchange', :require => false
9
+ end
@@ -0,0 +1,18 @@
1
+ guard 'minitest' do
2
+ watch(%r|^spec/(.*)_spec\.rb|)
3
+ watch(%r|^lib/(.*)([^/]+)\.rb|) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
4
+ watch(%r|^spec/spec_helper\.rb|) { "spec" }
5
+ end
6
+
7
+ guard 'cucumber' do
8
+ watch(%r{^features/.+\.feature$})
9
+ watch(%r{^features/support/.+$}) { 'features' }
10
+ watch(%r{^features/step_definitions/(.+)_steps\.rb$}) do |m|
11
+ Dir[File.join("**/#{m[1]}.feature")][0] || 'features'
12
+ end
13
+ end
14
+
15
+ guard 'cane' do
16
+ watch(%r|.*\.rb|)
17
+ watch('.cane')
18
+ end
data/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ Author:: Fletcher Nichol (<fnichol@nichol.ca>)
2
+
3
+ Copyright 2013 Fletcher Nichol
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
@@ -0,0 +1,35 @@
1
+ # Busser
2
+
3
+ [![Build Status](https://travis-ci.org/fnichol/busser.png?branch=master)](https://travis-ci.org/fnichol/busser)
4
+ [![Code Climate](https://codeclimate.com/github/fnichol/busser.png)](https://codeclimate.com/github/fnichol/busser)
5
+
6
+ Busser is a test setup and execution framework designed to
7
+ work on remote nodes whose system dependencies cannot be relied upon, except
8
+ for an Omnibus installation of Chef. It uses a plugin architecture to add
9
+ support for different testing strategies such minitest, cucumber, bash, etc.
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ gem 'busser'
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install busser
24
+
25
+ ## Usage
26
+
27
+ TODO: Write usage instructions here
28
+
29
+ ## Contributing
30
+
31
+ 1. Fork it
32
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
33
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
34
+ 4. Push to the branch (`git push origin my-new-feature`)
35
+ 5. Create new Pull Request
@@ -0,0 +1,38 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+ require 'cucumber/rake/task'
4
+ require 'cane/rake_task'
5
+ require 'tailor/rake_task'
6
+
7
+ Rake::TestTask.new(:unit) do |t|
8
+ t.libs.push "lib"
9
+ t.test_files = FileList['spec/**/*_spec.rb']
10
+ t.verbose = true
11
+ end
12
+
13
+ Cucumber::Rake::Task.new(:features) do |t|
14
+ t.cucumber_opts = ['features', '-x', '--format progress']
15
+ end
16
+
17
+ desc "Run all test suites"
18
+ task :test => [:unit, :features]
19
+
20
+ desc "Run cane to check quality metrics"
21
+ Cane::RakeTask.new do |cane|
22
+ cane.canefile = './.cane'
23
+ end
24
+
25
+ Tailor::RakeTask.new
26
+
27
+ desc "Display LOC stats"
28
+ task :stats do
29
+ puts "\n## Production Code Stats"
30
+ sh "countloc -r lib"
31
+ puts "\n## Test Code Stats"
32
+ sh "countloc -r spec features"
33
+ end
34
+
35
+ desc "Run all quality tasks"
36
+ task :quality => [:cane, :tailor, :stats]
37
+
38
+ task :default => [:test, :quality]
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- encoding: utf-8 -*-
3
+
4
+ $:.unshift File.join(File.dirname(__FILE__), %w{.. lib})
5
+ require 'rubygems'
6
+ require 'busser/cli'
7
+
8
+ Busser::CLI.start
@@ -0,0 +1,39 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'busser/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "busser"
8
+ spec.version = Busser::VERSION
9
+ spec.authors = ["Fletcher Nichol"]
10
+ spec.email = ["fnichol@nichol.ca"]
11
+ spec.description = %q{Kitchen Busser - Runs tests for projects in test-kitchen}
12
+ spec.summary = spec.description
13
+ spec.homepage = "https://github.com/fnichol/busser"
14
+ spec.license = 'Apache 2.0'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.required_ruby_version = ">= 1.9.1"
22
+
23
+ spec.add_dependency 'thor'
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.3"
26
+ spec.add_development_dependency "rake"
27
+ spec.add_development_dependency 'minitest'
28
+ spec.add_development_dependency 'guard-minitest'
29
+ spec.add_development_dependency 'mocha'
30
+ spec.add_development_dependency 'fakefs'
31
+ spec.add_development_dependency 'aruba'
32
+ spec.add_development_dependency 'guard-cucumber'
33
+
34
+ spec.add_development_dependency 'cane'
35
+ spec.add_development_dependency 'guard-cane'
36
+ spec.add_development_dependency 'tailor'
37
+ spec.add_development_dependency 'simplecov'
38
+ spec.add_development_dependency 'countloc'
39
+ end
@@ -0,0 +1,26 @@
1
+ Feature: Plugin install command
2
+ In order to let user test they way they want to test
3
+ As a user of Busser
4
+ I want the ability to install test runner plugins
5
+
6
+ Background:
7
+ Given a sandboxed GEM_HOME directory named "busser-plugin"
8
+
9
+ Scenario: Installing a missing plugin
10
+ When I run `busser plugin install rack`
11
+ Then the output should contain "Plugin rack installed"
12
+ And the exit status should be 0
13
+ And a gem named "rack" is installed
14
+
15
+ Scenario: Installing a missing plugin with a version
16
+ When I run `busser plugin install rack@1.2.8`
17
+ Then the output should contain "Plugin rack@1.2.8 installed (version 1.2.8)"
18
+ And the exit status should be 0
19
+ And a gem named "rack" is installed with version "1.2.8"
20
+
21
+ Scenario: Installing a specfic newer version of an existing plugin
22
+ When I successfully run `busser plugin install rack@1.2.8`
23
+ And I run `busser plugin install rack@1.3.10`
24
+ Then the output should contain "Plugin rack@1.3.10 installed (version 1.3.10)"
25
+ And the exit status should be 0
26
+ And a gem named "rack" is installed with version "1.3.10"
@@ -0,0 +1,17 @@
1
+ Feature: Setup command
2
+ In order to make Busser self-reliant with little external initialization
3
+ As a user of Busser
4
+ I want a command to set up Busser's environment
5
+
6
+ Background:
7
+ Given a test BUSSER_ROOT directory named "busser-setup"
8
+ And I delete the BUSSER_ROOT directory
9
+
10
+ Scenario: Busser home is set up
11
+ Given I run `busser setup`
12
+ Then the BUSSER_ROOT directory should exist
13
+ And a busser binstub file should contain:
14
+ """
15
+ This file was generated by Busser.
16
+ """
17
+ And the exit status should be 0
@@ -0,0 +1,65 @@
1
+ require 'tmpdir'
2
+ require 'pathname'
3
+
4
+ Given(/^a BUSSER_ROOT of "(.*?)"$/) do |busser_root|
5
+ backup_envvar('BUSSER_ROOT')
6
+
7
+ ENV['BUSSER_ROOT'] = busser_root
8
+ end
9
+
10
+ Given(/^a test BUSSER_ROOT directory named "(.*?)"$/) do |name|
11
+ backup_envvar('BUSSER_ROOT')
12
+
13
+ busser_root = Pathname.new(Dir.mktmpdir(name))
14
+ (busser_root + "suites").mkpath
15
+ ENV['BUSSER_ROOT'] = busser_root.to_s
16
+ @busser_root_dirs << busser_root
17
+ end
18
+
19
+ Given(/^I delete the BUSSER_ROOT directory$/) do
20
+ FileUtils.rm_rf(ENV['BUSSER_ROOT'])
21
+ end
22
+
23
+ Given(/^a suite directory named "(.*?)"$/) do |name|
24
+ FileUtils.mkdir_p(File.join(ENV['BUSSER_ROOT'], "suites", name))
25
+ end
26
+
27
+ Given(/^a sandboxed GEM_HOME directory named "(.*?)"$/) do |name|
28
+ backup_envvar('GEM_HOME')
29
+ backup_envvar('GEM_PATH')
30
+
31
+ gem_home = Pathname.new(Dir.mktmpdir(name))
32
+ ENV['GEM_HOME'] = gem_home.to_s
33
+ ENV['GEM_PATH'] = [gem_home.to_s, ENV['GEM_PATH']].join(':')
34
+ @busser_root_dirs << gem_home
35
+ end
36
+
37
+ Then(/^the suite directory named "(.*?)" should not exist$/) do |name|
38
+ directory = File.join(ENV['BUSSER_ROOT'], "suites", name)
39
+ check_directory_presence([directory], false)
40
+ end
41
+
42
+ Then(/^a gem named "(.*?)" is installed with version "(.*?)"$/) do |name, version|
43
+ unbundlerize do
44
+ run_simple(unescape("gem list #{name} --version #{version} -i"), true, nil)
45
+ end
46
+ end
47
+
48
+ Then(/^a gem named "(.*?)" is installed$/) do |name|
49
+ unbundlerize do
50
+ run_simple(unescape("gem list #{name} -i"), true, nil)
51
+ end
52
+ end
53
+
54
+ Then(/^the BUSSER_ROOT directory should exist$/) do
55
+ check_directory_presence([ENV['BUSSER_ROOT']], true)
56
+ end
57
+
58
+ Then(/^a busser binstub file should contain:$/) do |partial_content|
59
+ file = File.join(ENV['BUSSER_ROOT'], %w{bin busser})
60
+ check_file_content(file, partial_content, true)
61
+ end
62
+
63
+ Then(/^pry me$/) do
64
+ require 'pry' ; binding.pry
65
+ end
@@ -0,0 +1,28 @@
1
+ Feature: Suite cleanup command
2
+ In order to have a fresh suite directory base for each test run
3
+ As a user of Busser
4
+ I want a command to clean any suite subdirectories
5
+
6
+ Background:
7
+ Given a test BUSSER_ROOT directory named "busser-suite"
8
+
9
+ Scenario: A nonexistent base suite path
10
+ Given I delete the BUSSER_ROOT directory
11
+ When I run `busser suite cleanup`
12
+ Then the output should contain "does not exist"
13
+ And the exit status should be 0
14
+
15
+ Scenario: An empty base suite path
16
+ When I run `busser suite cleanup`
17
+ Then the stdout should not contain anything
18
+ And the exit status should be 0
19
+
20
+ Scenario: A base suite path containing suite directories
21
+ Given a suite directory named "bats"
22
+ And a suite directory named "minitest"
23
+ When I run `busser suite cleanup`
24
+ Then the output should contain "bats"
25
+ And the output should contain "minitest"
26
+ And the suite directory named "bats" should not exist
27
+ And the suite directory named "minitest" should not exist
28
+ And the exit status should be 0
@@ -0,0 +1,15 @@
1
+ Feature: Suite path command
2
+ In order to determine the directory containing suite tests
3
+ As a user of Busser
4
+ I want a command to echo this directory on standard output
5
+
6
+ Background:
7
+ Given a BUSSER_ROOT of "/path/to/busser"
8
+
9
+ Scenario: Get base suite path
10
+ When I successfully run `busser suite path`
11
+ Then the output should contain exactly "/path/to/busser/suites\n"
12
+
13
+ Scenario: Get suite path for a plugin
14
+ When I successfully run `busser suite path footester`
15
+ Then the output should contain exactly "/path/to/busser/suites/footester\n"
@@ -0,0 +1,40 @@
1
+ require 'simplecov'
2
+ require 'aruba/cucumber'
3
+
4
+ SimpleCov.command_name "features"
5
+
6
+ Before do
7
+ @aruba_timeout_seconds = 10
8
+ @busser_root_dirs = []
9
+ end
10
+
11
+ After do |s|
12
+ # Tell Cucumber to quit after this scenario is done - if it failed.
13
+ # This is useful to inspect the 'tmp/aruba' directory before any other
14
+ # steps are executed and clear it out.
15
+ Cucumber.wants_to_quit = true if s.failed?
16
+
17
+ # Restore environment variables to their original settings, if they have
18
+ # been saved off
19
+ ENV.keys.select { |key| key =~ /^_CUKE_/ }.each do |backup_key|
20
+ ENV[backup_key.sub(/^_CUKE_/, '')] = ENV.delete(backup_key)
21
+ end
22
+
23
+ @busser_root_dirs.each { |dir| FileUtils.rm_rf(dir) }
24
+ end
25
+
26
+ def backup_envvar(key)
27
+ ENV["_CUKE_#{key}"] = ENV[key]
28
+ end
29
+
30
+ def restore_envvar(key)
31
+ ENV[key] = ENV.delete("_CUKE_#{key}")
32
+ end
33
+
34
+ def unbundlerize
35
+ keys = %w[BUNDLER_EDITOR BUNDLE_BIN_PATH BUNDLE_GEMFILE RUBYOPT]
36
+
37
+ keys.each { |key| backup_envvar(key) ; ENV.delete(key) }
38
+ yield
39
+ keys.each { |key| restore_envvar(key) }
40
+ end
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ #
3
+ # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
+ #
5
+ # Copyright (C) 2013, Fletcher Nichol
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+
19
+ require "busser/version"
20
+
21
+ module Busser
22
+ end