Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
196 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.9.3-p0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source 'https://rubygems.org' | ||
|
||
# Specify your gem's dependencies in wtf.gemspec | ||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
m (0.0.1) | ||
ruby_parser (~> 2.3.1) | ||
|
||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
rake (0.9.2.2) | ||
ruby_parser (2.3.1) | ||
sexp_processor (~> 3.0) | ||
sexp_processor (3.0.9) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
m! | ||
rake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright (c) 2011 Nick Quaranto | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# m | ||
|
||
`m` stands :metal: (metal), which is a better test/unit test runner. @sferik took `t` so this was the next best option. | ||
|
||
## Usage | ||
|
||
Basically, I was sick of using the `-n` flag to grab one test to run, like RSpec's test runner works. | ||
|
||
Given this file: | ||
|
||
$ cat -n test/example_test.rb | ||
1 require 'test/unit' | ||
2 | ||
3 class ExampleTest < Test::Unit::TestCase | ||
4 def test_apple | ||
5 assert_equal 1, 1 | ||
6 end | ||
7 | ||
8 def test_banana | ||
9 assert_equal 1, 1 | ||
10 end | ||
11 end | ||
|
||
You can run a test by line number, using format `m TEST_FILE:LINE_NUMBER_OF_TEST`: | ||
|
||
$ m test/example_test.rb:4 | ||
Run options: -n /test_apple/ | ||
|
||
# Running tests: | ||
|
||
. | ||
|
||
Finished tests in 0.000525s, 1904.7619 tests/s, 1904.7619 assertions/s. | ||
|
||
1 tests, 1 assertions, 0 failures, 0 errors, 0 skips | ||
|
||
## License | ||
|
||
This gem is MIT licensed, please see `LICENSE` for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env rake | ||
require "bundler/gem_tasks" | ||
require "rake/testtask" | ||
|
||
task :default => :test | ||
|
||
Rake::TestTask.new do |t| | ||
t.libs << 'test' | ||
t.pattern = 'test/*_test.rb' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require 'ruby_parser' | ||
require 'pp' | ||
|
||
file, line = ARGV.first.split(':') | ||
|
||
if line | ||
parser = RubyParser.new | ||
r = parser.parse(File.read(file)) | ||
r.each_of_type(:defn) do |s| | ||
if s.line == line.to_i | ||
method_name = s.sexp_body.first | ||
exec "ruby -Itest #{file} -n '/#{method_name}/'" | ||
end | ||
end | ||
else | ||
exec "ruby -Itest #{file}" | ||
end | ||
require 'm' | ||
M.run(ARGV) | ||
#require 'ruby_parser' | ||
#require 'pp' | ||
# | ||
#file, line = ARGV.first.split(':') | ||
# | ||
#if line | ||
# parser = RubyParser.new | ||
# r = parser.parse(File.read(file)) | ||
# r.each_of_type(:defn) do |s| | ||
# if s.line == line.to_i | ||
# method_name = s.sexp_body.first | ||
# exec "ruby -Itest #{file} -n '/#{method_name}/'" | ||
# end | ||
# end | ||
#else | ||
# exec "ruby -Itest #{file}" | ||
#end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require "ruby_parser" | ||
|
||
require "m/version" | ||
|
||
module M | ||
class Runner | ||
def initialize(argv) | ||
@file, @line = argv.first.split(':') | ||
end | ||
|
||
def run | ||
if @line | ||
parser = RubyParser.new | ||
sexps = parser.parse(File.read(@file)) | ||
sexps.each_of_type(:defn) do |sexp| | ||
if sexp.line == @line.to_i | ||
method_name = sexp.sexp_body.first | ||
run_tests method_name | ||
end | ||
end | ||
else | ||
run_tests | ||
end | ||
end | ||
|
||
private | ||
|
||
def run_tests(method_name = nil) | ||
command = "ruby -Itest #{@file}" | ||
command << " -n '/#{method_name}/'" if method_name | ||
exec command | ||
end | ||
end | ||
|
||
def self.run(argv) | ||
Runner.new(argv).run | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module M | ||
VERSION = "0.0.1" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Gem::Specification.new do |gem| | ||
gem.authors = ["Nick Quaranto"] | ||
gem.email = ["nick@quaran.to"] | ||
gem.description = %q{TODO: Write a gem description} | ||
gem.summary = %q{TODO: Write a gem summary} | ||
gem.homepage = "" | ||
|
||
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } | ||
gem.files = `git ls-files`.split("\n") | ||
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") | ||
gem.name = "m" | ||
gem.require_paths = ["lib"] | ||
gem.version = "0.0.1" | ||
|
||
gem.add_runtime_dependency "ruby_parser", "~> 2.3.1" | ||
gem.add_development_dependency "rake" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require 'test_helper' | ||
|
||
class RunByLineNumberTest < MTest | ||
def test_run_simple_test_by_line_number | ||
output = m('test/example_test.rb:4') | ||
|
||
assert $?.success?, "Execution failed, output:\n\n#{output}" | ||
assert_match /1 tests, 1 assertions/, output | ||
end | ||
|
||
def test_runs_entire_test_without_line_number | ||
output = m('test/example_test.rb') | ||
|
||
assert $?.success?, "Execution failed, output:\n\n#{output}" | ||
assert_match /2 tests, 2 assertions/, output | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'test/unit' | ||
|
||
class MTest < Test::Unit::TestCase | ||
def m(arguments) | ||
`ruby -Ilib ./bin/m #{arguments}`.strip | ||
end | ||
end |