exemplor-chaser 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ History for exemplor-chaser:
2
+
3
+ === 0.0.2 / 2009-11-14
4
+
5
+ * 1 major enhancement
6
+
7
+ * Birthday! (As a separate gem)
@@ -0,0 +1,7 @@
1
+ exemplor-chaser.gemspec
2
+ History.txt
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ bin/exemplor-chaser
7
+ lib/exemplor-chaser.rb
@@ -0,0 +1,43 @@
1
+ == DESCRIPTION:
2
+
3
+ Exemplor Chaser is a runner for Chaser against Exemplor.
4
+
5
+ == FEATURES/PROBLEMS:
6
+
7
+ * Timeout option may not work properly.
8
+ * This gem doesn't have any tests of itself.
9
+
10
+ == REQUIREMENTS:
11
+
12
+ * Exemplor
13
+ * Chaser
14
+
15
+ == INSTALL:
16
+
17
+ * Add gemcutter as a gem source.
18
+ * sudo gem install exemplor-chaser
19
+
20
+ == LICENSE:
21
+
22
+ (The MIT License)
23
+
24
+ Copyright (c) 2006-2009 Ryan Davis and Kevin Clark and Andrew Grimm
25
+
26
+ Permission is hereby granted, free of charge, to any person obtaining
27
+ a copy of this software and associated documentation files (the
28
+ 'Software'), to deal in the Software without restriction, including
29
+ without limitation the rights to use, copy, modify, merge, publish,
30
+ distribute, sublicense, and/or sell copies of the Software, and to
31
+ permit persons to whom the Software is furnished to do so, subject to
32
+ the following conditions:
33
+
34
+ The above copyright notice and this permission notice shall be
35
+ included in all copies or substantial portions of the Software.
36
+
37
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
38
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
39
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
40
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
41
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
42
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
43
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,16 @@
1
+ begin
2
+ require 'jeweler'
3
+ require File.dirname(__FILE__) + "/lib/exemplor-chaser.rb"
4
+ Jeweler::Tasks.new do |gemspec|
5
+ gemspec.name = "exemplor-chaser"
6
+ gemspec.summary = "Runner for chaser against exemplor"
7
+ gemspec.description = "Lightweight mutation testing against exemplor"
8
+ gemspec.email = "andrew.j.grimm@gmail.com"
9
+ gemspec.authors = ["Andrew Grimm", "Ryan Davis", "Eric Hodel", "Kevin Clark"]
10
+ gemspec.add_dependency('exemplor', '>= 2000.2.0')
11
+ gemspec.version = ExemplorChaser::VERSION
12
+ gemspec.homepage = "http://andrewjgrimm.wordpress.com/2009/11/08/declare-war-on-everything-with-chaser/"
13
+ end
14
+ rescue LoadError
15
+ puts "Jeweler not available. Install it with: sudo gem install jeweler"
16
+ end
@@ -0,0 +1,55 @@
1
+ #!/usr/local/bin/ruby
2
+
3
+ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
4
+ require 'exemplor-chaser'
5
+ require 'optparse'
6
+
7
+ force = false
8
+
9
+ opts = OptionParser.new do |opts|
10
+ opts.banner = "Usage: #{File.basename($0)} class_name [method_name]"
11
+ opts.on("-v", "--verbose", "Loudly explain chaser run") do |opt|
12
+ ExemplorChaser.debug = true
13
+ end
14
+
15
+ opts.on("-V", "--version", "Prints exemplor-chaser's version number") do |opt|
16
+ puts "exemplor-chaser #{ExemplorChaser::VERSION}"
17
+ exit 0
18
+ end
19
+
20
+ opts.on("-t", "--tests TEST_PATTERN",
21
+ "Location of examples (glob). Unix-style even on Windows, so use forward slashes.") do |pattern|
22
+ ExemplorChaser.test_pattern = pattern
23
+ end
24
+
25
+ opts.on("-F", "--force", "Ignore initial exemplor failures") do |opt|
26
+ force = true
27
+ end
28
+
29
+ opts.on("-T", "--timeout SECONDS", "The maximum time for an exemplor run in seconds",
30
+ "Used to catch infinite loops") do |timeout|
31
+ Chaser.timeout = timeout.to_i
32
+ puts "Setting timeout at #{timeout} seconds."
33
+ end
34
+
35
+ opts.on("-h", "--help", "Show this message") do |opt|
36
+ puts opts
37
+ exit 0
38
+ end
39
+ end
40
+
41
+ looks_like_rails = test ?f, 'config/environment.rb'
42
+ ExemplorChaser.test_pattern = "examples/**/*.rb" if looks_like_rails
43
+
44
+ opts.parse!
45
+
46
+ impl = ARGV.shift
47
+ meth = ARGV.shift
48
+
49
+ unless impl then
50
+ puts opts
51
+ exit 1
52
+ end
53
+
54
+ exit ExemplorChaser.validate(impl, meth, force)
55
+
@@ -0,0 +1,48 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{exemplor-chaser}
8
+ s.version = "0.0.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Andrew Grimm", "Ryan Davis", "Eric Hodel", "Kevin Clark"]
12
+ s.date = %q{2009-11-15}
13
+ s.default_executable = %q{exemplor-chaser}
14
+ s.description = %q{Lightweight mutation testing against exemplor}
15
+ s.email = %q{andrew.j.grimm@gmail.com}
16
+ s.executables = ["exemplor-chaser"]
17
+ s.extra_rdoc_files = [
18
+ "README.txt"
19
+ ]
20
+ s.files = [
21
+ "History.txt",
22
+ "Manifest.txt",
23
+ "README.txt",
24
+ "Rakefile",
25
+ "bin/exemplor-chaser",
26
+ "exemplor-chaser.gemspec",
27
+ "lib/exemplor-chaser.rb"
28
+ ]
29
+ s.homepage = %q{http://andrewjgrimm.wordpress.com/2009/11/08/declare-war-on-everything-with-chaser/}
30
+ s.rdoc_options = ["--charset=UTF-8"]
31
+ s.require_paths = ["lib"]
32
+ s.rubygems_version = %q{1.3.5}
33
+ s.summary = %q{Runner for chaser against exemplor}
34
+
35
+ if s.respond_to? :specification_version then
36
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
37
+ s.specification_version = 3
38
+
39
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
40
+ s.add_runtime_dependency(%q<exemplor>, [">= 2000.2.0"])
41
+ else
42
+ s.add_dependency(%q<exemplor>, [">= 2000.2.0"])
43
+ end
44
+ else
45
+ s.add_dependency(%q<exemplor>, [">= 2000.2.0"])
46
+ end
47
+ end
48
+
@@ -0,0 +1,100 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'exemplor'
4
+ require 'chaser'
5
+
6
+ # Exemplor doesn't have passthrough exceptions.
7
+
8
+ class ExemplorChaser < Chaser
9
+
10
+ VERSION = '0.0.2'
11
+
12
+ @@test_pattern = 'examples/_examples*.rb' # Fixme what's idiomatic here?
13
+ @@tests_loaded = false
14
+
15
+ def self.test_pattern=(value)
16
+ @@test_pattern = value
17
+ end
18
+
19
+ def self.load_test_files
20
+ @@tests_loaded = true
21
+ raise "Can't detect any files in test pattern \"#{@@test_pattern}\"#{WINDOZE ? " Are you remembering to use forward slashes?" : ""}" if Dir.glob(@@test_pattern).empty?
22
+ Dir.glob(@@test_pattern).each {|test| require test}
23
+ end
24
+
25
+ def self.validate(klass_name, method_name = nil, force = false)
26
+ load_test_files
27
+ klass = klass_name.to_class
28
+
29
+ # Does the method exist?
30
+ klass_methods = klass.singleton_methods(false).collect {|meth| "self.#{meth}"}
31
+ if method_name
32
+ if method_name =~ /self\./
33
+ abort "Unknown method: #{klass_name}.#{method_name.gsub('self.', '')}" unless klass_methods.include? method_name
34
+ else
35
+ abort "Unknown method: #{klass_name}##{method_name}" unless klass.instance_methods(false).map{|sym| sym.to_s}.include? method_name
36
+ end
37
+ end
38
+
39
+ initial_time = Time.now
40
+
41
+ chaser = self.new(klass_name)
42
+
43
+ passed = chaser.tests_pass?
44
+
45
+ unless force or passed then
46
+ abort "Initial run of examples failed... fix and run chaser again"
47
+ end
48
+
49
+ if self.guess_timeout? then
50
+ running_time = Time.now - initial_time
51
+ adjusted_timeout = (running_time * 2 < 5) ? 5 : (running_time * 2).ceil
52
+ self.timeout = adjusted_timeout
53
+ end
54
+
55
+ puts "Timeout set to #{adjusted_timeout} seconds."
56
+
57
+ if passed then
58
+ puts "Initial examples pass. Let's rumble."
59
+ else
60
+ puts "Initial examples failed but you forced things. Let's rumble."
61
+ end
62
+ puts
63
+
64
+ methods = method_name ? Array(method_name) : klass.instance_methods(false) + klass_methods
65
+
66
+ counts = Hash.new(0)
67
+ methods.sort.each do |method_name|
68
+ result = self.new(klass_name, method_name).validate
69
+ counts[result] += 1
70
+ end
71
+ all_good = counts[false] == 0
72
+
73
+ puts "Chaser Results:"
74
+ puts
75
+ puts "Passed : %3d" % counts[true]
76
+ puts "Failed : %3d" % counts[false]
77
+ puts
78
+
79
+ if all_good then
80
+ puts "All chasing was thwarted! YAY!!!"
81
+ else
82
+ puts "Improve the tests and try again."
83
+ end
84
+
85
+ all_good
86
+ end
87
+
88
+ def initialize(klass_name=nil, method_name=nil)
89
+ super
90
+ self.class.load_test_files unless @@tests_loaded
91
+ end
92
+
93
+ def tests_pass?
94
+ silence_stream do
95
+ result = Exemplor.examples.run([]).zero?
96
+ ARGV.clear
97
+ result
98
+ end
99
+ end
100
+ end
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: exemplor-chaser
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Andrew Grimm
8
+ - Ryan Davis
9
+ - Eric Hodel
10
+ - Kevin Clark
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+
15
+ date: 2009-11-15 00:00:00 +11:00
16
+ default_executable: exemplor-chaser
17
+ dependencies:
18
+ - !ruby/object:Gem::Dependency
19
+ name: exemplor
20
+ type: :runtime
21
+ version_requirement:
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 2000.2.0
27
+ version:
28
+ description: Lightweight mutation testing against exemplor
29
+ email: andrew.j.grimm@gmail.com
30
+ executables:
31
+ - exemplor-chaser
32
+ extensions: []
33
+
34
+ extra_rdoc_files:
35
+ - README.txt
36
+ files:
37
+ - History.txt
38
+ - Manifest.txt
39
+ - README.txt
40
+ - Rakefile
41
+ - bin/exemplor-chaser
42
+ - exemplor-chaser.gemspec
43
+ - lib/exemplor-chaser.rb
44
+ has_rdoc: true
45
+ homepage: http://andrewjgrimm.wordpress.com/2009/11/08/declare-war-on-everything-with-chaser/
46
+ licenses: []
47
+
48
+ post_install_message:
49
+ rdoc_options:
50
+ - --charset=UTF-8
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: "0"
58
+ version:
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: "0"
64
+ version:
65
+ requirements: []
66
+
67
+ rubyforge_project:
68
+ rubygems_version: 1.3.5
69
+ signing_key:
70
+ specification_version: 3
71
+ summary: Runner for chaser against exemplor
72
+ test_files: []
73
+