synthesis 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/{README → README.rdoc} +26 -1
- data/Rakefile +1 -1
- data/lib/synthesis/formatter/dot.rb +19 -10
- data/lib/synthesis/formatter/text.rb +12 -7
- data/lib/synthesis/formatter.rb +8 -4
- data/lib/synthesis/reporter.rb +19 -7
- data/lib/synthesis/runner.rb +7 -4
- data/lib/synthesis/task.rb +2 -2
- data/synthesis.gemspec +5 -5
- metadata +6 -6
data/{README → README.rdoc}
RENAMED
@@ -34,6 +34,8 @@ Synthesis can be setup to ignore certain classes or modules when collecting expe
|
|
34
34
|
|
35
35
|
If +pattern+ is not specified, it will default to <tt>test/**/*_test.rb</tt>
|
36
36
|
|
37
|
+
As of version 0.2.0, Synthesis has a +DOT+ formatter which, when used, will output text in the DOT graph description language, producing system visualizations as specified by the simulated interactions in the system's tests. The output of the +DOT+ formatter can be used with tools like Graphviz( http://www.graphviz.org/ ).
|
38
|
+
|
37
39
|
== Usage examples
|
38
40
|
|
39
41
|
To use with Test::Unit and Mocha, ignoring Array and Hash:
|
@@ -54,7 +56,7 @@ To use with RSpec, running all specs in the <tt>spec</tt> directory:
|
|
54
56
|
t.pattern = 'spec/**/*_spec.rb'
|
55
57
|
end
|
56
58
|
|
57
|
-
To use with Expectations, redirecting output to a file
|
59
|
+
To use with Expectations, redirecting output to a file:
|
58
60
|
|
59
61
|
require "synthesis/task"
|
60
62
|
|
@@ -62,6 +64,29 @@ To use with Expectations, redirecting output to a file
|
|
62
64
|
t.adapter = :expectations
|
63
65
|
t.out = File.new "synthesis.test.txt", "a"
|
64
66
|
end
|
67
|
+
|
68
|
+
To output a DOT graph, first make sure you have sexp_processor installed:
|
69
|
+
|
70
|
+
sudo gem install sexp_processor
|
71
|
+
|
72
|
+
Then, to output a file called "synthesis.dot", do (if formatter_out is not specified, the default ouput is STDOUT):
|
73
|
+
|
74
|
+
require "synthesis/task"
|
75
|
+
|
76
|
+
Synthesis::Task.new do |t|
|
77
|
+
t.formatter = :dot
|
78
|
+
t.formatter_out = "synthesis.dot"
|
79
|
+
end
|
80
|
+
|
81
|
+
To use Synthesis with Rails:
|
82
|
+
|
83
|
+
require "synthesis/task"
|
84
|
+
|
85
|
+
Synthesis::Task.new do |t|
|
86
|
+
RAILS_ENV = "test"
|
87
|
+
Rake::Task['environment'].invoke # This loads the Rails environment, which may make your build slower. Use only if needed
|
88
|
+
t.pattern = 'test/**/*_test.rb'
|
89
|
+
end
|
65
90
|
|
66
91
|
== Utilities
|
67
92
|
|
data/Rakefile
CHANGED
@@ -13,7 +13,7 @@ task :test => %w[test:core test:mocha test:spec]
|
|
13
13
|
|
14
14
|
desc "Run core tests"
|
15
15
|
Rake::TestTask.new('test:core') do |t|
|
16
|
-
t.pattern = 'test/synthesis
|
16
|
+
t.pattern = '{test/synthesis/,test/synthesis/formatter/}*_test.rb'
|
17
17
|
end
|
18
18
|
|
19
19
|
desc "Run Mocha adapter tests"
|
@@ -4,22 +4,24 @@ require "sexp_processor"
|
|
4
4
|
|
5
5
|
module Synthesis
|
6
6
|
class DotFormatter < Formatter
|
7
|
-
def initialize
|
7
|
+
def initialize(out)
|
8
|
+
super
|
8
9
|
Expectation::Expectation.send(:include, ExpectationReportFormat::Dot)
|
9
10
|
end
|
10
11
|
|
11
12
|
def digraph
|
12
|
-
puts "digraph synthesis_expectations {"
|
13
|
-
puts " rankdir=LR;"
|
14
|
-
puts " size=\"
|
15
|
-
puts " ratio=\"fill\";"
|
16
|
-
puts "
|
17
|
-
puts "
|
13
|
+
@out.puts "digraph synthesis_expectations {"
|
14
|
+
@out.puts " rankdir=LR;"
|
15
|
+
@out.puts " size=\"10,10\";"
|
16
|
+
@out.puts " ratio=\"fill\";"
|
17
|
+
@out.puts " remincross=\"true\";"
|
18
|
+
@out.puts " node [shape = circle];"
|
19
|
+
@out.puts " edge [color = green]"
|
18
20
|
report_tested_expectations
|
19
|
-
puts
|
20
|
-
puts " edge [color = red]"
|
21
|
+
@out.puts
|
22
|
+
@out.puts " edge [color = red]"
|
21
23
|
report_untested_expectations
|
22
|
-
puts "}"
|
24
|
+
@out.puts "}"
|
23
25
|
end
|
24
26
|
alias format_failure digraph
|
25
27
|
alias format_success digraph
|
@@ -85,6 +87,13 @@ module Synthesis
|
|
85
87
|
@klazz = @ancestors * '::' if name == method.to_sym
|
86
88
|
s(:defn, name, process(exp.shift), process(exp.shift))
|
87
89
|
end
|
90
|
+
|
91
|
+
def process_defs(exp)
|
92
|
+
selff = exp.shift
|
93
|
+
name = exp.shift
|
94
|
+
@klazz = @ancestors * '::' if name == method.to_sym
|
95
|
+
s(:defs, selff, name, process(exp.shift), process(exp.shift))
|
96
|
+
end
|
88
97
|
end
|
89
98
|
end
|
90
99
|
end
|
@@ -2,22 +2,27 @@ module Synthesis
|
|
2
2
|
class TextFormatter < Formatter
|
3
3
|
include Logging
|
4
4
|
|
5
|
-
def initialize
|
5
|
+
def initialize(out)
|
6
|
+
super
|
6
7
|
Expectation::Expectation.send(:include, ExpectationReportFormat::Text)
|
7
8
|
end
|
8
9
|
|
9
10
|
def format_success
|
10
|
-
|
11
|
-
|
11
|
+
@out.puts "[Synthesis] "
|
12
|
+
@out.puts "[Synthesis] Verified #{ExpectationRecord.expectations.size} expectations"
|
13
|
+
@out.puts "[Synthesis] SUCCESS."
|
12
14
|
end
|
13
15
|
|
14
16
|
def format_failure
|
15
|
-
|
17
|
+
@out.puts "[Synthesis] "
|
18
|
+
@out.puts "[Synthesis] Tested Expectations: "
|
16
19
|
report_tested_expectations
|
17
|
-
|
20
|
+
@out.puts "[Synthesis] "
|
21
|
+
@out.puts "[Synthesis] Untested Expectations: "
|
18
22
|
report_untested_expectations
|
19
|
-
|
20
|
-
|
23
|
+
@out.puts "[Synthesis] Ignoring: #{ExpectationRecord.ignored.to_a * ', '}"
|
24
|
+
@out.puts "[Synthesis] "
|
25
|
+
@out.puts "[Synthesis] FAILED."
|
21
26
|
end
|
22
27
|
end
|
23
28
|
|
data/lib/synthesis/formatter.rb
CHANGED
@@ -1,16 +1,20 @@
|
|
1
1
|
module Synthesis
|
2
2
|
class Formatter
|
3
|
+
def initialize(out)
|
4
|
+
@out = out
|
5
|
+
end
|
6
|
+
|
3
7
|
def report_tested_expectations
|
4
|
-
ExpectationRecord.tested_expectations.each { |e| puts e.to_report }
|
8
|
+
ExpectationRecord.tested_expectations.each { |e| @out.puts e.to_report }
|
5
9
|
end
|
6
10
|
|
7
11
|
def report_untested_expectations
|
8
|
-
ExpectationRecord.untested_expectations.each { |e| puts e.to_report }
|
12
|
+
ExpectationRecord.untested_expectations.each { |e| @out.puts e.to_report }
|
9
13
|
end
|
10
14
|
|
11
15
|
class << self
|
12
|
-
def load
|
13
|
-
@formatter.new
|
16
|
+
def load(out)
|
17
|
+
@formatter.new(out)
|
14
18
|
end
|
15
19
|
|
16
20
|
def inherited(subclass)
|
data/lib/synthesis/reporter.rb
CHANGED
@@ -1,13 +1,25 @@
|
|
1
1
|
module Synthesis
|
2
2
|
class Reporter
|
3
|
-
def self.report
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
def self.report(format, formatter_out)
|
4
|
+
begin
|
5
|
+
require "synthesis/formatter/#{format}"
|
6
|
+
rescue LoadError
|
7
|
+
raise "Invalid format: #{format}"
|
8
8
|
end
|
9
|
-
|
10
|
-
0
|
9
|
+
out = formatter_out ? File.open(formatter_out, 'w') : STDOUT
|
10
|
+
result = 0
|
11
|
+
begin
|
12
|
+
formatter = Formatter.load(out)
|
13
|
+
if ExpectationRecord.has_untested_expectations?
|
14
|
+
formatter.format_failure
|
15
|
+
result = -1
|
16
|
+
else
|
17
|
+
formatter.format_success
|
18
|
+
end
|
19
|
+
ensure
|
20
|
+
out.close unless out == STDOUT
|
21
|
+
end
|
22
|
+
return result
|
11
23
|
end
|
12
24
|
end
|
13
25
|
end
|
data/lib/synthesis/runner.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
module Synthesis
|
2
2
|
class Runner
|
3
|
-
def self.run(adapter, pattern, formatter)
|
4
|
-
|
5
|
-
|
3
|
+
def self.run(adapter, pattern, formatter, formatter_out)
|
4
|
+
begin
|
5
|
+
require "synthesis/adapter/#{adapter}"
|
6
|
+
rescue LoadError
|
7
|
+
raise "Invalid adapter: #{adapter}"
|
8
|
+
end
|
6
9
|
Adapter.load(pattern).run
|
7
|
-
at_exit { Reporter.report unless $! }
|
10
|
+
at_exit { Reporter.report(formatter, formatter_out) unless $! }
|
8
11
|
end
|
9
12
|
end
|
10
13
|
end
|
data/lib/synthesis/task.rb
CHANGED
@@ -7,7 +7,7 @@ module Synthesis
|
|
7
7
|
class Task < Rake::TaskLib
|
8
8
|
include Logging
|
9
9
|
attr_accessor :verbose, :pattern, :ruby_opts
|
10
|
-
attr_accessor :adapter, :out, :ignored, :libs, :formatter
|
10
|
+
attr_accessor :adapter, :out, :ignored, :libs, :formatter, :formatter_out
|
11
11
|
|
12
12
|
def initialize(name='synthesis:test')
|
13
13
|
@name, @ignored, @libs = name, [], []
|
@@ -39,7 +39,7 @@ module Synthesis
|
|
39
39
|
require File.dirname(__FILE__) + "/../synthesis/runner"
|
40
40
|
Synthesis::Logging.const_set(:OUT, @out) if @out
|
41
41
|
Synthesis::ExpectationRecord.ignore(*@ignored)
|
42
|
-
Synthesis::Runner.run(@adapter, @pattern, @formatter)
|
42
|
+
Synthesis::Runner.run(@adapter, @pattern, @formatter, @formatter_out)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
self
|
data/synthesis.gemspec
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
GEMSPEC =Gem::Specification.new do |s|
|
2
2
|
s.name = 'synthesis'
|
3
|
-
s.version = '0.2.
|
3
|
+
s.version = '0.2.1'
|
4
4
|
s.platform = Gem::Platform::RUBY
|
5
5
|
s.rubyforge_project = "synthesis"
|
6
6
|
s.summary, s.description = 'A tool for Synthesized Testing'
|
7
|
-
s.authors = 'Stuart Caborn, George Malamidis'
|
7
|
+
s.authors = 'Stuart Caborn, George Malamidis, Danilo Sato'
|
8
8
|
s.email = 'george@nutrun.com'
|
9
9
|
s.homepage = 'http://synthesis.rubyforge.org'
|
10
10
|
s.has_rdoc = true
|
11
|
-
s.rdoc_options += ['--quiet', '--title', 'Synthesis', '--main', 'README', '--inline-source']
|
12
|
-
s.extra_rdoc_files = ['README', 'COPYING']
|
11
|
+
s.rdoc_options += ['--quiet', '--title', 'Synthesis', '--main', 'README.rdoc', '--inline-source']
|
12
|
+
s.extra_rdoc_files = ['README.rdoc', 'COPYING']
|
13
13
|
s.files = [
|
14
14
|
"COPYING",
|
15
15
|
"Rakefile",
|
16
|
-
"README",
|
16
|
+
"README.rdoc",
|
17
17
|
"synthesis.gemspec",
|
18
18
|
"lib/synthesis/adapter/expectations.rb",
|
19
19
|
"lib/synthesis/adapter/mocha.rb",
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: synthesis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Stuart Caborn, George Malamidis
|
7
|
+
- Stuart Caborn, George Malamidis, Danilo Sato
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-11-
|
12
|
+
date: 2008-11-13 00:00:00 +00:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -20,12 +20,12 @@ executables: []
|
|
20
20
|
extensions: []
|
21
21
|
|
22
22
|
extra_rdoc_files:
|
23
|
-
- README
|
23
|
+
- README.rdoc
|
24
24
|
- COPYING
|
25
25
|
files:
|
26
26
|
- COPYING
|
27
27
|
- Rakefile
|
28
|
-
- README
|
28
|
+
- README.rdoc
|
29
29
|
- synthesis.gemspec
|
30
30
|
- lib/synthesis/adapter/expectations.rb
|
31
31
|
- lib/synthesis/adapter/mocha.rb
|
@@ -60,7 +60,7 @@ rdoc_options:
|
|
60
60
|
- --title
|
61
61
|
- Synthesis
|
62
62
|
- --main
|
63
|
-
- README
|
63
|
+
- README.rdoc
|
64
64
|
- --inline-source
|
65
65
|
require_paths:
|
66
66
|
- lib
|