tla-trace-filter 0.0.3

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.
@@ -0,0 +1,177 @@
1
+ require_relative "../spec_helper.rb"
2
+
3
+ describe TlaTraceFilter::Render do
4
+
5
+ # Name defined
6
+ it { expect( described_class ).to be_a Class }
7
+
8
+
9
+ # ------------------------------------------------------------------
10
+ # @!group Interface
11
+
12
+ describe "module interface" do
13
+ describe "class-methods" do
14
+ subject { described_class }
15
+ %i[ ].each do |op|
16
+ specify { is_expected.to respond_to(op) }
17
+ end
18
+ end
19
+
20
+ describe "instance-methods" do
21
+ subject { described_class.new }
22
+ %i[ render render_str SOLC_LINE read_partial read_partial_file gem_location ].each do |op|
23
+ specify { is_expected.to respond_to(op) }
24
+ end
25
+ %i[ API_OUTPUT_STATE_INIT API_INPUT_STATE_INIT API_CALL_INIT API_RETURN_INIT API_OUTPUT_STATE API_INPUT_STATE API_CALL API_RETURN ].each do |op|
26
+ specify { is_expected.to respond_to(op) }
27
+ end
28
+ end
29
+ end
30
+
31
+ # @!endgroup
32
+
33
+ # ------------------------------------------------------------------
34
+ # @!group Start
35
+
36
+ describe ".start" do
37
+ let( :start ) { described_class.new }
38
+ it { expect( start ).to be_a described_class }
39
+ it { expect( start ).to be_a Mustache }
40
+
41
+ describe "#returnPartials" do
42
+ let ( :returnPartials ) { start.returnPartials }
43
+ context "default" do
44
+ it { expect( returnPartials ).to be_a Hash }
45
+ it { expect( returnPartials ).to have_key( TlaTraceFilter::Render::API_EMPTY_KEY ) }
46
+ it { expect( returnPartials ).to have_key( TlaTraceFilter::Render::API_DEFAULT_KEY ) }
47
+ it { expect( returnPartials[TlaTraceFilter::Render::API_DEFAULT_KEY] ).to eql TlaTraceFilter::Render::API_RETURN_DEFAULT_PARTIAL}
48
+ end
49
+ end
50
+
51
+
52
+ describe "#gem_location" do
53
+ let ( :gem_location ) { start.gem_location(gemName) }
54
+ context "no-such-gem error" do
55
+ let ( :gemName ) { "nosushc-gem" }
56
+ it { expect{ gem_location }.to raise_error( /Unknown gemName #{gemName}/ ) }
57
+ end
58
+ context "thor - in gemspec" do
59
+ let ( :gemName ) { "thor" }
60
+ it { expect( gem_location ).to match /#{gemName}/ }
61
+ end
62
+ context "rspec - in Gemfile" do
63
+ let ( :gemName ) { "rspec" }
64
+ it { expect( gem_location ).to match /#{gemName}/ }
65
+ end
66
+ context "sbuilder-eth - NOT in Gemfile - but should be installed" do
67
+ let ( :gemName ) { "sbuilder-eth" }
68
+ it { expect{ gem_location }.to raise_error( /Unknown gemName #{gemName}/) }
69
+ end
70
+ end # gem_location
71
+
72
+ describe "read_gem_partial_file" do
73
+ let ( :read_gem_partial_file ) { start.read_gem_partial_file(gemName, templateName) }
74
+ context "no-such-gem error" do
75
+ let ( :gemName ) { "nosushc-gem" }
76
+ let ( :templateName ) { "nosuc-h-tempalte" }
77
+ it { expect{ read_gem_partial_file }.to raise_error( /Unknown gemName #{gemName}/ ) }
78
+ end
79
+ context "tla-trace-filter@no-such-emplate" do
80
+ let ( :gemName ) { "tla-trace-filter" }
81
+ let ( :templateName ) { "nosuc-h-tempalte" }
82
+ it { expect( read_gem_partial_file ).to eql nil }
83
+ end
84
+ context "tla-trace-filter@api-call-init.mustache" do
85
+ let ( :gemName ) { "tla-trace-filter" }
86
+ let ( :templateName ) { "api-call-init.mustache" }
87
+ it { expect( read_gem_partial_file ).to be_a String }
88
+ end
89
+ context "tla-sbuilder@domains.mustache" do
90
+ let ( :gemName ) { "tla-sbuilder" }
91
+ let ( :templateName ) { "domains.mustache" }
92
+ it { expect( read_gem_partial_file ).to be_a String }
93
+ end
94
+ end
95
+
96
+
97
+ describe "#render_str" do
98
+ let( :template ) { "data" }
99
+ let( :data ) { { :val => "yksi" } }
100
+ let( :render_str ) { start.render_str(template, data) }
101
+ context "template=string" do
102
+ it { expect( render_str ).to eql template }
103
+ end
104
+ context "template={{:val}}" do
105
+ let( :template ) { "val={{val}}" }
106
+ it { expect( render_str ).to eql "val=yksi" }
107
+ end
108
+ end # render_str
109
+
110
+ describe "#read_partial_file" do
111
+ let ( :templateName ) { "templateName" }
112
+ let ( :read_partial_file ) { start.read_partial_file( path, templateName) }
113
+
114
+ context "path not directory" do
115
+ let ( :path ) { "gemName" }
116
+ it { expect{ read_partial_file }.to raise_error TlaTraceFilter::RenderException, /Expected '#{path}' to end/ }
117
+ end
118
+ context "path directory not found" do
119
+ let ( :path ) { "dirname/" }
120
+ it { expect( read_partial_file ).to eql nil }
121
+ end
122
+
123
+ end
124
+
125
+ describe "#SOLC_LINE" do
126
+
127
+ let ( :solc_line ) { start.render_str( "solc_line={{SOLC_LINE}}", data)}
128
+ context "solidity source not defined" do
129
+ let( :data ) { {} }
130
+ it { expect( solc_line ).to eql "solc_line=0" }
131
+ end
132
+
133
+
134
+ context "accessesing file" do
135
+
136
+ before :each do
137
+ expect( File ).to receive( :exists? ).with( "src").and_return( true )
138
+ expect( File ).to receive( :exists? ).with( "src/file.sol").and_return( true )
139
+ expect( File ).to receive( :open ).with( "src/file.sol").and_return( lines )
140
+ end
141
+
142
+ let( :lines ) { [ "line1\n", "line2", "line3" ] }
143
+ let( :data ) do
144
+ {
145
+ :options => { "src_dir" => "src"},
146
+ :interface => { :source => {
147
+ :sourceModule => "file.sol",
148
+ :sourceLine => sourceLine,
149
+ }
150
+ },
151
+ }
152
+ end # let :data
153
+
154
+ context "on first line" do
155
+ let ( :sourceLine ) { 4 }
156
+ it { expect( solc_line ).to eql "solc_line=1" }
157
+ end
158
+ context "on second line" do
159
+ let ( :sourceLine ) { 7 }
160
+ it { expect( solc_line ).to eql "solc_line=2" }
161
+ end
162
+ context "on last line" do
163
+ let ( :sourceLine ) { 999 }
164
+ it { expect( solc_line ).to eql "solc_line=3" }
165
+ end
166
+
167
+ end
168
+ end
169
+
170
+ end
171
+
172
+ # @!endgroup
173
+
174
+
175
+
176
+
177
+ end
@@ -0,0 +1,7 @@
1
+
2
+ FIXTURE_ROOT = File.join(File.dirname(__FILE__), "fixtures")
3
+
4
+ require_relative "../lib/tla-trace-filter.rb"
5
+
6
+
7
+
data/spec/test_spec.rb ADDED
@@ -0,0 +1,8 @@
1
+ require_relative './spec_helper.rb'
2
+
3
+
4
+ describe "Rspec" do
5
+
6
+ specify { expect(1).to eql(1) }
7
+
8
+ end
@@ -0,0 +1,45 @@
1
+ # -*- encoding: utf-8; mode: ruby -*-
2
+
3
+ lib = File.expand_path('../lib/', __FILE__)
4
+ $:.unshift lib unless $:.include?(lib)
5
+
6
+
7
+ # http://guides.rubygems.org/make-your-own-gem/
8
+
9
+ Gem::Specification.new do |s|
10
+
11
+ # version = "0.0.1.pre"
12
+ version = File.open( "VERSION", "r" ) { |f| f.read }.strip.gsub( "-SNAPSHOT", ".pre" )
13
+
14
+ s.name = 'tla-trace-filter'
15
+ s.version = version
16
+ s.date = Time.now.strftime( "%Y-%m-%d" ) #'2014-09-10'
17
+ s.summary = "Post process tla+tools model checker trace output"
18
+ s.description = <<EOF
19
+
20
+
21
+ A command line filter utility for processing
22
+ [[http://research.microsoft.com/en-us/um/people/lamport/tla/tools.html][TLA+
23
+ Tools]] output resulting created when model checking
24
+ [[[http://research.microsoft.com/en-us/um/people/lamport/tla/book.html][TLA+
25
+ language]]] formal model generated using
26
+ [[https://github.com/jarjuk/tla-sbuilder][sbuilder]] -tool.
27
+
28
+
29
+ EOF
30
+
31
+ s.authors = ["jarjuk"]
32
+ s.files = ["README.org", "VERSION", "#{s.name}.gemspec" ] | Dir.glob("lib/**/*") |Dir.glob("mustache/**/*") | Dir.glob("spec/**/*")
33
+ s.require_paths = [ "lib" ]
34
+ s.executables = [ "tla-trace-filter.rb" ]
35
+ s.license = 'MIT'
36
+
37
+ s.required_ruby_version = '~> 2', ">=2.3"
38
+
39
+ s.add_runtime_dependency 'tla-sbuilder', '~>0.3', ">0.3.7"
40
+ s.add_runtime_dependency 'thor', '~>0.19', ">=0.19.1"
41
+ s.add_runtime_dependency 'treetop', '~>1.6', ">=1.6.3"
42
+ s.add_runtime_dependency 'mustache', '~>1.0', ">=1.0.3"
43
+
44
+
45
+ end
metadata ADDED
@@ -0,0 +1,171 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tla-trace-filter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - jarjuk
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-12-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: tla-sbuilder
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.3'
20
+ - - ">"
21
+ - !ruby/object:Gem::Version
22
+ version: 0.3.7
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '0.3'
30
+ - - ">"
31
+ - !ruby/object:Gem::Version
32
+ version: 0.3.7
33
+ - !ruby/object:Gem::Dependency
34
+ name: thor
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '0.19'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 0.19.1
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '0.19'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 0.19.1
53
+ - !ruby/object:Gem::Dependency
54
+ name: treetop
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '1.6'
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 1.6.3
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '1.6'
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 1.6.3
73
+ - !ruby/object:Gem::Dependency
74
+ name: mustache
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: '1.0'
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 1.0.3
83
+ type: :runtime
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.0'
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: 1.0.3
93
+ description: |2+
94
+
95
+
96
+ A command line filter utility for processing
97
+ [[http://research.microsoft.com/en-us/um/people/lamport/tla/tools.html][TLA+
98
+ Tools]] output resulting created when model checking
99
+ [[[http://research.microsoft.com/en-us/um/people/lamport/tla/book.html][TLA+
100
+ language]]] formal model generated using
101
+ [[https://github.com/jarjuk/tla-sbuilder][sbuilder]] -tool.
102
+
103
+
104
+ email:
105
+ executables:
106
+ - tla-trace-filter.rb
107
+ extensions: []
108
+ extra_rdoc_files: []
109
+ files:
110
+ - README.org
111
+ - VERSION
112
+ - bin/tla-trace-filter.rb
113
+ - lib/cli/cli.rb
114
+ - lib/filter/filter.rb
115
+ - lib/parser/grammar.treetop
116
+ - lib/parser/node_extensions.rb
117
+ - lib/parser/parser.rb
118
+ - lib/render/render.rb
119
+ - lib/tla-trace-filter.rb
120
+ - lib/util/logger.rb
121
+ - mustache/add-links-interface.mustache
122
+ - mustache/add-links-state-dump.mustache
123
+ - mustache/add-links-transition.mustache
124
+ - mustache/add-links.mustache
125
+ - mustache/api-call-default.mustache
126
+ - mustache/api-call-init.mustache
127
+ - mustache/api-call-input.mustache
128
+ - mustache/api-call-link.mustache
129
+ - mustache/api-call-main.mustache
130
+ - mustache/api-call-output.mustache
131
+ - mustache/api-call-return.mustache
132
+ - mustache/api-call.mustache
133
+ - spec/cli/cli_spec.rb
134
+ - spec/filter/filter_spec.rb
135
+ - spec/fixtures/interfaces.yaml
136
+ - spec/fixtures/model.tla
137
+ - spec/fixtures/trace.txt
138
+ - spec/parser/node_extensions_spec.rb
139
+ - spec/parser/parser_spec.rb
140
+ - spec/render/render_spec.rb
141
+ - spec/spec_helper.rb
142
+ - spec/test_spec.rb
143
+ - tla-trace-filter.gemspec
144
+ homepage:
145
+ licenses:
146
+ - MIT
147
+ metadata: {}
148
+ post_install_message:
149
+ rdoc_options: []
150
+ require_paths:
151
+ - lib
152
+ required_ruby_version: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - "~>"
155
+ - !ruby/object:Gem::Version
156
+ version: '2'
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '2.3'
160
+ required_rubygems_version: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
+ requirements: []
166
+ rubyforge_project:
167
+ rubygems_version: 2.6.14
168
+ signing_key:
169
+ specification_version: 4
170
+ summary: Post process tla+tools model checker trace output
171
+ test_files: []