vagrant-test 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +5 -0
- data/LICENSE +19 -0
- data/README.md +48 -0
- data/lib/vagrant-test/command.rb +45 -0
- data/lib/vagrant-test/config.rb +41 -0
- data/lib/vagrant-test.rb +21 -0
- data/lib/vagrant_init.rb +1 -0
- metadata +74 -0
data/CHANGELOG.md
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (C) 2012 Michael Paul Thomas Conigliaro
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
5
|
+
the Software without restriction, including without limitation the rights to
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
7
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
8
|
+
so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# vagrant-test
|
2
|
+
|
3
|
+
**vagrant-test** is a simple Vagrant plugin for running tests on your VMs.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
gem install vagrant-test
|
8
|
+
|
9
|
+
## Configuration
|
10
|
+
|
11
|
+
The following options can be used within the `Vagrant::Config.run` block of
|
12
|
+
your Vagrantfile:
|
13
|
+
|
14
|
+
<table>
|
15
|
+
<tr>
|
16
|
+
<th>Option</th>
|
17
|
+
<th>Description</th>
|
18
|
+
<th>Default value</th>
|
19
|
+
</tr>
|
20
|
+
<tr>
|
21
|
+
<td>test.command</td>
|
22
|
+
<td>Command used to run tests</td>
|
23
|
+
<td>"rspec -f doc"</td>
|
24
|
+
</tr>
|
25
|
+
<tr>
|
26
|
+
<td>test.dir</td>
|
27
|
+
<td>Directory where tests are located</td>
|
28
|
+
<td>"spec"</td>
|
29
|
+
</tr>
|
30
|
+
<tr>
|
31
|
+
<td>test.internal_tests</td>
|
32
|
+
<td>List of tests to be run from inside the VM</td>
|
33
|
+
<td>[]</td>
|
34
|
+
</tr>
|
35
|
+
<tr>
|
36
|
+
<td>test.external_tests</td>
|
37
|
+
<td>List of tests to be run from the host against the VM</td>
|
38
|
+
<td>[]</td>
|
39
|
+
</tr>
|
40
|
+
</table>
|
41
|
+
|
42
|
+
## Usage
|
43
|
+
|
44
|
+
vagrant test [vm-name]
|
45
|
+
|
46
|
+
## Authors
|
47
|
+
|
48
|
+
* Michael Paul Thomas Conigliaro <mike [at] conigliaro [dot] org>
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module VagrantTest
|
2
|
+
|
3
|
+
class Command < Vagrant::Command::Base
|
4
|
+
|
5
|
+
def execute
|
6
|
+
opts = OptionParser.new do |opts|
|
7
|
+
opts.banner = "Usage: vagrant test [vm-name]"
|
8
|
+
end
|
9
|
+
|
10
|
+
argv = parse_options(opts)
|
11
|
+
return if !argv
|
12
|
+
|
13
|
+
with_target_vms(argv[0]) do |vm|
|
14
|
+
vm.env.action_runner.run(Vagrant::Action::General::Validate, {:vm=>vm, :ui=>vm.ui})
|
15
|
+
|
16
|
+
if !vm.created? || vm.state != :running
|
17
|
+
vm.ui.error("VM not running. Not running tests.")
|
18
|
+
elsif (vm.config.test.internal_tests + vm.config.test.external_tests).empty?
|
19
|
+
vm.ui.error("No tests defined.")
|
20
|
+
else
|
21
|
+
|
22
|
+
unless vm.config.test.internal_tests.empty?
|
23
|
+
internal_tests = vm.config.test.internal_tests.map { |obj|
|
24
|
+
File.join(V_ROOT, vm.config.test.dir, obj)
|
25
|
+
}.join(", ")
|
26
|
+
vm.ui.info("Running internal test(s): #{internal_tests}")
|
27
|
+
vm.channel.sudo("#{vm.config.test.command} #{internal_tests}") do |type,data|
|
28
|
+
print data if type == :stdout
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
unless vm.config.test.external_tests.empty?
|
33
|
+
external_tests = vm.config.test.external_tests.map { |obj|
|
34
|
+
File.join(vm.config.test.dir, obj)
|
35
|
+
}.join(", ")
|
36
|
+
vm.ui.info("Running external test(s): #{external_tests}")
|
37
|
+
system("#{vm.config.test.command} #{external_tests}")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module VagrantTest
|
2
|
+
|
3
|
+
class Config < Vagrant::Config::Base
|
4
|
+
|
5
|
+
attr_writer :command, :dir, :internal_tests, :external_tests
|
6
|
+
|
7
|
+
def command
|
8
|
+
@command || DEFAULT_COMMAND
|
9
|
+
end
|
10
|
+
|
11
|
+
def dir
|
12
|
+
@dir || DEFAULT_DIR
|
13
|
+
end
|
14
|
+
|
15
|
+
def internal_tests
|
16
|
+
@internal_tests || []
|
17
|
+
end
|
18
|
+
|
19
|
+
def external_tests
|
20
|
+
@external_tests || []
|
21
|
+
end
|
22
|
+
|
23
|
+
def validate(env, errors)
|
24
|
+
errors.add("Test directory not found: #{dir}") unless File.directory?(dir)
|
25
|
+
[:internal_tests, :external_tests].inject({}) { |memo,obj|
|
26
|
+
memo.merge({ obj => send(obj.to_sym) })
|
27
|
+
}.each do |name,value|
|
28
|
+
if value.respond_to?(:each)
|
29
|
+
value.each do |obj|
|
30
|
+
file = File.join(dir, obj)
|
31
|
+
errors.add("File not found: #{file}") unless File.exists?(file)
|
32
|
+
end
|
33
|
+
else
|
34
|
+
errors.add("#{name} is not enumerable")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
data/lib/vagrant-test.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require "vagrant"
|
2
|
+
require "vagrant-test/config"
|
3
|
+
require "vagrant-test/command"
|
4
|
+
|
5
|
+
module VagrantTest
|
6
|
+
|
7
|
+
NAME = "vagrant-test"
|
8
|
+
VERSION = "0.1.0"
|
9
|
+
AUTHOR = "Michael Paul Thomas Conigliaro"
|
10
|
+
AUTHOR_EMAIL = "mike [at] conigliaro [dot] org"
|
11
|
+
DESCRIPTION = "vagrant-test is a simple Vagrant plugin for running tests on your VMs."
|
12
|
+
URL = "http://github.com/mconigliaro/vagrant-test"
|
13
|
+
|
14
|
+
V_ROOT = "/vagrant"
|
15
|
+
DEFAULT_COMMAND = "rspec -f doc"
|
16
|
+
DEFAULT_DIR = "spec"
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
Vagrant.config_keys.register(:test) { VagrantTest::Config }
|
21
|
+
Vagrant.commands.register(:test) { VagrantTest::Command }
|
data/lib/vagrant_init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "vagrant-test"
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-test
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Michael Paul Thomas Conigliaro
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-02-29 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: vagrant
|
16
|
+
requirement: &2154978080 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.9.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2154978080
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
requirement: &2154977580 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2154977580
|
36
|
+
description: vagrant-test is a simple Vagrant plugin for running tests on your VMs.
|
37
|
+
email: mike [at] conigliaro [dot] org
|
38
|
+
executables: []
|
39
|
+
extensions: []
|
40
|
+
extra_rdoc_files: []
|
41
|
+
files:
|
42
|
+
- CHANGELOG.md
|
43
|
+
- LICENSE
|
44
|
+
- README.md
|
45
|
+
- lib/vagrant-test/command.rb
|
46
|
+
- lib/vagrant-test/config.rb
|
47
|
+
- lib/vagrant-test.rb
|
48
|
+
- lib/vagrant_init.rb
|
49
|
+
homepage: http://github.com/mconigliaro/vagrant-test
|
50
|
+
licenses: []
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options: []
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ! '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
requirements: []
|
68
|
+
rubyforge_project: vagrant-test
|
69
|
+
rubygems_version: 1.8.15
|
70
|
+
signing_key:
|
71
|
+
specification_version: 3
|
72
|
+
summary: vagrant-test is a simple Vagrant plugin for running tests on your VMs.
|
73
|
+
test_files: []
|
74
|
+
has_rdoc:
|