tla-trace-filter 0.0.3 → 0.0.6

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,9 @@
1
+ {{!
2
+
3
+ api-call-output-post.mustache: Override this template to change wrapping around api-calls
4
+
5
+ }}{{!
6
+ Local Variables:
7
+ require-final-newline: nil
8
+ End:
9
+ }}
@@ -0,0 +1,9 @@
1
+ {{!
2
+
3
+ api-call-output-pre.mustache: Override this template to change wrapping around api-calls
4
+
5
+ }}{{!
6
+ Local Variables:
7
+ require-final-newline: nil
8
+ End:
9
+ }}
@@ -0,0 +1,9 @@
1
+ {{!
2
+
3
+ api-call-input-post.mustache: Override this template to change wrapping around api-calls
4
+
5
+ }}{{!
6
+ Local Variables:
7
+ require-final-newline: nil
8
+ End:
9
+ }}
@@ -0,0 +1,9 @@
1
+ {{!
2
+
3
+ api-call-pre.mustache: Override this template to change wrapping around api-calls
4
+
5
+ }}{{!
6
+ Local Variables:
7
+ require-final-newline: nil
8
+ End:
9
+ }}
@@ -0,0 +1,9 @@
1
+ {{!
2
+
3
+ api-call-call-post.mustache: this template to change wrapping around api-calls
4
+
5
+ }}{{!
6
+ Local Variables:
7
+ require-final-newline: nil
8
+ End:
9
+ }}
@@ -0,0 +1,9 @@
1
+ {{!
2
+
3
+ api-call-call-pre.mustache: Override this template to change wrapping around api-calls
4
+
5
+ }}{{!
6
+ Local Variables:
7
+ require-final-newline: nil
8
+ End:
9
+ }}
@@ -7,9 +7,9 @@
7
7
 
8
8
  }}
9
9
 
10
- # <OUTPUT-BLOCKCHAIN now="{{inputState.now}}">
11
- eth_accounts: {{{outputState.eth_accounts.to_yaml}}}
12
- eth_storageRoot: {{{outputState.eth_storageRoot.to_yaml}}}
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:
@@ -9,9 +9,9 @@
9
9
 
10
10
  }}
11
11
 
12
- # <INPUT-BLOCKCHAIN now="{{inputState.now}}">
13
- eth_accounts: {{{inputState.eth_accounts.to_yaml}}}
14
- eth_storageRoot: {{{inputState.eth_storageRoot.pretty_generate}}}
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:
@@ -0,0 +1,4 @@
1
+ {{!
2
+ api-call-header.mustache : output header for step, override to change
3
+ }}
4
+ {{interface.interface_operation}}: at tick '{{parsed.state_space.now}}' for step '{{{parsed.state_space.step }}}'
@@ -1,66 +1,83 @@
1
1
  {{!
2
2
 
3
- api-call-init.mustache: define rendering for 'api-call' command
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
- It initialize four mappings:
11
+
12
+ It initializes four mappings:
9
13
 
10
- - API_INPUT_INIT : render state before API call
11
- - API_CALL_INIT : render API interface and API input parameters
12
- - API_RETURN_INIT : render API interface and API return parameters
13
- - API_OUTPUT_INIT : render state after API call
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. Two special keys are used: 1) 'default'
18
- (=template to use if no other found), and 2) 'empty' (=template to
19
- use if 'interface.interface_operation' is nil).
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-input
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-input.mustache'
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
- Search parth of these template files is configured using command line option --mustache
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
- }}{{#API_INPUT_STATE_INIT}}
41
- default: api-call-input
42
- empty: api-call-input
43
- {{/API_INPUT_STATE_INIT}}{{!
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-return
55
- empty: api-call-return
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
- }}{{#API_OUTPUT_STATE_INIT}}
61
- default: api-call-output
62
- empty: api-call-output
63
- {{/API_OUTPUT_STATE_INIT}}{{!
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
- {{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}}
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: template calling API_INPUT, API_CALL, API_OUTPUT templates
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
- IF #interface.source.sourceModule - interface known
14
+ }}{{!
10
15
 
11
- }}{{#interface.source.sourceModule}}{{!
16
+ Start of step == 'interface_started'
17
+
18
+ - output preamble
12
19
 
13
- - start interface
20
+ }}{{#interface_started}}{{>api-call-step-pre}}{{!
14
21
 
15
- }}{{#interface_started}}
16
- ------------------------------------------------------------------
17
- {{interface.interface_operation}}: at tick '{{parsed.state_space.now}}' for step '{{{parsed.state_space.step }}}'{{!
22
+ - output step header
23
+
24
+ }}{{>api-call-header}}{{!
18
25
 
19
- - input state: dispatched dynamically trough API_INPUT_STATE, which maps
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 API_INPUT_STATE_INIT
28
+ using API_BEFORE_STATE_INIT
22
29
 
23
- }}{{{API_INPUT_STATE}}}{{!
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 API_OUTPUT_STATE, which maps
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
- }}{{{API_OUTPUT_STATE}}}{{!
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
- }}{{{API_INPUT_STATE}}}{{!
59
-
60
- - API call
61
-
62
- }}{{{API_CALL}}}{{!
63
-
64
- - API return
65
-
66
- }}{{{API_RETURN}}}{{!
51
+ }}{{>api-call-link}}{{!
67
52
 
68
- - output state + some extra lines to separate different api-calls
69
-
70
- }}{{{API_OUTPUT_STATE}}}{{!
53
+ - output postamble
71
54
 
72
- - link to source file
73
-
74
- }}{{>api-call-link}}{{!
55
+ }}{{>api-call-step-post}}{{!
75
56
 
76
- - end interface_started
57
+ end of 'interface_started'
77
58
 
78
59
  }}{{/interface_started}}{{!
79
60
 
80
- END : ^interface.source.sourceModule
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
+ }}
@@ -0,0 +1,9 @@
1
+ {{!
2
+
3
+ api-call-pre.mustache: Override this template to change wrapping around api-calls
4
+
5
+ }}{{!
6
+ Local Variables:
7
+ require-final-newline: nil
8
+ End:
9
+ }}
@@ -0,0 +1,9 @@
1
+ {{!
2
+
3
+ api-call-ret-post.mustache: Override this template to change wrapping around api-calls
4
+
5
+ }}{{!
6
+ Local Variables:
7
+ require-final-newline: nil
8
+ End:
9
+ }}
@@ -0,0 +1,9 @@
1
+ {{!
2
+
3
+ api-call-ret-pre.mustache: Override this template to change wrapping around api-calls
4
+
5
+ }}{{!
6
+ Local Variables:
7
+ require-final-newline: nil
8
+ End:
9
+ }}
@@ -0,0 +1,9 @@
1
+ {{!
2
+
3
+ api-call-step-post.mustache: Override this template to change wrapping around api-calls
4
+
5
+ }}{{!
6
+ Local Variables:
7
+ require-final-newline: nil
8
+ End:
9
+ }}
@@ -0,0 +1,10 @@
1
+ {{!
2
+
3
+ api-call-step-pre.mustache: Override this template to change wrapping around api-calls
4
+
5
+ }}------------------------------------------------------------------
6
+ {{!
7
+ Local Variables:
8
+ require-final-newline: nil
9
+ End:
10
+ }}
@@ -23,8 +23,8 @@
23
23
 
24
24
  API call releated stuff
25
25
 
26
- :inputState : state space parsed before making API-call
27
- :outputState : state space parsed after making API-call
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}}{{!
@@ -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