gauge-ruby 0.4.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/code_parser.rb +52 -41
- data/lib/configuration.rb +37 -26
- data/lib/datastore.rb +6 -18
- data/lib/executor.rb +29 -36
- data/lib/gauge.rb +6 -19
- data/lib/gauge_messages.rb +12 -18
- data/lib/gauge_runtime.rb +14 -66
- data/lib/gauge_screenshot.rb +52 -0
- data/lib/log.rb +34 -28
- data/lib/messages_pb.rb +331 -0
- data/lib/method_cache.rb +21 -18
- data/lib/processors/cache_file_processor.rb +20 -31
- data/lib/processors/datastore_init_processor.rb +23 -30
- data/lib/processors/execute_step_request_processor.rb +11 -23
- data/lib/processors/execution_handler.rb +33 -33
- data/lib/processors/execution_hook_processors.rb +23 -36
- data/lib/processors/implementation_file_list_processor.rb +8 -21
- data/lib/processors/implementation_glob_pattern_processor.rb +15 -0
- data/lib/processors/kill_request_processor.rb +5 -17
- data/lib/processors/refactor_step_request_processor.rb +16 -28
- data/lib/processors/step_name_request_processor.rb +15 -30
- data/lib/processors/step_names_request_processor.rb +8 -22
- data/lib/processors/step_positions_request_processor.rb +9 -22
- data/lib/processors/step_validation_request_processor.rb +23 -37
- data/lib/processors/stub_implementation_processor.rb +10 -22
- data/lib/service_handlers.rb +110 -0
- data/lib/services_pb.rb +15 -0
- data/lib/services_services_pb.rb +165 -0
- data/lib/spec_pb.rb +272 -0
- data/lib/static_loader.rb +10 -22
- data/lib/table.rb +5 -17
- data/lib/util.rb +31 -44
- metadata +80 -21
- data/lib/api.pb.rb +0 -273
- data/lib/connector.rb +0 -45
- data/lib/message_processor.rb +0 -59
- data/lib/messages.pb.rb +0 -413
- data/lib/spec.pb.rb +0 -319
@@ -0,0 +1,15 @@
|
|
1
|
+
=begin
|
2
|
+
* Copyright (c) ThoughtWorks, Inc.
|
3
|
+
* Licensed under the Apache License, Version 2.0
|
4
|
+
* See LICENSE.txt in the project root for license information.
|
5
|
+
=end
|
6
|
+
require_relative '../util'
|
7
|
+
|
8
|
+
module Gauge
|
9
|
+
module Processors
|
10
|
+
def process_implementation_glob_pattern_request(_request)
|
11
|
+
implPath = Util.get_step_implementation_dir
|
12
|
+
Messages::ImplementationFileGlobPatternResponse.new(globPatterns: ["#{implPath}/**/*.rb"])
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -1,20 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
# it under the terms of the GNU General Public License as published by
|
7
|
-
# the Free Software Foundation, either version 3 of the License, or
|
8
|
-
# (at your option) any later version.
|
9
|
-
|
10
|
-
# Gauge-Ruby is distributed in the hope that it will be useful,
|
11
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
-
# GNU General Public License for more details.
|
14
|
-
|
15
|
-
# You should have received a copy of the GNU General Public License
|
16
|
-
# along with Gauge-Ruby. If not, see <http://www.gnu.org/licenses/>.
|
17
|
-
|
1
|
+
=begin
|
2
|
+
* Copyright (c) ThoughtWorks, Inc.
|
3
|
+
* Licensed under the Apache License, Version 2.0
|
4
|
+
* See LICENSE.txt in the project root for license information.
|
5
|
+
=end
|
18
6
|
module Gauge
|
19
7
|
# @api private
|
20
8
|
module Processors
|
@@ -1,39 +1,27 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
# it under the terms of the GNU General Public License as published by
|
7
|
-
# the Free Software Foundation, either version 3 of the License, or
|
8
|
-
# (at your option) any later version.
|
9
|
-
|
10
|
-
# Gauge-Ruby is distributed in the hope that it will be useful,
|
11
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
-
# GNU General Public License for more details.
|
14
|
-
|
15
|
-
# You should have received a copy of the GNU General Public License
|
16
|
-
# along with Gauge-Ruby. If not, see <http://www.gnu.org/licenses/>.
|
17
|
-
|
1
|
+
=begin
|
2
|
+
* Copyright (c) ThoughtWorks, Inc.
|
3
|
+
* Licensed under the Apache License, Version 2.0
|
4
|
+
* See LICENSE.txt in the project root for license information.
|
5
|
+
=end
|
18
6
|
require_relative '../code_parser'
|
19
7
|
|
20
8
|
module Gauge
|
21
9
|
module Processors
|
22
|
-
def
|
23
|
-
|
24
|
-
refactor_response = Messages::RefactorResponse.new(success: true)
|
10
|
+
def process_refactor_request(request)
|
11
|
+
response = Messages::RefactorResponse.new(success: true)
|
25
12
|
begin
|
26
13
|
step_info = get_step request.oldStepValue.stepValue
|
27
|
-
|
14
|
+
refactored_info = CodeParser.refactor step_info, request.paramPositions, request.newStepValue
|
28
15
|
file = step_info[:locations][0][:file]
|
29
|
-
File.write file,
|
30
|
-
|
31
|
-
|
16
|
+
File.write file, refactored_info[:content] if request.saveChanges
|
17
|
+
response.filesChanged.push(file)
|
18
|
+
changes = Messages::FileChanges.new(fileName: file, fileContent: refactored_info[:content], diffs: refactored_info[:diffs])
|
19
|
+
response.fileChanges.push(changes)
|
32
20
|
rescue Exception => e
|
33
|
-
|
34
|
-
|
21
|
+
response.success = false
|
22
|
+
response.error = e.message
|
35
23
|
end
|
36
|
-
|
24
|
+
response
|
37
25
|
end
|
38
26
|
|
39
27
|
def get_step(step_text)
|
@@ -42,4 +30,4 @@ module Gauge
|
|
42
30
|
MethodCache.get_step_info(step_text)
|
43
31
|
end
|
44
32
|
end
|
45
|
-
end
|
33
|
+
end
|
@@ -1,35 +1,20 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
# it under the terms of the GNU General Public License as published by
|
7
|
-
# the Free Software Foundation, either version 3 of the License, or
|
8
|
-
# (at your option) any later version.
|
9
|
-
|
10
|
-
# Gauge-Ruby is distributed in the hope that it will be useful,
|
11
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
-
# GNU General Public License for more details.
|
14
|
-
|
15
|
-
# You should have received a copy of the GNU General Public License
|
16
|
-
# along with Gauge-Ruby. If not, see <http://www.gnu.org/licenses/>.
|
17
|
-
|
1
|
+
=begin
|
2
|
+
* Copyright (c) ThoughtWorks, Inc.
|
3
|
+
* Licensed under the Apache License, Version 2.0
|
4
|
+
* See LICENSE.txt in the project root for license information.
|
5
|
+
=end
|
18
6
|
module Gauge
|
19
7
|
module Processors
|
20
|
-
def process_step_name_request(
|
21
|
-
step_value =
|
22
|
-
|
23
|
-
|
24
|
-
has_alias = MethodCache.has_alias?(step_text)
|
25
|
-
loc = MethodCache.get_step_info(step_value)[:locations][0]
|
26
|
-
span = Gauge::Messages::Span.new(start: loc[:span].begin.line, end: loc[:span].end.line, startChar: loc[:span].begin.column, endChar: loc[:span].end.column)
|
27
|
-
r = Messages::StepNameResponse.new(isStepPresent: true, stepName: [step_text], hasAlias: has_alias, fileName: loc[:file], span: span)
|
28
|
-
Messages::Message.new(:messageType => Messages::Message::MessageType::StepNameResponse, :messageId => message.messageId, :stepNameResponse => r)
|
29
|
-
else
|
30
|
-
r = Messages::StepNameResponse.new(isStepPresent: false, stepName: [''], hasAlias: false, fileName: '', span: nil)
|
31
|
-
Messages::Message.new(:messageType => Messages::Message::MessageType::StepNameResponse, :messageId => message.messageId, :stepNameResponse => r)
|
8
|
+
def process_step_name_request(request)
|
9
|
+
step_value = request.stepValue
|
10
|
+
unless MethodCache.valid_step?(step_value)
|
11
|
+
return Messages::StepNameResponse.new(isStepPresent: false, stepName: [""], hasAlias: false, fileName: "", span: nil)
|
32
12
|
end
|
13
|
+
step_text = MethodCache.get_step_text(step_value)
|
14
|
+
has_alias = MethodCache.has_alias?(step_text)
|
15
|
+
loc = MethodCache.get_step_info(step_value)[:locations][0]
|
16
|
+
span = Gauge::Messages::Span.new(start: loc[:span].begin.line, end: loc[:span].end.line, startChar: loc[:span].begin.column, endChar: loc[:span].end.column)
|
17
|
+
Messages::StepNameResponse.new(isStepPresent: true, stepName: [step_text], hasAlias: has_alias, fileName: loc[:file], span: span)
|
33
18
|
end
|
34
19
|
end
|
35
|
-
end
|
20
|
+
end
|
@@ -1,26 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
# it under the terms of the GNU General Public License as published by
|
7
|
-
# the Free Software Foundation, either version 3 of the License, or
|
8
|
-
# (at your option) any later version.
|
9
|
-
|
10
|
-
# Gauge-Ruby is distributed in the hope that it will be useful,
|
11
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
-
# GNU General Public License for more details.
|
14
|
-
|
15
|
-
# You should have received a copy of the GNU General Public License
|
16
|
-
# along with Gauge-Ruby. If not, see <http://www.gnu.org/licenses/>.
|
17
|
-
|
1
|
+
=begin
|
2
|
+
* Copyright (c) ThoughtWorks, Inc.
|
3
|
+
* Licensed under the Apache License, Version 2.0
|
4
|
+
* See LICENSE.txt in the project root for license information.
|
5
|
+
=end
|
18
6
|
module Gauge
|
19
7
|
module Processors
|
20
|
-
def process_step_names_request(
|
21
|
-
|
22
|
-
Messages::Message.new(:messageType => Messages::Message::MessageType::StepNamesResponse,
|
23
|
-
:messageId => message.messageId, :stepNamesResponse => step_names_response)
|
8
|
+
def process_step_names_request(_request)
|
9
|
+
Messages::StepNamesResponse.new(steps: MethodCache.all_steps)
|
24
10
|
end
|
25
11
|
end
|
26
|
-
end
|
12
|
+
end
|
@@ -1,28 +1,15 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
# it under the terms of the GNU General Public License as published by
|
7
|
-
# the Free Software Foundation, either version 3 of the License, or
|
8
|
-
# (at your option) any later version.
|
9
|
-
|
10
|
-
# Gauge-Ruby is distributed in the hope that it will be useful,
|
11
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
-
# GNU General Public License for more details.
|
14
|
-
|
15
|
-
# You should have received a copy of the GNU General Public License
|
16
|
-
# along with Gauge-Ruby. If not, see <http://www.gnu.org/licenses/>.
|
17
|
-
|
1
|
+
=begin
|
2
|
+
* Copyright (c) ThoughtWorks, Inc.
|
3
|
+
* Licensed under the Apache License, Version 2.0
|
4
|
+
* See LICENSE.txt in the project root for license information.
|
5
|
+
=end
|
18
6
|
module Gauge
|
19
7
|
module Processors
|
20
|
-
def process_step_positions_request(
|
21
|
-
file =
|
8
|
+
def process_step_positions_request(request)
|
9
|
+
file = request.filePath
|
22
10
|
positions = MethodCache.step_positions(file)
|
23
11
|
p = create_step_position_messages(positions)
|
24
|
-
|
25
|
-
Messages::Message.new(:messageType => Messages::Message::MessageType::StepPositionsResponse, :messageId => message.messageId, :stepPositionsResponse => r)
|
12
|
+
Messages::StepPositionsResponse.new(:stepPositions => p)
|
26
13
|
end
|
27
14
|
|
28
15
|
def create_step_position_messages(positions)
|
@@ -32,4 +19,4 @@ module Gauge
|
|
32
19
|
end
|
33
20
|
end
|
34
21
|
end
|
35
|
-
end
|
22
|
+
end
|
@@ -1,49 +1,35 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
# it under the terms of the GNU General Public License as published by
|
7
|
-
# the Free Software Foundation, either version 3 of the License, or
|
8
|
-
# (at your option) any later version.
|
9
|
-
|
10
|
-
# Gauge-Ruby is distributed in the hope that it will be useful,
|
11
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
-
# GNU General Public License for more details.
|
14
|
-
|
15
|
-
# You should have received a copy of the GNU General Public License
|
16
|
-
# along with Gauge-Ruby. If not, see <http://www.gnu.org/licenses/>.
|
17
|
-
|
1
|
+
=begin
|
2
|
+
* Copyright (c) ThoughtWorks, Inc.
|
3
|
+
* Licensed under the Apache License, Version 2.0
|
4
|
+
* See LICENSE.txt in the project root for license information.
|
5
|
+
=end
|
18
6
|
module Gauge
|
19
7
|
module Processors
|
20
|
-
def process_step_validation_request(
|
21
|
-
|
22
|
-
is_valid = true
|
23
|
-
msg,suggestion = ''
|
24
|
-
err_type = nil
|
8
|
+
def process_step_validation_request(request)
|
9
|
+
response = Messages::StepValidateResponse.new(isValid: true)
|
25
10
|
if !MethodCache.valid_step? request.stepText
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
11
|
+
suggestion = request.stepValue.stepValue.empty? ? '' : create_suggestion(request.stepValue)
|
12
|
+
response = Messages::StepValidateResponse.new(
|
13
|
+
isValid: false,
|
14
|
+
errorMessage: 'Step implementation not found',
|
15
|
+
errorType: Messages::StepValidateResponse::ErrorType::STEP_IMPLEMENTATION_NOT_FOUND,
|
16
|
+
suggestion: suggestion
|
17
|
+
)
|
30
18
|
elsif MethodCache.multiple_implementation?(request.stepText)
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
19
|
+
response = Messages::StepValidateResponse.new(
|
20
|
+
isValid: false,
|
21
|
+
errorMessage: "Multiple step implementations found for => '#{request.stepText}'",
|
22
|
+
errorType: Messages::StepValidateResponse::ErrorType::DUPLICATE_STEP_IMPLEMENTATION
|
23
|
+
)
|
35
24
|
end
|
36
|
-
|
37
|
-
Messages::Message.new(:messageType => Messages::Message::MessageType::StepValidateResponse,
|
38
|
-
:messageId => message.messageId,
|
39
|
-
:stepValidateResponse => step_validate_response)
|
25
|
+
response
|
40
26
|
end
|
41
27
|
|
42
28
|
def create_suggestion(step_value)
|
43
29
|
count = -1
|
44
|
-
step_text = step_value.stepValue.gsub(/{}/) {"<arg#{count += 1}>"}
|
45
|
-
params = step_value.parameters.map.with_index {|
|
30
|
+
step_text = step_value.stepValue.gsub(/{}/) { "<arg#{count += 1}>" }
|
31
|
+
params = step_value.parameters.map.with_index { |_v, i| "arg#{i}" }.join ', '
|
46
32
|
"step '#{step_text}' do |#{params}|\n\traise 'Unimplemented Step'\nend"
|
47
33
|
end
|
48
34
|
end
|
49
|
-
end
|
35
|
+
end
|
@@ -1,27 +1,15 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
# it under the terms of the GNU General Public License as published by
|
7
|
-
# the Free Software Foundation, either version 3 of the License, or
|
8
|
-
# (at your option) any later version.
|
9
|
-
|
10
|
-
# Gauge-Ruby is distributed in the hope that it will be useful,
|
11
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
-
# GNU General Public License for more details.
|
14
|
-
|
15
|
-
# You should have received a copy of the GNU General Public License
|
16
|
-
# along with Gauge-Ruby. If not, see <http://www.gnu.org/licenses/>.
|
17
|
-
|
1
|
+
=begin
|
2
|
+
* Copyright (c) ThoughtWorks, Inc.
|
3
|
+
* Licensed under the Apache License, Version 2.0
|
4
|
+
* See LICENSE.txt in the project root for license information.
|
5
|
+
=end
|
18
6
|
require_relative '../../lib/util'
|
19
7
|
|
20
8
|
module Gauge
|
21
9
|
module Processors
|
22
|
-
def process_stub_implementation_code_request(
|
23
|
-
codes =
|
24
|
-
file_path =
|
10
|
+
def process_stub_implementation_code_request(request)
|
11
|
+
codes = request.codes
|
12
|
+
file_path = request.implementationFilePath
|
25
13
|
content = ''
|
26
14
|
if File.file? file_path
|
27
15
|
content = File.read(file_path)
|
@@ -29,10 +17,10 @@ module Gauge
|
|
29
17
|
file_path = Util.get_file_name
|
30
18
|
end
|
31
19
|
text_diffs = [Messages::TextDiff.new(span: create_span(content, codes), content: codes.join("\n"))]
|
32
|
-
|
33
|
-
Messages::Message.new(messageType: Messages::Message::MessageType::FileDiff, messageId: message.messageId, fileDiff: file_diff)
|
20
|
+
Messages::FileDiff.new(filePath: file_path, textDiffs: text_diffs)
|
34
21
|
end
|
35
22
|
|
23
|
+
private
|
36
24
|
def create_span(content, codes)
|
37
25
|
unless content.empty?
|
38
26
|
eof_char = content.strip.length == content.length ? "\n" : ''
|
@@ -0,0 +1,110 @@
|
|
1
|
+
=begin
|
2
|
+
* Copyright (c) ThoughtWorks, Inc.
|
3
|
+
* Licensed under the Apache License, Version 2.0
|
4
|
+
* See LICENSE.txt in the project root for license information.
|
5
|
+
=end
|
6
|
+
require_relative "services_services_pb"
|
7
|
+
Dir[File.join(File.dirname(__FILE__), "processors/*.rb")].each { |file| require file }
|
8
|
+
|
9
|
+
module Gauge
|
10
|
+
class ExecutionHandler < Messages::Runner::Service
|
11
|
+
include Processors
|
12
|
+
|
13
|
+
def initialize(server)
|
14
|
+
@server = server
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize_suite_data_store(request, _call)
|
18
|
+
process_suite_data_store_init_request(request)
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize_spec_data_store(request, _call)
|
22
|
+
process_spec_data_store_init_request(request)
|
23
|
+
end
|
24
|
+
|
25
|
+
def initialize_scenario_data_store(request, _call)
|
26
|
+
process_scenario_data_store_init_request(request)
|
27
|
+
end
|
28
|
+
|
29
|
+
def start_execution(request, _call)
|
30
|
+
process_execution_start_request(request)
|
31
|
+
end
|
32
|
+
|
33
|
+
def finish_execution(request, _call)
|
34
|
+
process_execution_end_request(request)
|
35
|
+
end
|
36
|
+
|
37
|
+
def start_spec_execution(request, _call)
|
38
|
+
process_spec_execution_start_request(request)
|
39
|
+
end
|
40
|
+
|
41
|
+
def finish_spec_execution(request, _call)
|
42
|
+
process_spec_execution_end_request(request)
|
43
|
+
end
|
44
|
+
|
45
|
+
def start_scenario_execution(request, _call)
|
46
|
+
process_scenario_execution_start_request(request)
|
47
|
+
end
|
48
|
+
|
49
|
+
def finish_scenario_execution(request, _call)
|
50
|
+
process_scenario_execution_end_request(request)
|
51
|
+
end
|
52
|
+
|
53
|
+
def start_step_execution(request, _call)
|
54
|
+
process_step_execution_start_request(request)
|
55
|
+
end
|
56
|
+
|
57
|
+
def finish_step_execution(request, _call)
|
58
|
+
process_step_execution_end_request(request)
|
59
|
+
end
|
60
|
+
|
61
|
+
def execute_step(request, _call)
|
62
|
+
process_execute_step_request(request)
|
63
|
+
end
|
64
|
+
|
65
|
+
def get_step_names(request, _call)
|
66
|
+
process_step_names_request(request)
|
67
|
+
end
|
68
|
+
|
69
|
+
def cache_file(request, _call)
|
70
|
+
process_cache_file_request(request)
|
71
|
+
end
|
72
|
+
|
73
|
+
def get_step_positions(request, _call)
|
74
|
+
process_step_positions_request(request)
|
75
|
+
end
|
76
|
+
|
77
|
+
def get_implementation_files(request, _call)
|
78
|
+
process_implementation_file_list_request(request)
|
79
|
+
end
|
80
|
+
|
81
|
+
def implement_stub(request, _call)
|
82
|
+
process_stub_implementation_code_request(request)
|
83
|
+
end
|
84
|
+
|
85
|
+
def refactor(request, _call)
|
86
|
+
process_refactor_request(request)
|
87
|
+
end
|
88
|
+
|
89
|
+
def get_step_name(request, _call)
|
90
|
+
process_step_name_request(request)
|
91
|
+
end
|
92
|
+
|
93
|
+
def get_glob_patterns(request, _call)
|
94
|
+
process_implementation_glob_pattern_request(request)
|
95
|
+
end
|
96
|
+
|
97
|
+
def validate_step(request, _call)
|
98
|
+
process_step_validation_request(request)
|
99
|
+
end
|
100
|
+
|
101
|
+
def kill(_request, _call)
|
102
|
+
Thread.new do
|
103
|
+
sleep 0.1
|
104
|
+
@server.stop
|
105
|
+
exit(0)
|
106
|
+
end.run
|
107
|
+
Messages::Empty.new
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|