tla-trace-filter 0.0.3 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +108 -0
- data/VERSION +1 -1
- data/lib/cli/cli.rb +124 -70
- data/lib/render/render.rb +85 -53
- data/mustache/api-call-after-state-post.mustache +9 -0
- data/mustache/api-call-after-state-pre.mustache +9 -0
- data/mustache/api-call-before-state-post.mustache +9 -0
- data/mustache/api-call-before-state-pre.mustache +9 -0
- data/mustache/api-call-call-post.mustache +9 -0
- data/mustache/api-call-call-pre.mustache +9 -0
- data/mustache/{api-call-output.mustache → api-call-default-afterState.mustache} +3 -3
- data/mustache/{api-call-default.mustache → api-call-default-api_input.mustache} +0 -0
- data/mustache/{api-call-return.mustache → api-call-default-api_return.mustache} +0 -0
- data/mustache/{api-call-input.mustache → api-call-default-beforeState.mustache} +3 -3
- data/mustache/api-call-header.mustache +4 -0
- data/mustache/api-call-init.mustache +41 -24
- data/mustache/api-call-link.mustache +5 -1
- data/mustache/api-call-main.mustache +28 -48
- data/mustache/api-call-post.mustache +13 -0
- data/mustache/api-call-pre.mustache +9 -0
- data/mustache/api-call-ret-post.mustache +9 -0
- data/mustache/api-call-ret-pre.mustache +9 -0
- data/mustache/api-call-step-post.mustache +9 -0
- data/mustache/api-call-step-pre.mustache +10 -0
- data/mustache/api-call.mustache +2 -2
- data/spec/cli/cli_spec.rb +26 -1
- data/spec/render/render_spec.rb +26 -3
- data/tla-trace-filter.gemspec +3 -3
- metadata +25 -12
- data/README.org +0 -66
@@ -7,9 +7,9 @@
|
|
7
7
|
|
8
8
|
}}
|
9
9
|
|
10
|
-
# <OUTPUT-BLOCKCHAIN now="{{
|
11
|
-
eth_accounts: {{{
|
12
|
-
eth_storageRoot: {{{
|
10
|
+
# <OUTPUT-BLOCKCHAIN now="{{afterState.now}}">
|
11
|
+
eth_accounts: {{{afterState.eth_accounts.to_yaml}}}
|
12
|
+
eth_storageRoot: {{{afterState.eth_storageRoot.to_yaml}}}
|
13
13
|
# </OUTPUT-BLOCKCHAIN>
|
14
14
|
{{!
|
15
15
|
Local Variables:
|
File without changes
|
File without changes
|
@@ -9,9 +9,9 @@
|
|
9
9
|
|
10
10
|
}}
|
11
11
|
|
12
|
-
# <INPUT-BLOCKCHAIN now="{{
|
13
|
-
eth_accounts: {{{
|
14
|
-
eth_storageRoot: {{{
|
12
|
+
# <INPUT-BLOCKCHAIN now="{{beforeState.now}}">
|
13
|
+
eth_accounts: {{{beforeState.eth_accounts.to_yaml}}}
|
14
|
+
eth_storageRoot: {{{beforeState.eth_storageRoot.pretty_generate}}}
|
15
15
|
# </INPUT-BLOCKCHAIN>
|
16
16
|
{{!
|
17
17
|
Local Variables:
|
@@ -1,66 +1,83 @@
|
|
1
1
|
{{!
|
2
2
|
|
3
|
-
api-call-init.mustache:
|
4
|
-
|
3
|
+
api-call-init.mustache:
|
4
|
+
|
5
|
+
Configure name of template to dispatch for 'interface_operation' in
|
6
|
+
tla-trace-filter.rb api-call -command.
|
7
|
+
|
5
8
|
Override this template to use other than default rendering.
|
6
9
|
|
7
10
|
This template is called once for a 'tla-trace-filter.rb api-call'.
|
8
|
-
|
11
|
+
|
12
|
+
It initializes four mappings:
|
9
13
|
|
10
|
-
-
|
11
|
-
- API_CALL_INIT
|
12
|
-
- API_RETURN_INIT
|
13
|
-
-
|
14
|
+
- API_BEFORE_STATE_INIT : define template to render before state for interface operation
|
15
|
+
- API_CALL_INIT : define template to render API call for interface operation
|
16
|
+
- API_RETURN_INIT : define template to render API return for interface operation
|
17
|
+
- API_AFTER_STATE_INIT : define template to render after state for interface operation
|
14
18
|
|
15
19
|
These mappings wrap mustache lambda sections, which contain a YAML
|
16
20
|
formatted hash mapping interface operation to a name of mustache
|
17
|
-
partial template.
|
18
|
-
|
19
|
-
|
21
|
+
partial template.
|
22
|
+
|
23
|
+
Two special keys are used: 1) 'default' (=template to use if no
|
24
|
+
other found), and 2) 'empty' (=template to use if
|
25
|
+
'interface.interface_operation' is nil).
|
20
26
|
|
21
27
|
Example:
|
22
28
|
|
23
29
|
Demo(): solidity-constructor
|
24
30
|
Demo(execute): solidity-message
|
25
31
|
empty: api-call-empty
|
26
|
-
default: api-call-
|
32
|
+
default: api-call-default-beforeState
|
27
33
|
|
28
34
|
Which reads:
|
29
35
|
- inteface operation "Demo()" uses mustache partial 'solidity-constructor.mustache'
|
30
36
|
- interface Demo(execute) use partial 'solidity-message.mustache
|
31
37
|
- undedefined interface operation (initial state) use partial 'api-call-empty.mustache'
|
32
|
-
- all other interface operations use template 'api-call-
|
38
|
+
- all other interface operations use template 'api-call-default-beforeState.mustache'
|
39
|
+
|
40
|
+
Search parth of these template files is configured using command line option --mustache.
|
33
41
|
|
34
|
-
|
42
|
+
Extension instructions:
|
43
|
+
|
44
|
+
- create extension directory e.g. `mkdir mymustache`
|
45
|
+
- copy this file to extension directory e.g. `cp $(bundle show tla-trace-filter)/mustache/api-call-init.mustache mymustache/`
|
46
|
+
- modify file `mymustache/api-call-init.mustache`
|
47
|
+
- pass extension directory as --mustache paramter `bundle exec tla-trace-filter.rb api-calls --mustache mymustache/`
|
48
|
+
NOTICE directory names must end with slash '/' -character. Parameter not ending with slash are interpreted as GEM names
|
49
|
+
with template directory `mustache`.
|
50
|
+
|
35
51
|
|
36
52
|
}}{{!
|
37
53
|
|
38
54
|
Configure templates to render state before API call
|
39
55
|
|
40
|
-
}}{{#
|
41
|
-
default: api-call-
|
42
|
-
empty: api-call-
|
43
|
-
{{/
|
56
|
+
}}{{#API_BEFORE_STATE_INIT}}
|
57
|
+
default: api-call-default-beforeState
|
58
|
+
empty: api-call-default-beforeState
|
59
|
+
{{/API_BEFORE_STATE_INIT}}{{!
|
44
60
|
|
45
61
|
Configure templates to render API CALL
|
46
62
|
|
47
63
|
}}{{#API_CALL_INIT}}
|
48
|
-
default: api-call-default
|
64
|
+
default: api-call-default-api_input
|
65
|
+
empty: api-call-default-api_input
|
49
66
|
{{/API_CALL_INIT}}{{!
|
50
67
|
|
51
68
|
Configure templates to render API_RETURN
|
52
69
|
|
53
70
|
}}{{#API_RETURN_INIT}}
|
54
|
-
default: api-call-
|
55
|
-
empty: api-call-
|
71
|
+
default: api-call-default-api_return
|
72
|
+
empty: api-call-default-api_return
|
56
73
|
{{/API_RETURN_INIT}}{{!
|
57
74
|
|
58
75
|
Configure templates to render state after API call
|
59
76
|
|
60
|
-
}}{{#
|
61
|
-
default: api-call-
|
62
|
-
empty: api-call-
|
63
|
-
{{/
|
77
|
+
}}{{#API_AFTER_STATE_INIT}}
|
78
|
+
default: api-call-default-afterState
|
79
|
+
empty: api-call-default-afterState
|
80
|
+
{{/API_AFTER_STATE_INIT}}{{!
|
64
81
|
|
65
82
|
Do not output new-line
|
66
83
|
|
@@ -1,2 +1,6 @@
|
|
1
|
-
{{
|
1
|
+
{{!
|
2
|
+
|
3
|
+
api-call-link.mustache: Override this template to change link output
|
4
|
+
|
5
|
+
}}{{options.src_dir}}/{{interface.source.sourceModule}}:{{^options.solc_line}}{{interface.source.sourceLine}}{{/options.solc_line}}{{#options.solc_line}}{{SOLC_LINE}}{{/options.solc_line}}:1: {{interface.interface_operation}} at tick {{now}}
|
2
6
|
{{options.tla_dir}}/model.tla:{{parsed.actionLine}}: {{{parsed.line}}}
|
@@ -1,85 +1,65 @@
|
|
1
1
|
{{!
|
2
2
|
|
3
|
-
api-call-main.mustache:
|
3
|
+
api-call-main.mustache: output one step in api-call
|
4
|
+
|
5
|
+
IF interface_started THEN call templates
|
6
|
+
- api-call-step-pre, api-call-header,
|
7
|
+
- API_INPUT, API_CALL, API_OUTPUT (dynamic dispatch)
|
8
|
+
- api-call-link
|
9
|
+
- api-call-step-post
|
4
10
|
|
5
|
-
Output API call for interface.interface_operation
|
6
11
|
|
7
|
-
|
12
|
+
Output API step call for interface.interface_operation
|
8
13
|
|
9
|
-
|
14
|
+
}}{{!
|
10
15
|
|
11
|
-
|
16
|
+
Start of step == 'interface_started'
|
17
|
+
|
18
|
+
- output preamble
|
12
19
|
|
13
|
-
|
20
|
+
}}{{#interface_started}}{{>api-call-step-pre}}{{!
|
14
21
|
|
15
|
-
|
16
|
-
|
17
|
-
|
22
|
+
- output step header
|
23
|
+
|
24
|
+
}}{{>api-call-header}}{{!
|
18
25
|
|
19
|
-
- input state: dispatched dynamically trough
|
26
|
+
- input state: dispatched dynamically trough API_BEFORE_STATE, which maps
|
20
27
|
[:interface][:interface_operation] to partial name set in 'api-call-init'
|
21
|
-
using
|
28
|
+
using API_BEFORE_STATE_INIT
|
22
29
|
|
23
|
-
}}{{{
|
30
|
+
}}{{>api-call-before-state-pre}}{{{API_BEFORE_STATE}}}{{>api-call-before-state-post}}{{!
|
24
31
|
|
25
32
|
- API call: dispatched dynamically trough API_CALL, which maps
|
26
33
|
[:interface][:interface_operation] to partial name set in 'api-call-init'
|
27
34
|
using API_CALL_INIT
|
28
35
|
|
29
|
-
}}{{{API_CALL}}}{{!
|
36
|
+
}}{{>api-call-call-pre}}{{{API_CALL}}}{{>api-call-call-post}}{{!
|
30
37
|
|
31
38
|
- API_RETURN: dispatched dynamically trough API_RETURN, which maps
|
32
39
|
[:interface][:interface_operation] to partial name set in 'api-call-init'
|
33
40
|
using API_RETURN_INIT
|
34
41
|
|
35
|
-
}}{{{API_RETURN}}}{{!
|
42
|
+
}}{{>api-call-ret-pre}}{{{API_RETURN}}}{{>api-call-ret-post}}{{!
|
36
43
|
|
37
|
-
- output state: dispatched dynamically trough
|
44
|
+
- output state: dispatched dynamically trough API_AFTER_STATE, which maps
|
38
45
|
[:interface][:interface_operation] to partial name set in 'api-call-init'
|
39
46
|
|
40
|
-
}}{{{
|
47
|
+
}}{{>api-call-after-state-pre}}{{{API_AFTER_STATE}}}{{>api-call-after-state-post}}{{!
|
41
48
|
|
42
49
|
- link to source line
|
43
|
-
}}{{>api-call-link}}{{!
|
44
|
-
|
45
|
-
END IF - interface.source.sourceModule
|
46
|
-
|
47
|
-
}}{{/interface_started}}{{#interface_executing}}{{/interface_executing}}{{/interface.source.sourceModule}}{{!
|
48
|
-
|
49
|
-
ELSE ^interface.source.sourceModule : when no source module identified
|
50
|
-
- interface started
|
51
|
-
|
52
|
-
}}{{^interface.source.sourceModule}}{{#interface_started}}
|
53
|
-
------------------------------------------------------------------
|
54
|
-
{{interface.interface_operation}}: at tick '{{parsed.state_space.now}}' for step '{{{parsed.state_space.step }}}'{{!
|
55
|
-
|
56
|
-
- input state
|
57
50
|
|
58
|
-
}}{{
|
59
|
-
|
60
|
-
- API call
|
61
|
-
|
62
|
-
}}{{{API_CALL}}}{{!
|
63
|
-
|
64
|
-
- API return
|
65
|
-
|
66
|
-
}}{{{API_RETURN}}}{{!
|
51
|
+
}}{{>api-call-link}}{{!
|
67
52
|
|
68
|
-
- output
|
69
|
-
|
70
|
-
}}{{{API_OUTPUT_STATE}}}{{!
|
53
|
+
- output postamble
|
71
54
|
|
72
|
-
|
73
|
-
|
74
|
-
}}{{>api-call-link}}{{!
|
55
|
+
}}{{>api-call-step-post}}{{!
|
75
56
|
|
76
|
-
|
57
|
+
end of 'interface_started'
|
77
58
|
|
78
59
|
}}{{/interface_started}}{{!
|
79
60
|
|
80
|
-
|
61
|
+
No ouput here - all output generated by called partials
|
81
62
|
|
82
|
-
}}{{/interface.source.sourceModule}}{{!
|
83
63
|
Local Variables:
|
84
64
|
require-final-newline: nil
|
85
65
|
End:
|
@@ -0,0 +1,13 @@
|
|
1
|
+
{{!
|
2
|
+
|
3
|
+
api-call-post.mustache: Override this template to change wrapping around api-calls
|
4
|
+
|
5
|
+
This template may access value sha1, which counts sha1sum upto (but
|
6
|
+
not including) this template
|
7
|
+
|
8
|
+
|
9
|
+
}}{{!
|
10
|
+
Local Variables:
|
11
|
+
require-final-newline: nil
|
12
|
+
End:
|
13
|
+
}}
|
data/mustache/api-call.mustache
CHANGED
@@ -23,8 +23,8 @@
|
|
23
23
|
|
24
24
|
API call releated stuff
|
25
25
|
|
26
|
-
:
|
27
|
-
:
|
26
|
+
:beforeState : state space parsed before making API-call
|
27
|
+
:afterState : state space parsed after making API-call
|
28
28
|
:now : time when making :interface -call
|
29
29
|
|
30
30
|
}}{{>api-call-main}}{{!
|
data/spec/cli/cli_spec.rb
CHANGED
@@ -51,7 +51,7 @@ describe TlaTraceFilter::Cli do
|
|
51
51
|
|
52
52
|
describe "instance-methods" do
|
53
53
|
subject { described_class.new }
|
54
|
-
%i[ add_links api_calls ].each do |op|
|
54
|
+
%i[ add_links api_calls outputRendered ].each do |op|
|
55
55
|
specify { is_expected.to respond_to(op) }
|
56
56
|
end
|
57
57
|
end
|
@@ -68,6 +68,31 @@ describe TlaTraceFilter::Cli do
|
|
68
68
|
it { expect( help ).to match /#{cmd}.*#/ }
|
69
69
|
end
|
70
70
|
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# ------------------------------------------------------------------
|
74
|
+
# start
|
75
|
+
describe ".new" do
|
76
|
+
let ( :start ) { described_class.new }
|
77
|
+
it { expect( start ).to be_a Thor }
|
78
|
+
it { expect( start ).to be_a TlaTraceFilter::Cli }
|
79
|
+
|
80
|
+
describe "#outputRendered" do
|
81
|
+
let ( :outputRendered ) { start.outputRendered( line ) }
|
82
|
+
context "line not empty" do
|
83
|
+
let ( :line ) { "line" }
|
84
|
+
before( :each ) do
|
85
|
+
expect( STDOUT).to receive( :puts ).with( line )
|
86
|
+
# expect( start).to receive( :sha1Update ).with( "#{line}\n" )
|
87
|
+
expect( start).to receive( :sha1Update ).with( line )
|
88
|
+
end
|
89
|
+
it { outputRendered }
|
90
|
+
end
|
91
|
+
context "line empty" do
|
92
|
+
let ( :line ) { "" }
|
93
|
+
it { outputRendered }
|
94
|
+
end
|
95
|
+
end
|
71
96
|
end
|
72
97
|
|
73
98
|
end
|