faultinjection 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +0 -5
- data/lib/fault_injection/parser.rb +32 -7
- data/lib/fault_injection/version.rb +1 -1
- data/spec/fault_injection_spec.rb +14 -0
- data/website/index.html +2 -2
- metadata +2 -7
- data/#*scratch*#18552Tu2# +0 -0
- data/#*scratch*#20064OwE# +0 -0
- data/#*scratch*#20109z1E# +0 -0
- data/#*scratch*#20389vPF# +0 -0
- data/#*scratch*#20789Z7F# +0 -0
data/Manifest.txt
CHANGED
@@ -5,20 +5,45 @@
|
|
5
5
|
module FaultInjection
|
6
6
|
class Parser
|
7
7
|
def self.compile src
|
8
|
-
method_pat =
|
8
|
+
method_pat = /
|
9
|
+
([A-Z][A-Za-z0-9_]*) # class name
|
10
|
+
(?: \#|:: ) # '#' or '::', they are treated as same now.
|
11
|
+
([a-z_][a-zA-Z0-9_]*) # method name
|
12
|
+
/x
|
13
|
+
method_lineno_pat = /
|
14
|
+
([A-Z][A-Za-z0-9_]*) # class name
|
15
|
+
(?: \#|:: ) # '#' or '::', they are treated as same.
|
16
|
+
([a-z_][a-zA-Z0-9_]*) # method name
|
17
|
+
(?: :(\d+) ) # line number in method
|
18
|
+
/x
|
19
|
+
|
20
|
+
file_line_pat = /^([A-Za-z0-9_.~-]+):(\d+)$/
|
9
21
|
src.gsub!(/\s/,'')
|
10
22
|
|
11
|
-
if src =~
|
12
|
-
return FaultConditionLine.new(
|
13
|
-
|
23
|
+
if src =~ file_line_pat
|
24
|
+
return FaultConditionLine.new($~[1],$~[2].to_i)
|
25
|
+
|
26
|
+
elsif src =~ method_lineno_pat
|
27
|
+
#STDERR.puts("Class=#{$~[1]},method='#{$~[2]}',line='#{$~[3]}'")
|
28
|
+
klass = eval($~[1]) rescue raise(NameError,"No such class:'#{$~[1]}'")
|
29
|
+
method = $~[2]
|
30
|
+
line_in_meth = $~[3].to_i
|
31
|
+
|
32
|
+
# Proc#to_s contains file name & line number in which
|
33
|
+
# the method is defined.
|
34
|
+
method_info = klass.new.method(method).to_proc.to_s
|
35
|
+
method_info =~ /@([^:]+):(\d+)>$/
|
36
|
+
#STDERR.puts("file=#{$~[1]},line=#{$~[2]}")
|
37
|
+
return FaultConditionLine.new($~[1], $~[2].to_i + line_in_meth)
|
38
|
+
|
14
39
|
else
|
15
40
|
methods = src.split(">")
|
16
41
|
methods.map! do |e|
|
17
|
-
unless e =~
|
42
|
+
unless e =~ method_pat
|
18
43
|
raise ArgumentError,"Invalid method name:'#{e}'"
|
19
44
|
end
|
20
|
-
|
21
|
-
[
|
45
|
+
|
46
|
+
[$~[1].to_sym, $~[2].to_sym]
|
22
47
|
end
|
23
48
|
|
24
49
|
c = FaultConditionCall.new
|
@@ -76,6 +76,20 @@ describe "Method tracing fault-injection" do
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
+
describe "'Line number in method' style fault injection" do
|
80
|
+
require 'target_03.rb'
|
81
|
+
|
82
|
+
it "should inject faults properly with Class#method:line format." do
|
83
|
+
Proc.new { T3.new.foo }.should_not raise_error
|
84
|
+
|
85
|
+
pending "not yet implemented" do
|
86
|
+
FaultInjection.inject("T3#foo:2",IOError)
|
87
|
+
|
88
|
+
Proc.new { T3.new.foo }.should raise_error(IOError)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
79
93
|
describe "Specifying Exception class" do
|
80
94
|
require 'target_01.rb'
|
81
95
|
|
data/website/index.html
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
|
17
17
|
<h1>fault_injection.rb</h1>
|
18
18
|
<div style="text-align:right;">
|
19
|
-
Last version: <a href="http://rubyforge.org/projects/fault_injection" class="numbers">0.0.
|
19
|
+
Last version: <a href="http://rubyforge.org/projects/fault_injection" class="numbers">0.0.3</a>
|
20
20
|
</div>
|
21
21
|
<h2>Overview</h2>
|
22
22
|
|
@@ -128,7 +128,7 @@ it makes a script much slower.</p>
|
|
128
128
|
|
129
129
|
<p>(Please remove ”.spam” from the address for anti-spam, and include ‘ruby’ or ‘fault_injection’ in the title)</p>
|
130
130
|
<p class="coda">
|
131
|
-
<a herf="http://keisukefukuda.rubyforge.org">Keisuke Fukuda</a>,
|
131
|
+
<a herf="http://keisukefukuda.rubyforge.org">Keisuke Fukuda</a>, 13th January 2008<br>
|
132
132
|
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
133
133
|
</p>
|
134
134
|
</div>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faultinjection
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ""
|
6
6
|
authors:
|
7
7
|
- FIXME full name
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-03-12 00:00:00 +09:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -26,11 +26,6 @@ extra_rdoc_files:
|
|
26
26
|
- README.txt
|
27
27
|
- website/index.txt
|
28
28
|
files:
|
29
|
-
- "#*scratch*#18552Tu2#"
|
30
|
-
- "#*scratch*#20064OwE#"
|
31
|
-
- "#*scratch*#20109z1E#"
|
32
|
-
- "#*scratch*#20389vPF#"
|
33
|
-
- "#*scratch*#20789Z7F#"
|
34
29
|
- History.txt
|
35
30
|
- License.txt
|
36
31
|
- Manifest.txt
|
data/#*scratch*#18552Tu2#
DELETED
File without changes
|
data/#*scratch*#20064OwE#
DELETED
File without changes
|
data/#*scratch*#20109z1E#
DELETED
File without changes
|
data/#*scratch*#20389vPF#
DELETED
File without changes
|
data/#*scratch*#20789Z7F#
DELETED
File without changes
|