iocheck 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -4
- data/lib/iocheck/policy.rb +26 -23
- data/lib/iocheck/test.rb +20 -5
- data/lib/iocheck/tester.rb +22 -2
- metadata +11 -11
data/README.md
CHANGED
@@ -22,7 +22,7 @@ without any learning cost.
|
|
22
22
|
## Installation
|
23
23
|
iocheck can be installed from rubygems repository, just type
|
24
24
|
|
25
|
-
```
|
25
|
+
```
|
26
26
|
gem install iocheck
|
27
27
|
```
|
28
28
|
|
@@ -36,6 +36,5 @@ gem install iocheck
|
|
36
36
|
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
37
37
|
|
38
38
|
## Copyright
|
39
|
-
Copyright (c) 2011 Akira Hayakawa (@akiradeveloper).
|
40
|
-
further details.
|
41
|
-
|
39
|
+
Copyright (c) 2011 Akira Hayakawa (@akiradeveloper).
|
40
|
+
See LICENSE.txt for further details.
|
data/lib/iocheck/policy.rb
CHANGED
@@ -6,13 +6,13 @@ module IOCheck
|
|
6
6
|
end
|
7
7
|
attr_reader :result
|
8
8
|
|
9
|
-
# Expected -> Actual ->
|
10
|
-
def evaluate(
|
9
|
+
# Expected -> Actual -> Success or Failure
|
10
|
+
def evaluate( test )
|
11
11
|
raise NoMethodError, "You must override this method."
|
12
12
|
end
|
13
13
|
|
14
|
-
def run!(
|
15
|
-
@result = evaluate(
|
14
|
+
def run!( test )
|
15
|
+
@result = evaluate( test )
|
16
16
|
end
|
17
17
|
|
18
18
|
class Success
|
@@ -25,37 +25,40 @@ module IOCheck
|
|
25
25
|
attr_reader :log
|
26
26
|
end
|
27
27
|
|
28
|
-
class Either
|
29
|
-
def initialize(pred, log)
|
30
|
-
if pred
|
31
|
-
@stat = ::IOCheck::Policy::Success.new
|
32
|
-
else
|
33
|
-
@stat = ::IOCheck::Policy::Failure.new(log)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
def evaluate
|
37
|
-
@stat
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
28
|
class Block < Policy
|
42
29
|
def initialize(&blk)
|
43
30
|
super
|
44
31
|
@blk = blk
|
45
32
|
end
|
46
33
|
|
47
|
-
def evaluate(
|
48
|
-
@blk.call(
|
34
|
+
def evaluate( test )
|
35
|
+
@blk.call( test )
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.succeed_if( pred, log )
|
40
|
+
if pred
|
41
|
+
return Success.new
|
42
|
+
else
|
43
|
+
return Failure.new(log)
|
49
44
|
end
|
50
45
|
end
|
51
46
|
|
52
47
|
def self.by_bytes
|
53
|
-
Block.new do |
|
48
|
+
Block.new do |test|
|
54
49
|
# TODO: Better to show the diff to the user.
|
55
|
-
|
56
|
-
|
57
|
-
|
50
|
+
succeed_if(
|
51
|
+
test.actual.bytes == test.expected.bytes,
|
52
|
+
by_bytes_log( test ))
|
58
53
|
end
|
59
54
|
end
|
55
|
+
|
56
|
+
def self.by_bytes_log( test )
|
57
|
+
"Bytes not exactly matched.\n" +
|
58
|
+
"--------------------------\n" +
|
59
|
+
"expected :\n#{test.expected.bytes}\n" +
|
60
|
+
"--------------------------\n" +
|
61
|
+
"actual :\n#{test.actual.bytes}"
|
62
|
+
end
|
60
63
|
end # end of class Policy
|
61
64
|
end # end of module IOCheck
|
data/lib/iocheck/test.rb
CHANGED
@@ -40,9 +40,11 @@ module IOCheck
|
|
40
40
|
end
|
41
41
|
|
42
42
|
class Test
|
43
|
+
|
43
44
|
def initialize(cmd)
|
44
45
|
@command = Command.new(cmd)
|
45
|
-
@policies = [
|
46
|
+
@policies = []
|
47
|
+
@policies << Policy.by_bytes
|
46
48
|
@repeat = 1
|
47
49
|
@desc = ""
|
48
50
|
end
|
@@ -86,13 +88,21 @@ module IOCheck
|
|
86
88
|
def run!
|
87
89
|
do_run!
|
88
90
|
@policies.each do |p|
|
89
|
-
p.run!(
|
91
|
+
p.run!( self )
|
90
92
|
end
|
91
93
|
end
|
92
94
|
|
93
95
|
def ready
|
94
96
|
RakeTask.new(self).create_tasks
|
95
97
|
end
|
98
|
+
|
99
|
+
# Regard as success iff all the minor tests were end in success.
|
100
|
+
def succeeded?
|
101
|
+
@policies.each do |p|
|
102
|
+
return false if p.result.class == ::IOCheck::Policy::Failure
|
103
|
+
end
|
104
|
+
return true
|
105
|
+
end
|
96
106
|
|
97
107
|
def show
|
98
108
|
n_success = 0
|
@@ -108,7 +118,7 @@ module IOCheck
|
|
108
118
|
raise Error
|
109
119
|
end
|
110
120
|
end
|
111
|
-
puts "
|
121
|
+
puts "Command : #{@command.cmd}"
|
112
122
|
puts "Description : #{@desc}"
|
113
123
|
puts "Minor Success : #{n_success}"
|
114
124
|
puts "Minor Failure : #{n_failure}"
|
@@ -116,12 +126,17 @@ module IOCheck
|
|
116
126
|
puts log.join("\n")
|
117
127
|
end
|
118
128
|
|
119
|
-
private
|
120
|
-
|
121
129
|
def expected
|
122
130
|
Expected.new(self)
|
123
131
|
end
|
124
132
|
|
133
|
+
def actual
|
134
|
+
@command.actual
|
135
|
+
end
|
136
|
+
|
137
|
+
attr_reader :command
|
138
|
+
|
139
|
+
private
|
125
140
|
class Command
|
126
141
|
def initialize(cmd)
|
127
142
|
@cmd = cmd
|
data/lib/iocheck/tester.rb
CHANGED
@@ -26,8 +26,10 @@ module IOCheck
|
|
26
26
|
t.ready
|
27
27
|
end
|
28
28
|
namespace "iocheck" do
|
29
|
+
desc( "update all the tests except locked ones" )
|
29
30
|
task "update" => @tests.map { |t| "iocheck:update:#{t.name}" }
|
30
31
|
end
|
32
|
+
desc( "run all the tests" )
|
31
33
|
task "iocheck" do
|
32
34
|
run!
|
33
35
|
show
|
@@ -41,6 +43,7 @@ module IOCheck
|
|
41
43
|
dir = ::IOCheck::Env["dir"]
|
42
44
|
|
43
45
|
namespace "iocheck" do
|
46
|
+
desc( "lock all unlocked files." )
|
44
47
|
task "lock" => unlocked.map { |t| "iocheck:lock:#{t.name}" }
|
45
48
|
unlocked.each do |t|
|
46
49
|
namespace "lock" do
|
@@ -50,6 +53,7 @@ module IOCheck
|
|
50
53
|
end
|
51
54
|
end
|
52
55
|
end
|
56
|
+
desc( "unlock all locked files." )
|
53
57
|
task "unlock" => locked.map { |t| "iocheck:unlock:#{t.name}" }
|
54
58
|
locked.each do |t|
|
55
59
|
namespace "unlock" do
|
@@ -64,11 +68,27 @@ module IOCheck
|
|
64
68
|
|
65
69
|
private
|
66
70
|
def show
|
67
|
-
# TODO: This is a temporary implementation.
|
68
71
|
@tests.each do |t|
|
69
72
|
t.show
|
70
73
|
end
|
71
|
-
|
74
|
+
puts
|
75
|
+
show_overall
|
76
|
+
end
|
77
|
+
|
78
|
+
def show_overall
|
79
|
+
n_success = 0
|
80
|
+
n_failure = 0
|
81
|
+
@tests.each do |t|
|
82
|
+
if t.succeeded?
|
83
|
+
n_success += 1
|
84
|
+
else
|
85
|
+
n_failure += 1
|
86
|
+
end
|
87
|
+
end
|
88
|
+
puts "--------------"
|
89
|
+
puts "Overall Result"
|
90
|
+
puts "Success : #{n_success}"
|
91
|
+
puts "Failure : #{n_failure}"
|
72
92
|
end
|
73
93
|
end # end of class Tester
|
74
94
|
end # end of module IOCheck
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iocheck
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-09-
|
12
|
+
date: 2011-09-08 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &24785340 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 2.3.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *24785340
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
requirement: &
|
27
|
+
requirement: &24784860 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.0.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *24784860
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: jeweler
|
38
|
-
requirement: &
|
38
|
+
requirement: &24688960 !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: *24688960
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rcov
|
49
|
-
requirement: &
|
49
|
+
requirement: &24688480 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *24688480
|
58
58
|
description: Make refactoring for legacy softwares safe.
|
59
59
|
email: ruby.wktk@gmail.com
|
60
60
|
executables: []
|
@@ -84,7 +84,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
84
84
|
version: '0'
|
85
85
|
segments:
|
86
86
|
- 0
|
87
|
-
hash:
|
87
|
+
hash: 2045296085534462150
|
88
88
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
89
|
none: false
|
90
90
|
requirements:
|