Permalink
Browse files

initial project commit

  • Loading branch information...
TwP committed Jan 6, 2008
0 parents commit a2a4ddecfa061d539477e97590ea0607302f385d
Showing with 726 additions and 0 deletions.
  1. +15 −0 History.txt
  2. +13 −0 Manifest.txt
  3. +103 −0 README.txt
  4. +19 −0 Rakefile
  5. +14 −0 bin/turn
  6. +101 −0 lib/turn.rb
  7. +30 −0 tasks/annotations.rake
  8. +49 −0 tasks/doc.rake
  9. +89 −0 tasks/gem.rake
  10. +41 −0 tasks/manifest.rake
  11. +57 −0 tasks/rubyforge.rake
  12. +151 −0 tasks/setup.rb
  13. +44 −0 tasks/svn.rake
@@ -0,0 +1,15 @@
+== 0.3.0 / 2007-12-11
+ * color highlighting now works (need facets-2.0 library)
+
+== 0.2.0 / 2006-11-26
+ * add the "turn" executable
+ * fixed warnings
+
+== 0.1.2 / 2006-11-13
+ * added some instructions for using the package
+
+== 0.1.1 / 2006-11-10
+ * removed explicit dependency on the 'hoe' gem
+
+== 0.1.0 / 2006-11-10
+ * initial release
@@ -0,0 +1,13 @@
+History.txt
+Manifest.txt
+README.txt
+Rakefile
+bin/turn
+lib/turn.rb
+tasks/annotations.rake
+tasks/doc.rake
+tasks/gem.rake
+tasks/manifest.rake
+tasks/rubyforge.rake
+tasks/setup.rb
+tasks/svn.rake
@@ -0,0 +1,103 @@
+= TURN - Test::Unit Reporter (New)
+ by Tim Pease
+ http://codeforpeople.rubyforge.org/turn
+
+== DESCRIPTION:
+
+TURN is a new way to view Test::Unit results. With longer running tests, it
+can be very frustrating to see a failure (....F...) and then have to wait till
+all the tests finish before you can see what the exact failure was. TURN
+displays each test on a separate line with failures being displayed
+immediately instead of at the end of the tests.
+
+If you have the 'facets' gem installed, then TURN output will be displayed in
+wonderful technicolor (but only if your terminal supports ANSI color codes).
+Well, the only colors are green and red, but that is still color.
+
+== FEATURES:
+
+Sample output:
+
+ TestMyClass
+ test_alt PASS
+ test_alt_eq PASS
+ test_bad FAIL
+ ./test/test_my_class.rb:64:in `test_bad'
+ <false> is not true.
+ test_foo PASS
+ test_foo_eq PASS
+ TestYourClass
+ test_method_a PASS
+ test_method_b PASS
+ test_method_c PASS
+ ============================================================================
+ pass: 7, fail: 1, error: 0
+ total: 15 tests with 42 assertions in 0.018 seconds
+ ============================================================================
+
+== SYNOPSIS:
+
+If you have the 'facets' gem installed, then TURN output will be displayed in
+wonderful technicolor (but only if your terminal supports ANSI color codes).
+Well, the only colors are green and red, but that is still color.
+
+
+=== Command Line
+
+You can use the *turn* executable in place of the *ruby* interpreter.
+
+ turn -Ilib test/test_all.rb
+
+This will invoke the ruby interpreter and automatically require the turn
+formatting library. All command line arguments are passed "as is" to the
+ruby interpreter.
+
+=== Require
+
+Simply require the TURN package from within your test suite.
+
+ require 'turn'
+
+This will configure Test::Unit to use TURN formatting for displaying test
+restuls. A better line to use, though, is the following:
+
+ begin; require 'turn'; rescue LoadError; end
+
+When you distribute your code, the test suite can be run without requiring
+the end user to install the TURN package.
+
+For a Rails application, put the require line into the 'test/test_helper.rb'
+scipt. Now your Rails tests will use TURN formatting.
+
+== REQUIREMENTS:
+
+* facets 2.0
+
+== INSTALL:
+
+ sudo gem install turn
+
+== LICENSE:
+
+MIT License
+
+Copyright (c) 2006-2008
+
+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.
@@ -0,0 +1,19 @@
+# $Id$
+
+load 'tasks/setup.rb'
+
+PROJ.name = 'turn'
+PROJ.summary = 'Test::Unit Reporter (New) -- new output format for Test::Unit'
+PROJ.authors = 'Tim Pease'
+PROJ.email = 'tim.pease@gmail.com'
+PROJ.url = 'http://codeforpeople.rubyforge.org/turn'
+PROJ.description = paragraphs_of('README.txt', 1).join("\n\n")
+PROJ.changes = paragraphs_of('History.txt', 0..1).join("\n\n")
+PROJ.rubyforge_name = 'codeforpeople'
+PROJ.version = '0.3.0'
+
+PROJ.rdoc_exclude << '^lib/'
+PROJ.rdoc_remote_dir = PROJ.name
+PROJ.svn = PROJ.name
+
+# EOF
@@ -0,0 +1,14 @@
+#!/usr/bin/ruby
+
+RUBY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
+
+begin
+ require 'turn'
+ Kernel.exec(RUBY, '-r', 'turn', *ARGV)
+rescue LoadError
+ require 'rubygems'
+ require 'turn'
+ Kernel.exec(RUBY, '-rubygems', '-r', 'turn', *ARGV)
+end
+
+# EOF
@@ -0,0 +1,101 @@
+# $Id$
+
+require 'test/unit/ui/console/testrunner'
+begin
+ require 'facets/ansicode'
+rescue LoadError
+ begin
+ require 'rubygems'
+ require 'facets/ansicode'
+ rescue LoadError
+ end
+end
+
+
+module ::Test::Unit
+module UI
+module Console
+ class TestRunner
+
+ alias :t_attach_to_mediator :attach_to_mediator
+ def attach_to_mediator
+ @mediator.add_listener(TestRunnerMediator::STARTED, &method(:t_started))
+ @mediator.add_listener(TestRunnerMediator::FINISHED, &method(:t_finished))
+ @mediator.add_listener(TestCase::STARTED, &method(:t_test_started))
+ @mediator.add_listener(TestCase::FINISHED, &method(:t_test_finished))
+ @mediator.add_listener(TestResult::FAULT, &method(:t_fault))
+ @io.sync = true
+ @t_cur_file, @t_fault = nil
+ end
+
+ def t_started( result )
+ @t_result = result
+ end
+
+ def t_finished( elapsed_time )
+ failure = @t_result.failure_count
+ error = @t_result.error_count
+ total = @t_result.run_count
+ pass = total - failure - error
+
+ bar = '=' * 78
+ if COLORIZE
+ bar = if pass == total then ::Console::ANSICode.green bar
+ else ::Console::ANSICode.red bar end
+ end
+
+ @io.puts bar
+ @io.puts " pass: %d, fail: %d, error: %d" % [pass, failure, error]
+ @io.puts " total: %d tests with %d assertions in #{elapsed_time} seconds" % [total, @t_result.assertion_count]
+ @io.puts bar
+ end
+
+ def t_test_started( name )
+ method, file = name.scan(%r/^([^\(]+)\(([^\)]+)\)/o).flatten!
+ if @t_cur_file != file
+ @t_cur_file = file
+ @io.puts file
+ end
+ @io.print " %-69s" % method
+ end
+
+ def t_test_finished( name )
+ @io.puts PASS unless @t_fault
+ @t_fault = false
+ end
+
+ def t_fault( fault )
+ @t_fault = true
+ msg = "\t"
+
+ case fault
+ when ::Test::Unit::Error
+ @io.puts ERROR
+ msg << fault.to_s.split("\n")[2..-1].join("\n\t")
+ when ::Test::Unit::Failure
+ @io.puts FAIL
+ msg << fault.location[0] << "\n\t"
+ msg << fault.message.gsub("\n","\n\t")
+ end
+
+ msg = ::Console::ANSICode.magenta msg if COLORIZE
+ @io.puts msg
+ end
+
+ COLORIZE = defined?(::Console::ANSICode) && ENV.has_key?('TERM')
+ if COLORIZE
+ PASS = ::Console::ANSICode.green ' PASS'
+ FAIL = ::Console::ANSICode.red ' FAIL'
+ ERROR = ::Console::ANSICode.white(
+ ::Console::ANSICode.on_red('ERROR'))
+ else
+ PASS = " PASS"
+ FAIL = " FAIL"
+ ERROR = "ERROR"
+ end
+ end
+end
+end
+end
+
+# EOF
@@ -0,0 +1,30 @@
+# $Id$
+
+if HAVE_BONES
+
+desc "Enumerate all annotations"
+task :notes do
+ Bones::AnnotationExtractor.enumerate(
+ PROJ, "OPTIMIZE|FIXME|TODO", :tag => true)
+end
+
+namespace :notes do
+ desc "Enumerate all OPTIMIZE annotations"
+ task :optimize do
+ Bones::AnnotationExtractor.enumerate(PROJ, "OPTIMIZE")
+ end
+
+ desc "Enumerate all FIXME annotations"
+ task :fixme do
+ Bones::AnnotationExtractor.enumerate(PROJ, "FIXME")
+ end
+
+ desc "Enumerate all TODO annotations"
+ task :todo do
+ Bones::AnnotationExtractor.enumerate(PROJ, "TODO")
+ end
+end
+
+end # if HAVE_BONES
+
+# EOF
@@ -0,0 +1,49 @@
+# $Id$
+
+require 'rake/rdoctask'
+
+namespace :doc do
+
+ desc 'Generate RDoc documentation'
+ Rake::RDocTask.new do |rd|
+ rd.main = PROJ.rdoc_main
+ rd.options << '-d' if !WIN32 and `which dot` =~ %r/\/dot/
+ rd.rdoc_dir = PROJ.rdoc_dir
+
+ incl = Regexp.new(PROJ.rdoc_include.join('|'))
+ excl = Regexp.new(PROJ.rdoc_exclude.join('|'))
+ files = PROJ.files.find_all do |fn|
+ case fn
+ when excl; false
+ when incl; true
+ else false end
+ end
+ rd.rdoc_files.push(*files)
+
+ title = "#{PROJ.name}-#{PROJ.version} Documentation"
+ title = "#{PROJ.rubyforge_name}'s " + title if PROJ.rubyforge_name != title
+
+ rd.options << "-t #{title}"
+ end
+
+ desc 'Generate ri locally for testing'
+ task :ri => :clobber_ri do
+ sh "#{RDOC} --ri -o ri ."
+ end
+
+ desc 'Remove ri products'
+ task :clobber_ri do
+ rm_r 'ri' rescue nil
+ end
+
+end # namespace :doc
+
+desc 'Alias to doc:rdoc'
+task :doc => 'doc:rdoc'
+
+desc 'Remove all build products'
+task :clobber => %w(doc:clobber_rdoc doc:clobber_ri)
+
+remove_desc_for_task %w(doc:clobber_rdoc doc:clobber_ri)
+
+# EOF
Oops, something went wrong.

0 comments on commit a2a4dde

Please sign in to comment.