bauxite 0.6.18 → 0.6.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +21 -21
- data/README.md +293 -293
- data/Rakefile +128 -128
- data/bin/bauxite +27 -27
- data/doc/Bauxite.html +6 -9
- data/doc/Bauxite/Action.html +298 -315
- data/doc/Bauxite/ActionModule.html +23 -26
- data/doc/Bauxite/Application.html +36 -38
- data/doc/Bauxite/Context.html +303 -303
- data/doc/Bauxite/Errors.html +6 -9
- data/doc/Bauxite/Errors/AssertionError.html +6 -9
- data/doc/Bauxite/Errors/FileNotFoundError.html +6 -9
- data/doc/Bauxite/Errors/FormatError.html +6 -9
- data/doc/Bauxite/Loggers.html +6 -9
- data/doc/Bauxite/Loggers/CompositeLogger.html +29 -32
- data/doc/Bauxite/Loggers/EchoLogger.html +10 -13
- data/doc/Bauxite/Loggers/FileLogger.html +25 -28
- data/doc/Bauxite/Loggers/HtmlLogger.html +99 -102
- data/doc/Bauxite/Loggers/NullLogger.html +16 -19
- data/doc/Bauxite/Loggers/ReportLogger.html +43 -46
- data/doc/Bauxite/Loggers/TerminalLogger.html +76 -79
- data/doc/Bauxite/Loggers/XtermLogger.html +28 -31
- data/doc/Bauxite/Parser.html +87 -89
- data/doc/Bauxite/ParserModule.html +19 -22
- data/doc/Bauxite/Selector.html +99 -105
- data/doc/Bauxite/SelectorModule.html +27 -30
- data/doc/README_md.html +117 -103
- data/doc/created.rid +58 -58
- data/doc/fonts.css +167 -167
- data/doc/fonts/Lato-Light.ttf +0 -0
- data/doc/fonts/Lato-LightItalic.ttf +0 -0
- data/doc/fonts/Lato-Regular.ttf +0 -0
- data/doc/fonts/Lato-RegularItalic.ttf +0 -0
- data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
- data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
- data/doc/images/add.png +0 -0
- data/doc/images/arrow_up.png +0 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/transparent.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +117 -103
- data/doc/js/darkfish.js +32 -11
- data/doc/js/jquery.js +0 -0
- data/doc/js/navigation.js +0 -0
- data/doc/js/search.js +0 -0
- data/doc/js/search_index.js +1 -1
- data/doc/js/searcher.js +0 -0
- data/doc/rdoc.css +580 -580
- data/doc/table_of_contents.html +69 -72
- data/lib/bauxite.rb +28 -28
- data/lib/bauxite/actions/alias.rb +51 -51
- data/lib/bauxite/actions/assert.rb +49 -49
- data/lib/bauxite/actions/asserth.rb +60 -60
- data/lib/bauxite/actions/assertm.rb +49 -49
- data/lib/bauxite/actions/assertv.rb +40 -40
- data/lib/bauxite/actions/assertw.rb +47 -47
- data/lib/bauxite/actions/break.rb +39 -39
- data/lib/bauxite/actions/capture.rb +61 -61
- data/lib/bauxite/actions/click.rb +36 -36
- data/lib/bauxite/actions/debug.rb +103 -103
- data/lib/bauxite/actions/doif.rb +43 -43
- data/lib/bauxite/actions/dounless.rb +43 -43
- data/lib/bauxite/actions/echo.rb +36 -36
- data/lib/bauxite/actions/exec.rb +46 -46
- data/lib/bauxite/actions/exit.rb +35 -35
- data/lib/bauxite/actions/failif.rb +52 -52
- data/lib/bauxite/actions/js.rb +41 -41
- data/lib/bauxite/actions/load.rb +49 -49
- data/lib/bauxite/actions/open.rb +35 -35
- data/lib/bauxite/actions/params.rb +40 -40
- data/lib/bauxite/actions/replace.rb +37 -37
- data/lib/bauxite/actions/reset.rb +38 -38
- data/lib/bauxite/actions/return.rb +68 -68
- data/lib/bauxite/actions/ruby.rb +58 -58
- data/lib/bauxite/actions/select.rb +48 -48
- data/lib/bauxite/actions/set.rb +39 -39
- data/lib/bauxite/actions/setif.rb +44 -44
- data/lib/bauxite/actions/source.rb +44 -44
- data/lib/bauxite/actions/store.rb +38 -38
- data/lib/bauxite/actions/submit.rb +37 -37
- data/lib/bauxite/actions/test.rb +67 -67
- data/lib/bauxite/actions/tryload.rb +71 -71
- data/lib/bauxite/actions/wait.rb +38 -38
- data/lib/bauxite/actions/write.rb +44 -44
- data/lib/bauxite/application.rb +349 -349
- data/lib/bauxite/core/action.rb +199 -199
- data/lib/bauxite/core/context.rb +791 -791
- data/lib/bauxite/core/errors.rb +41 -41
- data/lib/bauxite/core/logger.rb +169 -169
- data/lib/bauxite/core/parser.rb +85 -85
- data/lib/bauxite/core/selector.rb +152 -152
- data/lib/bauxite/loggers/composite.rb +91 -91
- data/lib/bauxite/loggers/echo.rb +36 -36
- data/lib/bauxite/loggers/file.rb +68 -68
- data/lib/bauxite/loggers/html.rb +154 -154
- data/lib/bauxite/loggers/terminal.rb +134 -134
- data/lib/bauxite/loggers/xterm.rb +101 -101
- data/lib/bauxite/parsers/csv.rb +43 -43
- data/lib/bauxite/parsers/default.rb +42 -42
- data/lib/bauxite/parsers/html.rb +79 -79
- data/lib/bauxite/selectors/attr.rb +39 -39
- data/lib/bauxite/selectors/frame.rb +60 -60
- data/lib/bauxite/selectors/json.rb +88 -88
- data/lib/bauxite/selectors/sid.rb +38 -38
- data/lib/bauxite/selectors/smart.rb +80 -80
- data/lib/bauxite/selectors/window.rb +77 -77
- data/test/alert.bxt +3 -3
- data/test/alert/page.html +4 -4
- data/test/alias.bxt +9 -9
- data/test/asserth.bxt +2 -2
- data/test/assertv.bxt +1 -1
- data/test/assertw.bxt +7 -7
- data/test/broken.bxt.manual +0 -0
- data/test/bug_load_path.bxt.manual +0 -0
- data/test/bug_load_path/broken.bxt.manual +0 -0
- data/test/bug_load_path/test.bxt +0 -0
- data/test/capture.bxt.manual +20 -20
- data/test/capture/my_test.bxt +1 -1
- data/test/capture/page.html +6 -6
- data/test/capture_on_error.bxt.manual +3 -3
- data/test/capture_on_error/my_test.bxt +1 -1
- data/test/capture_on_error/page.html +2 -2
- data/test/debug.bxt.manual +0 -0
- data/test/default_selector.bxt.manual +7 -7
- data/test/default_selector/page.html +10 -10
- data/test/default_selector_var.bxt +1 -1
- data/test/delay.bxt +2 -2
- data/test/delay/page.html +4 -4
- data/test/doif.bxt +6 -6
- data/test/dounless.bxt +6 -6
- data/test/exec.bxt +6 -6
- data/test/exit.bxt +3 -3
- data/test/exit/test.bxt +3 -3
- data/test/extension.bxt.manual +4 -4
- data/test/extension/custom.rb +12 -12
- data/test/extension/page.html +4 -4
- data/test/failif.bxt +7 -7
- data/test/failif/page.html +5 -5
- data/test/format.bxt +17 -17
- data/test/format/page.html +6 -6
- data/test/frame.bxt +6 -6
- data/test/frame/child_frame.html +6 -6
- data/test/frame/grandchild_frame.html +4 -4
- data/test/frame/page.html +4 -4
- data/test/js.bxt +4 -4
- data/test/json.bxt +19 -19
- data/test/json/array.json +3 -3
- data/test/json/object.json +13 -13
- data/test/load.bxt +18 -18
- data/test/load/child.bxt +12 -12
- data/test/parsers.bxt +1 -1
- data/test/parsers.csv +7 -7
- data/test/parsers.html +32 -32
- data/test/parsers/page.html +6 -6
- data/test/return.bxt +1 -1
- data/test/return/f1.bxt +1 -1
- data/test/return/f2.bxt +1 -1
- data/test/return/f3.bxt +1 -1
- data/test/return/f4.bxt +2 -2
- data/test/ruby.bxt +1 -1
- data/test/ruby/custom.rb +5 -5
- data/test/select.bxt +9 -9
- data/test/select/page.html +8 -8
- data/test/selectors.bxt +7 -7
- data/test/selectors/page.html +6 -6
- data/test/set_builtin.bxt +5 -0
- data/test/set_builtin/page.html +5 -0
- data/test/setif.bxt +3 -3
- data/test/smart_selector.bxt +17 -17
- data/test/smart_selector/page.html +17 -17
- data/test/stdin.bxt +0 -0
- data/test/submit.bxt +4 -4
- data/test/submit/page.html +6 -6
- data/test/submit/page2.html +4 -4
- data/test/test.bxt.manual +6 -6
- data/test/test/test1.bxt +2 -2
- data/test/test/test2.bxt +3 -3
- data/test/test/test3.bxt +2 -2
- data/test/test/test4.bxt +1 -1
- data/test/test/test5.bxt +1 -1
- data/test/window.bxt +14 -14
- data/test/window/page.html +5 -5
- data/test/window/popup.html +4 -4
- metadata +5 -3
data/lib/bauxite/core/errors.rb
CHANGED
@@ -1,42 +1,42 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2014 Patricio Zavolinsky
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
-
# of this software and associated documentation files (the "Software"), to deal
|
6
|
-
# in the Software without restriction, including without limitation the rights
|
7
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
-
# copies of the Software, and to permit persons to whom the Software is
|
9
|
-
# furnished to do so, subject to the following conditions:
|
10
|
-
#
|
11
|
-
# The above copyright notice and this permission notice shall be included in
|
12
|
-
# all copies or substantial portions of the Software.
|
13
|
-
#
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
-
# SOFTWARE.
|
21
|
-
#++
|
22
|
-
|
23
|
-
module Bauxite
|
24
|
-
# Errors Module
|
25
|
-
module Errors
|
26
|
-
# Error raised when an assertion fails.
|
27
|
-
#
|
28
|
-
class AssertionError < StandardError
|
29
|
-
end
|
30
|
-
|
31
|
-
# Error raised when an invalid file tried to be loaded.
|
32
|
-
#
|
33
|
-
class FileNotFoundError < StandardError
|
34
|
-
end
|
35
|
-
|
36
|
-
# Error raised when trying to process an invalid file format.
|
37
|
-
#
|
38
|
-
class FormatError < StandardError
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2014 Patricio Zavolinsky
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
# SOFTWARE.
|
21
|
+
#++
|
22
|
+
|
23
|
+
module Bauxite
|
24
|
+
# Errors Module
|
25
|
+
module Errors
|
26
|
+
# Error raised when an assertion fails.
|
27
|
+
#
|
28
|
+
class AssertionError < StandardError
|
29
|
+
end
|
30
|
+
|
31
|
+
# Error raised when an invalid file tried to be loaded.
|
32
|
+
#
|
33
|
+
class FileNotFoundError < StandardError
|
34
|
+
end
|
35
|
+
|
36
|
+
# Error raised when trying to process an invalid file format.
|
37
|
+
#
|
38
|
+
class FormatError < StandardError
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
42
|
end
|
data/lib/bauxite/core/logger.rb
CHANGED
@@ -1,170 +1,170 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2014 Patricio Zavolinsky
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
-
# of this software and associated documentation files (the "Software"), to deal
|
6
|
-
# in the Software without restriction, including without limitation the rights
|
7
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
-
# copies of the Software, and to permit persons to whom the Software is
|
9
|
-
# furnished to do so, subject to the following conditions:
|
10
|
-
#
|
11
|
-
# The above copyright notice and this permission notice shall be included in
|
12
|
-
# all copies or substantial portions of the Software.
|
13
|
-
#
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
-
# SOFTWARE.
|
21
|
-
#++
|
22
|
-
|
23
|
-
module Bauxite
|
24
|
-
# Test loggers module
|
25
|
-
#
|
26
|
-
# The default Logger class and all custom loggers must be included in this
|
27
|
-
# module.
|
28
|
-
#
|
29
|
-
module Loggers
|
30
|
-
# Test logger class.
|
31
|
-
#
|
32
|
-
# Test loggers handle test output format.
|
33
|
-
#
|
34
|
-
# The default logger does not provide any output logging.
|
35
|
-
#
|
36
|
-
# This default behavior can be overriden in a custom logger passed to the
|
37
|
-
# Context constructor (see Context::new). By convention, custom loggers are
|
38
|
-
# defined in the 'loggers/' directory.
|
39
|
-
#
|
40
|
-
class NullLogger
|
41
|
-
|
42
|
-
# Constructs a new null logger instance.
|
43
|
-
#
|
44
|
-
def initialize(options)
|
45
|
-
@options = options
|
46
|
-
end
|
47
|
-
|
48
|
-
# Executes the given block in a logging context.
|
49
|
-
#
|
50
|
-
# This default implementation does not provide any logging
|
51
|
-
# capabilities.
|
52
|
-
#
|
53
|
-
# For example:
|
54
|
-
# log.log_cmd('echo', 'Hello World!') do
|
55
|
-
# puts 'Hello World!'
|
56
|
-
# end
|
57
|
-
# # => echoes 'Hello World!'
|
58
|
-
#
|
59
|
-
def log_cmd(action)
|
60
|
-
yield
|
61
|
-
end
|
62
|
-
|
63
|
-
# Returns the prompt shown by the debug console (see Context#debug).
|
64
|
-
#
|
65
|
-
# For example:
|
66
|
-
# log.debug_prompt
|
67
|
-
# # => returns the debug prompt
|
68
|
-
def debug_prompt
|
69
|
-
'debug> '
|
70
|
-
end
|
71
|
-
|
72
|
-
# Updates the progress of the current action.
|
73
|
-
def progress(value)
|
74
|
-
end
|
75
|
-
|
76
|
-
# Logs the specified string.
|
77
|
-
#
|
78
|
-
# +type+, if specified, should be one of +:error+, +:warning+,
|
79
|
-
# +:info+ (default), +:debug+.
|
80
|
-
#
|
81
|
-
def log(s, type = :info)
|
82
|
-
print s
|
83
|
-
end
|
84
|
-
|
85
|
-
# Completes the log execution.
|
86
|
-
#
|
87
|
-
def finalize(ctx)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
# Report logger.
|
92
|
-
#
|
93
|
-
# This base logger class can be inherited to create reporting loggers.
|
94
|
-
#
|
95
|
-
# Descendent classes must override the #finalize method and iterate the
|
96
|
-
# <tt>@data</tt> array to produce the report.
|
97
|
-
#
|
98
|
-
# The items included in the <tt>@data</tt> array contain the
|
99
|
-
# following fields:
|
100
|
-
# [:name]
|
101
|
-
# Name of the current test.
|
102
|
-
# [:actions]
|
103
|
-
# Array of actions with the following fields
|
104
|
-
# - +:cmd+: name of the action.
|
105
|
-
# - +:args+: action arguments.
|
106
|
-
# - +:action+: action object.
|
107
|
-
# - +:status+: action execution status: +:ok+, +:skip+ or +:error+.
|
108
|
-
# - +:capture+: path to the current capture, if any.
|
109
|
-
#
|
110
|
-
# For an example of a ReportLogger implementation see the HtmlLogger
|
111
|
-
# class.
|
112
|
-
#
|
113
|
-
class ReportLogger < NullLogger
|
114
|
-
# Constructs a new report logger instance.
|
115
|
-
#
|
116
|
-
def initialize(options)
|
117
|
-
super(options)
|
118
|
-
@data = []
|
119
|
-
end
|
120
|
-
|
121
|
-
# Logs the specified string.
|
122
|
-
#
|
123
|
-
# +type+, if specified, should be one of +:error+, +:warning+,
|
124
|
-
# +:info+ (default), +:debug+.
|
125
|
-
#
|
126
|
-
def log(s, type = :info)
|
127
|
-
end
|
128
|
-
|
129
|
-
# Echoes the raw action text.
|
130
|
-
def log_cmd(action)
|
131
|
-
stime = Time.new
|
132
|
-
ret = yield || false
|
133
|
-
etime = Time.new
|
134
|
-
ensure
|
135
|
-
etime ||= Time.new
|
136
|
-
status = case ret; when nil; :error; when false; :skip; else :ok; end
|
137
|
-
|
138
|
-
test_name = action.ctx.variables['__TEST__'] || 'Main'
|
139
|
-
test = @data.find { |t| t[:name] == test_name }
|
140
|
-
unless test
|
141
|
-
test = { :name => test_name, :actions => [] }
|
142
|
-
@data << test
|
143
|
-
end
|
144
|
-
|
145
|
-
capture = action.ctx.variables['__CAPTURE__']
|
146
|
-
if capture == @last_capture
|
147
|
-
capture = nil
|
148
|
-
else
|
149
|
-
@last_capture = capture
|
150
|
-
end
|
151
|
-
|
152
|
-
test[:actions] << {
|
153
|
-
:cmd => action.cmd,
|
154
|
-
:args => action.args(true),
|
155
|
-
:action => action,
|
156
|
-
:status => status,
|
157
|
-
:time => (etime - stime),
|
158
|
-
:capture => capture
|
159
|
-
}
|
160
|
-
|
161
|
-
ret
|
162
|
-
end
|
163
|
-
|
164
|
-
# Completes the log execution.
|
165
|
-
#
|
166
|
-
def finalize(ctx)
|
167
|
-
end
|
168
|
-
end
|
169
|
-
end
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2014 Patricio Zavolinsky
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
# SOFTWARE.
|
21
|
+
#++
|
22
|
+
|
23
|
+
module Bauxite
|
24
|
+
# Test loggers module
|
25
|
+
#
|
26
|
+
# The default Logger class and all custom loggers must be included in this
|
27
|
+
# module.
|
28
|
+
#
|
29
|
+
module Loggers
|
30
|
+
# Test logger class.
|
31
|
+
#
|
32
|
+
# Test loggers handle test output format.
|
33
|
+
#
|
34
|
+
# The default logger does not provide any output logging.
|
35
|
+
#
|
36
|
+
# This default behavior can be overriden in a custom logger passed to the
|
37
|
+
# Context constructor (see Context::new). By convention, custom loggers are
|
38
|
+
# defined in the 'loggers/' directory.
|
39
|
+
#
|
40
|
+
class NullLogger
|
41
|
+
|
42
|
+
# Constructs a new null logger instance.
|
43
|
+
#
|
44
|
+
def initialize(options)
|
45
|
+
@options = options
|
46
|
+
end
|
47
|
+
|
48
|
+
# Executes the given block in a logging context.
|
49
|
+
#
|
50
|
+
# This default implementation does not provide any logging
|
51
|
+
# capabilities.
|
52
|
+
#
|
53
|
+
# For example:
|
54
|
+
# log.log_cmd('echo', 'Hello World!') do
|
55
|
+
# puts 'Hello World!'
|
56
|
+
# end
|
57
|
+
# # => echoes 'Hello World!'
|
58
|
+
#
|
59
|
+
def log_cmd(action)
|
60
|
+
yield
|
61
|
+
end
|
62
|
+
|
63
|
+
# Returns the prompt shown by the debug console (see Context#debug).
|
64
|
+
#
|
65
|
+
# For example:
|
66
|
+
# log.debug_prompt
|
67
|
+
# # => returns the debug prompt
|
68
|
+
def debug_prompt
|
69
|
+
'debug> '
|
70
|
+
end
|
71
|
+
|
72
|
+
# Updates the progress of the current action.
|
73
|
+
def progress(value)
|
74
|
+
end
|
75
|
+
|
76
|
+
# Logs the specified string.
|
77
|
+
#
|
78
|
+
# +type+, if specified, should be one of +:error+, +:warning+,
|
79
|
+
# +:info+ (default), +:debug+.
|
80
|
+
#
|
81
|
+
def log(s, type = :info)
|
82
|
+
print s
|
83
|
+
end
|
84
|
+
|
85
|
+
# Completes the log execution.
|
86
|
+
#
|
87
|
+
def finalize(ctx)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# Report logger.
|
92
|
+
#
|
93
|
+
# This base logger class can be inherited to create reporting loggers.
|
94
|
+
#
|
95
|
+
# Descendent classes must override the #finalize method and iterate the
|
96
|
+
# <tt>@data</tt> array to produce the report.
|
97
|
+
#
|
98
|
+
# The items included in the <tt>@data</tt> array contain the
|
99
|
+
# following fields:
|
100
|
+
# [:name]
|
101
|
+
# Name of the current test.
|
102
|
+
# [:actions]
|
103
|
+
# Array of actions with the following fields
|
104
|
+
# - +:cmd+: name of the action.
|
105
|
+
# - +:args+: action arguments.
|
106
|
+
# - +:action+: action object.
|
107
|
+
# - +:status+: action execution status: +:ok+, +:skip+ or +:error+.
|
108
|
+
# - +:capture+: path to the current capture, if any.
|
109
|
+
#
|
110
|
+
# For an example of a ReportLogger implementation see the HtmlLogger
|
111
|
+
# class.
|
112
|
+
#
|
113
|
+
class ReportLogger < NullLogger
|
114
|
+
# Constructs a new report logger instance.
|
115
|
+
#
|
116
|
+
def initialize(options)
|
117
|
+
super(options)
|
118
|
+
@data = []
|
119
|
+
end
|
120
|
+
|
121
|
+
# Logs the specified string.
|
122
|
+
#
|
123
|
+
# +type+, if specified, should be one of +:error+, +:warning+,
|
124
|
+
# +:info+ (default), +:debug+.
|
125
|
+
#
|
126
|
+
def log(s, type = :info)
|
127
|
+
end
|
128
|
+
|
129
|
+
# Echoes the raw action text.
|
130
|
+
def log_cmd(action)
|
131
|
+
stime = Time.new
|
132
|
+
ret = yield || false
|
133
|
+
etime = Time.new
|
134
|
+
ensure
|
135
|
+
etime ||= Time.new
|
136
|
+
status = case ret; when nil; :error; when false; :skip; else :ok; end
|
137
|
+
|
138
|
+
test_name = action.ctx.variables['__TEST__'] || 'Main'
|
139
|
+
test = @data.find { |t| t[:name] == test_name }
|
140
|
+
unless test
|
141
|
+
test = { :name => test_name, :actions => [] }
|
142
|
+
@data << test
|
143
|
+
end
|
144
|
+
|
145
|
+
capture = action.ctx.variables['__CAPTURE__']
|
146
|
+
if capture == @last_capture
|
147
|
+
capture = nil
|
148
|
+
else
|
149
|
+
@last_capture = capture
|
150
|
+
end
|
151
|
+
|
152
|
+
test[:actions] << {
|
153
|
+
:cmd => action.cmd,
|
154
|
+
:args => action.args(true),
|
155
|
+
:action => action,
|
156
|
+
:status => status,
|
157
|
+
:time => (etime - stime),
|
158
|
+
:capture => capture
|
159
|
+
}
|
160
|
+
|
161
|
+
ret
|
162
|
+
end
|
163
|
+
|
164
|
+
# Completes the log execution.
|
165
|
+
#
|
166
|
+
def finalize(ctx)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
170
|
end
|
data/lib/bauxite/core/parser.rb
CHANGED
@@ -1,86 +1,86 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2014 Patricio Zavolinsky
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
-
# of this software and associated documentation files (the "Software"), to deal
|
6
|
-
# in the Software without restriction, including without limitation the rights
|
7
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
-
# copies of the Software, and to permit persons to whom the Software is
|
9
|
-
# furnished to do so, subject to the following conditions:
|
10
|
-
#
|
11
|
-
# The above copyright notice and this permission notice shall be included in
|
12
|
-
# all copies or substantial portions of the Software.
|
13
|
-
#
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
-
# SOFTWARE.
|
21
|
-
#++
|
22
|
-
|
23
|
-
module Bauxite
|
24
|
-
# Parser common state and behavior.
|
25
|
-
module ParserModule
|
26
|
-
# Constructs a new test parser instance.
|
27
|
-
def initialize(ctx)
|
28
|
-
@ctx = ctx
|
29
|
-
end
|
30
|
-
|
31
|
-
# Parse +file+ and yield the resulting actions.
|
32
|
-
def parse(file)
|
33
|
-
actions = nil
|
34
|
-
Context::parsers.any? { |p| actions = send(p, file) }
|
35
|
-
|
36
|
-
unless actions
|
37
|
-
raise Errors::FormatError, "Invalid format in '#{file}'. None of the available parsers can understand this file format."
|
38
|
-
end
|
39
|
-
|
40
|
-
actions.each do |action, args, text, line|
|
41
|
-
yield action.strip.downcase, args, text, file, line
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
# Parser class.
|
47
|
-
#
|
48
|
-
# Parser represent different strategies for reading input files into lists
|
49
|
-
# of Bauxite actions.
|
50
|
-
#
|
51
|
-
# Each custom parser is defined in a separate file in the 'parsers/'
|
52
|
-
# directory. These files should avoid adding public methods other than
|
53
|
-
# the parser method itself. Also, no +attr_accessors+ should be added.
|
54
|
-
#
|
55
|
-
# Parser methods can use the +ctx+ attribute to refer to the current test
|
56
|
-
# Context.
|
57
|
-
# Parser methods receive a single action hash argument including <tt>:file</tt>
|
58
|
-
# and return an array of arrays or nil if the parser can't handle the file.
|
59
|
-
#
|
60
|
-
# Each element in the output array must contain the following fields:
|
61
|
-
# [
|
62
|
-
# action, # action name
|
63
|
-
# args, # args array
|
64
|
-
# text, # raw action text (before parsing), or nil
|
65
|
-
# line # line in the file that defined the action
|
66
|
-
# ]
|
67
|
-
#
|
68
|
-
# For example:
|
69
|
-
# # === parsers/my_parser.rb ======= #
|
70
|
-
# class Parser
|
71
|
-
# # :category: Parser Methods
|
72
|
-
# def my_parser(action)
|
73
|
-
# # open and read file
|
74
|
-
# [
|
75
|
-
# [ 'echo', [ 'hello world' ], 'echo "hello world"', 0 ],
|
76
|
-
# [ 'write',[ 'id=username', 'jdoe' ], nil , 1 ],
|
77
|
-
# [ 'write',[ 'id=password', 'hello world!' ], nil , 2 ]
|
78
|
-
# ]
|
79
|
-
# end
|
80
|
-
# end
|
81
|
-
# # === end parsers/my_parser.rb === #
|
82
|
-
#
|
83
|
-
class Parser
|
84
|
-
include Bauxite::ParserModule
|
85
|
-
end
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2014 Patricio Zavolinsky
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
# SOFTWARE.
|
21
|
+
#++
|
22
|
+
|
23
|
+
module Bauxite
|
24
|
+
# Parser common state and behavior.
|
25
|
+
module ParserModule
|
26
|
+
# Constructs a new test parser instance.
|
27
|
+
def initialize(ctx)
|
28
|
+
@ctx = ctx
|
29
|
+
end
|
30
|
+
|
31
|
+
# Parse +file+ and yield the resulting actions.
|
32
|
+
def parse(file)
|
33
|
+
actions = nil
|
34
|
+
Context::parsers.any? { |p| actions = send(p, file) }
|
35
|
+
|
36
|
+
unless actions
|
37
|
+
raise Errors::FormatError, "Invalid format in '#{file}'. None of the available parsers can understand this file format."
|
38
|
+
end
|
39
|
+
|
40
|
+
actions.each do |action, args, text, line|
|
41
|
+
yield action.strip.downcase, args, text, file, line
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# Parser class.
|
47
|
+
#
|
48
|
+
# Parser represent different strategies for reading input files into lists
|
49
|
+
# of Bauxite actions.
|
50
|
+
#
|
51
|
+
# Each custom parser is defined in a separate file in the 'parsers/'
|
52
|
+
# directory. These files should avoid adding public methods other than
|
53
|
+
# the parser method itself. Also, no +attr_accessors+ should be added.
|
54
|
+
#
|
55
|
+
# Parser methods can use the +ctx+ attribute to refer to the current test
|
56
|
+
# Context.
|
57
|
+
# Parser methods receive a single action hash argument including <tt>:file</tt>
|
58
|
+
# and return an array of arrays or nil if the parser can't handle the file.
|
59
|
+
#
|
60
|
+
# Each element in the output array must contain the following fields:
|
61
|
+
# [
|
62
|
+
# action, # action name
|
63
|
+
# args, # args array
|
64
|
+
# text, # raw action text (before parsing), or nil
|
65
|
+
# line # line in the file that defined the action
|
66
|
+
# ]
|
67
|
+
#
|
68
|
+
# For example:
|
69
|
+
# # === parsers/my_parser.rb ======= #
|
70
|
+
# class Parser
|
71
|
+
# # :category: Parser Methods
|
72
|
+
# def my_parser(action)
|
73
|
+
# # open and read file
|
74
|
+
# [
|
75
|
+
# [ 'echo', [ 'hello world' ], 'echo "hello world"', 0 ],
|
76
|
+
# [ 'write',[ 'id=username', 'jdoe' ], nil , 1 ],
|
77
|
+
# [ 'write',[ 'id=password', 'hello world!' ], nil , 2 ]
|
78
|
+
# ]
|
79
|
+
# end
|
80
|
+
# end
|
81
|
+
# # === end parsers/my_parser.rb === #
|
82
|
+
#
|
83
|
+
class Parser
|
84
|
+
include Bauxite::ParserModule
|
85
|
+
end
|
86
86
|
end
|