monkeytest-win32 0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,26 @@
1
+ require 'fileutils'
2
+ include FileUtils
3
+
4
+ cwd = Dir.getwd
5
+
6
+ unless File.exist?("#{cwd}#{File::SEPARATOR}lib#{File::SEPARATOR}tasks")
7
+ puts "create lib/tasks"
8
+ Dir.mkdir("#{cwd}#{File::SEPARATOR}lib#{File::SEPARATOR}tasks")
9
+ else
10
+ puts "exists lib/tasks"
11
+ end
12
+
13
+ if File.exist?("#{cwd}#{File::SEPARATOR}lib#{File::SEPARATOR}tasks#{File::SEPARATOR}monkey.rake")
14
+ puts "replace lib/tasks/monkey.rake"
15
+ else
16
+ puts "create lib/tasks/monkey.rake"
17
+ end
18
+
19
+ begin
20
+ cp("#{File.dirname(__FILE__)}#{File::SEPARATOR}..#{File::SEPARATOR}lib#{File::SEPARATOR}tasks#{File::SEPARATOR}monkey.rake","#{cwd}#{File::SEPARATOR}lib#{File::SEPARATOR}tasks#{File::SEPARATOR}monkey.rake")
21
+ rescue Exception => e
22
+ puts "There was a problem copying the file!"
23
+ puts e
24
+ end
25
+
26
+ puts "All done!"
@@ -0,0 +1,76 @@
1
+
2
+ module Monkey
3
+
4
+ PATTERN = /.+_test.rb/
5
+ DIRECTORIES = ['./test/unit/','./test/functional/','./test/integration/']
6
+
7
+ def self.run_tests(mode)
8
+ quiet = ((mode.to_s == "quiet") or (mode.to_s == "q"))
9
+ silent = ((mode.to_s == "silent") or (mode.to_s == "s"))
10
+ directories = DIRECTORIES.collect {|dir| File.expand_path(dir) }
11
+ failures = Array.new
12
+ totalTests = totalAsserts = totalErrors = totalFailures = 0
13
+
14
+ directories.each do |dir|
15
+ puts "#{dir.match(/\/([^\/]+)\/?$/)[1].upcase} TESTS:".bold
16
+ Dir.foreach(dir) do |file|
17
+ if file.match(PATTERN)
18
+ print " #{file.ljust(35)}"
19
+
20
+ fullResult = `ruby -C \"#{dir}\" \"#{dir}/#{file}\"`
21
+
22
+ result = fullResult.match(/([\d]+) tests, ([\d]+) assertions, ([\d]+) failures, ([\d]+) errors/) or break
23
+ numTests = result[1].to_i
24
+ numAsserts = result[2].to_i
25
+ numFailures = result[3].to_i
26
+ numErrors = result[4].to_i
27
+
28
+ totalTests += numTests
29
+ totalAsserts += numAsserts
30
+ totalErrors += numErrors
31
+ totalFailures += numFailures
32
+
33
+ print "#{numTests.to_s.rjust(4)} Tests "
34
+ print "#{numAsserts.to_s.rjust(4)} Assertions "
35
+
36
+ if numErrors > 0 then
37
+ puts "ERROR".red
38
+ failures.push fullResult
39
+ elsif numFailures > 0 then
40
+ puts "FAIL".yellow
41
+ failures.push fullResult
42
+ else
43
+ puts "PASS".green
44
+ end
45
+ end
46
+ end
47
+ end
48
+ puts '-'*80
49
+ print "TOTALS:".bold.ljust(38)
50
+ print "#{totalTests.to_s.rjust(4)} Tests "
51
+ print "#{totalAsserts.to_s.rjust(4)} Assertions "
52
+ print "#{(totalFailures+totalErrors).to_s.rjust(4)} Problem(s)\n"
53
+ if silent
54
+ puts "\n"
55
+ elsif quiet
56
+ puts "\n\nErrors & Failures:".bold unless failures.empty?
57
+ failures.each do |badthing|
58
+ while matches = badthing.match(/(Error|Failure):[\s]+(test_[^\()]+)\(([^\)]+)\)([\s]\[[^\]]+\/(.+?):([\d]+)\])?/m) do
59
+ msg = " #{matches[1].ljust(10).red}" if matches[1] == "Error"
60
+ msg = " #{matches[1].ljust(10).yellow}" if matches[1] == "Failure"
61
+ msg << " #{matches[3].underline} : #{matches[2]}"
62
+ msg << " (#{matches[5]}:#{matches[6]})" unless matches[6].nil?
63
+ puts msg
64
+ badthing = matches.post_match
65
+ end
66
+ end
67
+ puts "\n"
68
+ else
69
+ puts "\n\nErrors & Failures:".bold unless failures.empty?
70
+ failures.each do |badthing|
71
+ puts badthing
72
+ puts "\n"
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,53 @@
1
+ # ===================================================
2
+ # A set of rake tasks for running monkey tests.
3
+ # ===================================================
4
+
5
+ begin
6
+ require 'rubygems'
7
+ rescue
8
+ puts "Please install ruby gems."
9
+ exit(1)
10
+ end
11
+
12
+ begin
13
+ require 'win32console'
14
+ include Win32::Console::ANSI
15
+ include Term::ANSIColor
16
+ rescue
17
+ puts "When running on Windows the win32console gem is required."
18
+ end unless system('ls > /dev/null 2> /dev/null')
19
+
20
+ begin
21
+ require 'color'
22
+ require 'monkeytest'
23
+ rescue Exception => e
24
+ puts "The monkeytest gem is required to perform this task,"
25
+ print "Would you like to install this gem now? [y/n]: "
26
+ answer = STDIN.gets
27
+ print "\n"
28
+ if answer.upcase[0].chr == 'Y'
29
+ unless system('gem install monkeytest -y')
30
+ puts "\nLet's try that again... this time with sudo!\n"
31
+ system('sudo gem install monkeytest -y')
32
+ end
33
+ puts "Everything should be in place, go ahead and give 'er another try."
34
+ end
35
+ exit(1)
36
+ end
37
+
38
+ namespace :test do
39
+ namespace :monkey do
40
+ desc "Outputs per-file summary only."
41
+ task :silent do
42
+ Monkey.run_tests(:silent)
43
+ end
44
+ desc "Outputs per-file summary as well as a method level summaries."
45
+ task :quiet do
46
+ Monkey.run_tests(:quiet)
47
+ end
48
+ end
49
+ desc "Outputs per-file summary as well as full failure messages."
50
+ task :monkey do
51
+ Monkey.run_tests(:normal)
52
+ end
53
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.8.11
3
+ specification_version: 1
4
+ name: monkeytest-win32
5
+ version: !ruby/object:Gem::Version
6
+ version: "0.1"
7
+ date: 2006-10-26 00:00:00 -04:00
8
+ summary: A set of rake tasks for pretty testing of rails apps.
9
+ require_paths:
10
+ - lib
11
+ email: geoffrey.parsons@gmail.com
12
+ homepage:
13
+ rubyforge_project:
14
+ description:
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: false
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.8.4
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ authors:
29
+ - Marshall Huss
30
+ files:
31
+ - lib/tasks/monkey.rake
32
+ - lib/monkeytest.rb
33
+ test_files: []
34
+
35
+ rdoc_options: []
36
+
37
+ extra_rdoc_files: []
38
+
39
+ executables:
40
+ - monkeytest
41
+ extensions: []
42
+
43
+ requirements: []
44
+
45
+ dependencies:
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Version::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 0.7.1
54
+ version:
55
+ - !ruby/object:Gem::Dependency
56
+ name: color
57
+ version_requirement:
58
+ version_requirements: !ruby/object:Gem::Version::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 0.1.0
63
+ version:
64
+ - !ruby/object:Gem::Dependency
65
+ name: win32console
66
+ version_requirement:
67
+ version_requirements: !ruby/object:Gem::Version::Requirement
68
+ requirements:
69
+ - - "="
70
+ - !ruby/object:Gem::Version
71
+ version: 1.0.8
72
+ version: