soundcheck 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +24 -14
- data/VERSION +1 -1
- data/bin/soundcheck +10 -1
- data/features/soundcheck.feature +7 -1
- data/fixtures/ruby-cutest/Rakefile +7 -0
- data/fixtures/ruby-cutest/test/foo.rb +0 -0
- data/fixtures/ruby-rspec/Rakefile +0 -0
- data/fixtures/ruby-rspec-exception/Rakefile +0 -0
- data/fixtures/ruby-unknown-framework/Gemfile +0 -0
- data/lib/soundcheck/frameworks.rb +22 -1
- data/lib/soundcheck/languages.rb +1 -1
- data/lib/soundcheck/project.rb +27 -5
- data/lib/soundcheck.rb +4 -12
- data/soundcheck.gemspec +7 -1
- data/spec/soundcheck/frameworks/ruby_cutest_spec.rb +44 -0
- data/spec/soundcheck/project_spec.rb +2 -2
- data/spec/soundcheck_spec.rb +0 -4
- metadata +18 -12
data/README.markdown
CHANGED
@@ -1,32 +1,42 @@
|
|
1
1
|
A smarter way to run your tests
|
2
2
|
===============================
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
Soundcheck is a universal test runner. It automatically detects what testing
|
5
|
+
frameworks you use, and how to run your tests. You can pass it a filename,
|
6
|
+
and it'll run just those tests.
|
6
7
|
|
7
|
-
|
8
|
-
and
|
9
|
-
|
10
|
-
|
11
|
-
you require that file, you'll probably need all of Rails loaded. If you don't (as you can
|
12
|
-
often do when running a spec for something you put in `Rails.root.join("lib")`), it'll execute
|
13
|
-
"rspec $0", otherwise it'll execute "bundle exec rspec $0".
|
8
|
+
One benefit of this is that you can set your editor to simply run `soundcheck
|
9
|
+
$filename`, and soundcheck will figure out how to run that test.
|
10
|
+
|
11
|
+
Soundcheck will also try to run your tests as fast as possible.
|
14
12
|
|
15
13
|
## Is Soundcheck not working for your project?
|
16
14
|
|
17
|
-
Feel free to submit a pull request that adds only a fixture and RSpec testcase
|
15
|
+
Feel free to submit a pull request that adds only a fixture and RSpec testcase
|
16
|
+
which describes the situation in which it fails. If you can fix it yourself,
|
17
|
+
then great, but I'll happily accept patches that add more project styles which
|
18
|
+
Soundcheck currently can't handle.
|
18
19
|
|
19
20
|
## Contributing to Soundcheck
|
20
21
|
|
21
|
-
* Check out the latest master to make sure the feature hasn't been implemented
|
22
|
-
|
22
|
+
* Check out the latest master to make sure the feature hasn't been implemented
|
23
|
+
or the bug hasn't been fixed yet
|
24
|
+
* Check out the issue tracker to make sure someone already hasn't requested it
|
25
|
+
and/or contributed it
|
23
26
|
* Fork the project
|
24
27
|
* Start a feature/bugfix branch
|
25
28
|
* Commit and push until you are happy with your contribution
|
26
|
-
* Make sure to add tests for it. This is important so I don't break it in a
|
27
|
-
|
29
|
+
* Make sure to add tests for it. This is important so I don't break it in a
|
30
|
+
future version unintentionally.
|
31
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to
|
32
|
+
have your own version, or is otherwise necessary, that is fine, but please
|
33
|
+
isolate to its own commit so I can cherry-pick around it.
|
28
34
|
|
29
35
|
## Copyright
|
30
36
|
|
31
37
|
Copyright (c) 2011 Marten Veldthuis. See LICENSE.txt for further details.
|
32
38
|
|
39
|
+
This gem started as a Ruby version of Gary Bernhardt's 'script/test' from
|
40
|
+
[Destroy All Software's screencast number 10][1].
|
41
|
+
|
42
|
+
[1]: http://destroyallsoftware.com/screencasts/catalog/fast-tests-with-and-without-rails
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/bin/soundcheck
CHANGED
@@ -14,6 +14,10 @@ option_parser = OptionParser.new do |opts|
|
|
14
14
|
options[:trace] = true
|
15
15
|
end
|
16
16
|
|
17
|
+
opts.on("-v", "--verbose", "Shows debug information about language/test-framework detection") do
|
18
|
+
options[:verbose] = true
|
19
|
+
end
|
20
|
+
|
17
21
|
opts.on("--help", "Show this info") do
|
18
22
|
puts opts
|
19
23
|
exit
|
@@ -21,11 +25,16 @@ option_parser = OptionParser.new do |opts|
|
|
21
25
|
end
|
22
26
|
|
23
27
|
option_parser.parse!(ARGV)
|
28
|
+
soundcheck = Soundcheck.new(ARGV[0], options)
|
29
|
+
|
24
30
|
begin
|
25
|
-
cmd =
|
31
|
+
cmd = soundcheck.command_to_run
|
26
32
|
puts cmd
|
27
33
|
exec cmd
|
28
34
|
rescue Project::UnknownLanguage
|
29
35
|
puts "Error: Cannot detect the programming language for this project."
|
30
36
|
exit 1
|
37
|
+
rescue Project::UnknownFramework
|
38
|
+
puts "Error: Cannot detect the test framework for this project."
|
39
|
+
exit 1
|
31
40
|
end
|
data/features/soundcheck.feature
CHANGED
@@ -9,7 +9,13 @@ Feature: Soundcheck
|
|
9
9
|
Scenario: Unknown languages
|
10
10
|
Given the "null-project" fixture
|
11
11
|
When I run "soundcheck"
|
12
|
-
Then I should see "Cannot detect the programming language for this project
|
12
|
+
Then I should see "Cannot detect the programming language for this project"
|
13
|
+
And it should have failed
|
14
|
+
|
15
|
+
Scenario: Unknown frameworks
|
16
|
+
Given the "ruby-unknown-framework" fixture
|
17
|
+
When I run "soundcheck"
|
18
|
+
Then I should see "Cannot detect the test framework for this project"
|
13
19
|
And it should have failed
|
14
20
|
|
15
21
|
Scenario: Ruby and RSpec
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -46,7 +46,7 @@ module Frameworks
|
|
46
46
|
def filter(*args)
|
47
47
|
filter_with(args, {
|
48
48
|
:is_spec_file => /_spec\.rb$/,
|
49
|
-
:is_in_spec_dir =>
|
49
|
+
:is_in_spec_dir => /^spec/,
|
50
50
|
:is_dir => lambda {|arg| project.has_dir?(arg) }
|
51
51
|
})
|
52
52
|
end
|
@@ -94,6 +94,27 @@ module Frameworks
|
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
+
class RubyCutest
|
98
|
+
include Frameworks::Base
|
99
|
+
|
100
|
+
def present?
|
101
|
+
project.has_file?("Rakefile") and project.file_contents("Rakefile") =~ /Cutest\.run/
|
102
|
+
end
|
103
|
+
|
104
|
+
def filter(*args)
|
105
|
+
filter_with(args, {
|
106
|
+
:is_in_test_dir => /^test\//
|
107
|
+
})
|
108
|
+
end
|
109
|
+
|
110
|
+
def command(*args)
|
111
|
+
args = (args.empty? ? ["test/*.rb"] : filter(*args))
|
112
|
+
return nil if args.empty?
|
113
|
+
|
114
|
+
"cutest #{args.join(" ")}".strip
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
97
118
|
class Expresso
|
98
119
|
include Frameworks::Base
|
99
120
|
|
data/lib/soundcheck/languages.rb
CHANGED
data/lib/soundcheck/project.rb
CHANGED
@@ -3,6 +3,8 @@ require 'soundcheck/languages'
|
|
3
3
|
|
4
4
|
class Project
|
5
5
|
class UnknownLanguage < StandardError; end
|
6
|
+
class UnknownFramework < StandardError; end
|
7
|
+
|
6
8
|
attr_accessor :root
|
7
9
|
|
8
10
|
def initialize(root)
|
@@ -25,17 +27,37 @@ class Project
|
|
25
27
|
paths.any? { |path| has_file?(path) }
|
26
28
|
end
|
27
29
|
|
30
|
+
def file_contents(filename)
|
31
|
+
File.read(File.expand_path(File.join(root, filename)))
|
32
|
+
end
|
33
|
+
|
28
34
|
def language
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
35
|
+
case
|
36
|
+
when has_file?("Gemfile")
|
37
|
+
logger.debug "You have a Gemfile, so I think this is Ruby."
|
38
|
+
return Languages::Ruby.new(self)
|
39
|
+
when has_file?("Rakefile")
|
40
|
+
logger.debug "You have a Rakefile, so I think this is Ruby."
|
41
|
+
return Languages::Ruby.new(self)
|
42
|
+
when has_file?("*.gemspec")
|
43
|
+
logger.debug "You have a gemspec, so I think this is Ruby."
|
44
|
+
return Languages::Ruby.new(self)
|
45
|
+
when has_file?("package.json")
|
46
|
+
logger.debug "You have a package.json, so I think this is NodeJS."
|
47
|
+
return Languages::NodeJS.new(self)
|
48
|
+
else
|
49
|
+
raise UnknownLanguage
|
50
|
+
end
|
33
51
|
end
|
34
52
|
|
35
53
|
def frameworks
|
36
|
-
language.frameworks.map do |framework_class|
|
54
|
+
detected_frameworks = language.frameworks.map do |framework_class|
|
37
55
|
framework_class.new(self)
|
38
56
|
end
|
57
|
+
logger.debug "Detected your frameworks: #{detected_frameworks}"
|
58
|
+
|
59
|
+
raise UnknownFramework if detected_frameworks.empty?
|
60
|
+
return detected_frameworks
|
39
61
|
end
|
40
62
|
|
41
63
|
def execute(command)
|
data/lib/soundcheck.rb
CHANGED
@@ -10,24 +10,16 @@ class Soundcheck
|
|
10
10
|
self.project = Project.new(Dir.pwd)
|
11
11
|
self.path = path
|
12
12
|
self.options = options
|
13
|
+
|
14
|
+
logger.level = Logger::DEBUG if options[:verbose]
|
15
|
+
logger.debug "Debug logging enabled."
|
13
16
|
end
|
14
17
|
|
15
18
|
def command_to_run
|
16
|
-
commands = []
|
17
19
|
project.frameworks.each do |framework|
|
18
20
|
framework.options = options
|
19
21
|
command = framework.command(*path)
|
20
|
-
|
22
|
+
return command if command
|
21
23
|
end
|
22
|
-
commands.first
|
23
|
-
end
|
24
|
-
|
25
|
-
def requires_spec_helper?
|
26
|
-
`grep -r 'spec_helper' #{@path}`
|
27
|
-
$?.exitstatus == 0 # matched
|
28
|
-
end
|
29
|
-
|
30
|
-
def has_gemfile?
|
31
|
-
File.exist?("Gemfile")
|
32
24
|
end
|
33
25
|
end
|
data/soundcheck.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "soundcheck"
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Marten Veldthuis"]
|
@@ -41,12 +41,17 @@ Gem::Specification.new do |s|
|
|
41
41
|
"fixtures/ruby-cucumber-rspec/spec/with_spec_helper_spec.rb",
|
42
42
|
"fixtures/ruby-cucumber-rspec/spec/without_spec_helper_spec.rb",
|
43
43
|
"fixtures/ruby-cucumber/features/cucumber.feature",
|
44
|
+
"fixtures/ruby-cutest/Rakefile",
|
45
|
+
"fixtures/ruby-cutest/test/foo.rb",
|
46
|
+
"fixtures/ruby-rspec-exception/Rakefile",
|
44
47
|
"fixtures/ruby-rspec-exception/spec/spec_helper.rb",
|
45
48
|
"fixtures/ruby-rspec-exception/spec/with_spec_helper_spec.rb",
|
46
49
|
"fixtures/ruby-rspec-exception/spec/without_spec_helper_spec.rb",
|
50
|
+
"fixtures/ruby-rspec/Rakefile",
|
47
51
|
"fixtures/ruby-rspec/spec/spec_helper.rb",
|
48
52
|
"fixtures/ruby-rspec/spec/with_spec_helper_spec.rb",
|
49
53
|
"fixtures/ruby-rspec/spec/without_spec_helper_spec.rb",
|
54
|
+
"fixtures/ruby-unknown-framework/Gemfile",
|
50
55
|
"lib/soundcheck.rb",
|
51
56
|
"lib/soundcheck/frameworks.rb",
|
52
57
|
"lib/soundcheck/languages.rb",
|
@@ -56,6 +61,7 @@ Gem::Specification.new do |s|
|
|
56
61
|
"spec/soundcheck/frameworks/cucumber_spec.rb",
|
57
62
|
"spec/soundcheck/frameworks/expresso_spec.rb",
|
58
63
|
"spec/soundcheck/frameworks/rspec_spec.rb",
|
64
|
+
"spec/soundcheck/frameworks/ruby_cutest_spec.rb",
|
59
65
|
"spec/soundcheck/frameworks_spec.rb",
|
60
66
|
"spec/soundcheck/languages_spec.rb",
|
61
67
|
"spec/soundcheck/project_spec.rb",
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require 'soundcheck/project'
|
3
|
+
require 'soundcheck/frameworks'
|
4
|
+
|
5
|
+
describe "Frameworks" do
|
6
|
+
let(:project) { Project.new(fixture("null-project")) }
|
7
|
+
|
8
|
+
describe "Ruby Cutest" do
|
9
|
+
# This is for the Ruby library called Cutest,
|
10
|
+
# not the C Unit Testing library called CuTest
|
11
|
+
#
|
12
|
+
# https://github.com/djanowski/cutest
|
13
|
+
|
14
|
+
let(:framework) { Frameworks::RubyCutest.new(project) }
|
15
|
+
|
16
|
+
it "should find the rspec framework" do
|
17
|
+
project.stub!(:root => fixture("ruby-cutest"))
|
18
|
+
framework.present?.should be_true
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should not find when not there" do
|
22
|
+
framework.present?.should be_false
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should work with no args" do
|
26
|
+
framework.command().should == "cutest test/*.rb"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should not do anything when args contain no cutest files" do
|
30
|
+
framework.command("features/a.feature").should == nil
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should work with args" do
|
34
|
+
cmd = framework.command("test/a.rb", "test/b.rb")
|
35
|
+
cmd.should == "cutest test/a.rb test/b.rb"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should filter invalid non-cutest args" do
|
39
|
+
cmd = framework.command("test/a.rb", "features/a.feature")
|
40
|
+
cmd.should == "cutest test/a.rb"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
@@ -19,8 +19,8 @@ describe Project do
|
|
19
19
|
it "should ask the language to determine the frameworks used" do
|
20
20
|
project = Project.new(stub)
|
21
21
|
language = stub
|
22
|
-
language.should_receive(:frameworks).and_return([])
|
23
|
-
project.stub
|
22
|
+
language.should_receive(:frameworks).and_return([stub.as_null_object])
|
23
|
+
project.stub(:language => language)
|
24
24
|
project.frameworks
|
25
25
|
end
|
26
26
|
end
|
data/spec/soundcheck_spec.rb
CHANGED
@@ -23,10 +23,6 @@ describe "Soundcheck" do
|
|
23
23
|
cmd_for.should == "bundle exec rspec spec"
|
24
24
|
end
|
25
25
|
|
26
|
-
it "should run only fast specs" do
|
27
|
-
cmd_for("spec", fast: true).should == "rspec spec/without_spec_helper_spec.rb"
|
28
|
-
end
|
29
|
-
|
30
26
|
it "should return 'bundle exec rspec spec/with_spec_helper_spec.rb'" do
|
31
27
|
cmd_for('spec/with_spec_helper_spec.rb').should == "bundle exec rspec spec/with_spec_helper_spec.rb"
|
32
28
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soundcheck
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-11-06 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &8641460 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '3.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *8641460
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &8640200 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *8640200
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: jeweler
|
38
|
-
requirement: &
|
38
|
+
requirement: &8656340 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.6.4
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *8656340
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rcov
|
49
|
-
requirement: &
|
49
|
+
requirement: &8655680 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *8655680
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: cucumber
|
60
|
-
requirement: &
|
60
|
+
requirement: &8654740 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *8654740
|
69
69
|
description: Soundcheck tries to figure out what kind of project you're working on,
|
70
70
|
what test file you're trying to run, and what the fastest way is to run that.
|
71
71
|
email: marten@veldthuis.com
|
@@ -99,12 +99,17 @@ files:
|
|
99
99
|
- fixtures/ruby-cucumber-rspec/spec/with_spec_helper_spec.rb
|
100
100
|
- fixtures/ruby-cucumber-rspec/spec/without_spec_helper_spec.rb
|
101
101
|
- fixtures/ruby-cucumber/features/cucumber.feature
|
102
|
+
- fixtures/ruby-cutest/Rakefile
|
103
|
+
- fixtures/ruby-cutest/test/foo.rb
|
104
|
+
- fixtures/ruby-rspec-exception/Rakefile
|
102
105
|
- fixtures/ruby-rspec-exception/spec/spec_helper.rb
|
103
106
|
- fixtures/ruby-rspec-exception/spec/with_spec_helper_spec.rb
|
104
107
|
- fixtures/ruby-rspec-exception/spec/without_spec_helper_spec.rb
|
108
|
+
- fixtures/ruby-rspec/Rakefile
|
105
109
|
- fixtures/ruby-rspec/spec/spec_helper.rb
|
106
110
|
- fixtures/ruby-rspec/spec/with_spec_helper_spec.rb
|
107
111
|
- fixtures/ruby-rspec/spec/without_spec_helper_spec.rb
|
112
|
+
- fixtures/ruby-unknown-framework/Gemfile
|
108
113
|
- lib/soundcheck.rb
|
109
114
|
- lib/soundcheck/frameworks.rb
|
110
115
|
- lib/soundcheck/languages.rb
|
@@ -114,6 +119,7 @@ files:
|
|
114
119
|
- spec/soundcheck/frameworks/cucumber_spec.rb
|
115
120
|
- spec/soundcheck/frameworks/expresso_spec.rb
|
116
121
|
- spec/soundcheck/frameworks/rspec_spec.rb
|
122
|
+
- spec/soundcheck/frameworks/ruby_cutest_spec.rb
|
117
123
|
- spec/soundcheck/frameworks_spec.rb
|
118
124
|
- spec/soundcheck/languages_spec.rb
|
119
125
|
- spec/soundcheck/project_spec.rb
|
@@ -134,7 +140,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
134
140
|
version: '0'
|
135
141
|
segments:
|
136
142
|
- 0
|
137
|
-
hash:
|
143
|
+
hash: -2863149779894878725
|
138
144
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
145
|
none: false
|
140
146
|
requirements:
|