razorrisk-razor-control 0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/RakeFile +46 -0
- data/lib/razor_risk/razor/control/cucumber_helpers/consolidate_reports.rb +80 -0
- data/lib/razor_risk/razor/control/cucumber_helpers/executor.rb +108 -0
- data/lib/razor_risk/razor/control/cucumber_helpers.rb +3 -0
- data/lib/razor_risk/razor/control/diagnostics/util_functions.rb +203 -0
- data/lib/razor_risk/razor/control/diagnostics/zeroth_include.rb +27 -0
- data/lib/razor_risk/razor/control/exceptions.rb +121 -0
- data/lib/razor_risk/razor/control/gem/gem_helpers.rb +397 -0
- data/lib/razor_risk/razor/control/rake_helpers/aborter.rb +90 -0
- data/lib/razor_risk/razor/control/rake_helpers/diagnostic_tasks.rb +74 -0
- data/lib/razor_risk/razor/control/rake_helpers/gem_tasks.rb +128 -0
- data/lib/razor_risk/razor/control/rake_helpers/razor_tasks.rb +195 -0
- data/lib/razor_risk/razor/control/rake_helpers/task_helpers.rb +86 -0
- data/lib/razor_risk/razor/control/rake_helpers.rb +3 -0
- data/lib/razor_risk/razor/control/razor/executor.rb +131 -0
- data/lib/razor_risk/razor/control/razor/razor_instance.rb +227 -0
- data/lib/razor_risk/razor/control/razor.rb +2 -0
- data/lib/razor_risk/razor/control/version.rb +41 -0
- data/test/unit/control/cucumber_helpers/reports/expected/groups.html +213 -0
- data/test/unit/control/cucumber_helpers/reports/expected/no_groups.html +170 -0
- data/test/unit/control/cucumber_helpers/reports/groups/LbbwConfig/LbbwConfig.json +69 -0
- data/test/unit/control/cucumber_helpers/reports/groups/StandardConfig/StandardConfig.json +69 -0
- data/test/unit/control/cucumber_helpers/reports/no_groups/LbbwConfig.json +69 -0
- data/test/unit/control/cucumber_helpers/reports/no_groups/StandardConfig/StandardConfig.json +69 -0
- data/test/unit/control/cucumber_helpers/tc_consolidate_reports.rb +73 -0
- data/test/unit/control/cucumber_helpers/tc_executor.rb +406 -0
- data/test/unit/control/gem/tc_gem_helpers.rb +405 -0
- data/test/unit/control/rake_helpers/tc_aborter.rb +131 -0
- data/test/unit/control/rake_helpers/tc_task_helpers.rb +228 -0
- data/test/unit/control/razor/tc_executor.rb +129 -0
- data/test/unit/control/razor/tc_razor_instance.rb +517 -0
- data/test/unit/control/razor/test_scripts/exit_failure.cmd +3 -0
- data/test/unit/control/razor/test_scripts/exit_strange.cmd +3 -0
- data/test/unit/control/razor/test_scripts/exit_success.cmd +3 -0
- data/test/unit/control/razor/test_scripts/pause.cmd +5 -0
- data/test/unit/control/razor/test_scripts/print.cmd +6 -0
- data/test/unit/control/tc_exceptions.rb +120 -0
- metadata +192 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 11bc6351674d5158b9a6a1996b7ae16fd953fe4a
|
4
|
+
data.tar.gz: 259b460cbac634c3c7c34bfccc3e5c72a2d6bbe2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1b61b9f047002e5e38f73dacf80b03764c3049516d953f8a6c4b44eca1d78582e8c36495d3ca6ed599f5f8642bd33f5afc39bfcaa5bc90d4f39cbc6c72034aef
|
7
|
+
data.tar.gz: 736c3a56258688f0a30a803e0223154164b9ae9eb2b89bde7557e0266802d6c45c6c11f30614353f8f422d5d2f96c1e5c54d380104ae5e4cad415f4d9a77ec6e
|
data/RakeFile
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
# ######################################################################## #
|
4
|
+
#
|
5
|
+
# Rakefile for Razor Risk Razor Control library.
|
6
|
+
#
|
7
|
+
# Copyright (c) 2019 Razor Risk Technologies Pty Limited. All rights reserved.
|
8
|
+
#
|
9
|
+
# ######################################################################## #
|
10
|
+
|
11
|
+
$:.unshift File.join(File.dirname(__FILE__), 'lib')
|
12
|
+
|
13
|
+
# ######################################################################## #
|
14
|
+
# requires
|
15
|
+
|
16
|
+
require 'rake'
|
17
|
+
require 'razor_risk/razor/control/rake_helpers/gem_tasks'
|
18
|
+
|
19
|
+
|
20
|
+
# ##########################################################
|
21
|
+
# Default
|
22
|
+
|
23
|
+
task :default => :test
|
24
|
+
|
25
|
+
|
26
|
+
# ##########################################################
|
27
|
+
# Public Tasks
|
28
|
+
|
29
|
+
desc 'Run tests'
|
30
|
+
task :test => [ :'gem:unit_test' ]
|
31
|
+
|
32
|
+
desc 'Builds the Razor Control Gem'
|
33
|
+
task :build, [ :path ] => :'gem:build'
|
34
|
+
|
35
|
+
desc 'Install gem and dependencies locally and execute unit test'
|
36
|
+
task :installAndTest => :'gem:test_with_local_install'
|
37
|
+
|
38
|
+
desc 'Push the gem to the gem server.'
|
39
|
+
task :deploy => :'gem:push'
|
40
|
+
|
41
|
+
desc 'Builds, unit tests, and pushes the gem to the gem server'
|
42
|
+
task :buildAndDeploy => [ :build, :installAndTest, :deploy ]
|
43
|
+
|
44
|
+
# ############################## end of file ############################# #
|
45
|
+
|
46
|
+
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
# ######################################################################## #
|
4
|
+
#
|
5
|
+
# Cucumber Rake task library.
|
6
|
+
#
|
7
|
+
# Copyright (c) 2019 Razor Risk Technologies Pty Limited. All rights reserved.
|
8
|
+
#
|
9
|
+
# ######################################################################## #
|
10
|
+
|
11
|
+
# ######################################################################## #
|
12
|
+
# requires
|
13
|
+
|
14
|
+
require 'report_builder'
|
15
|
+
|
16
|
+
require 'pantheios'
|
17
|
+
require 'xqsr3/quality/parameter_checking'
|
18
|
+
|
19
|
+
module RazorRisk
|
20
|
+
module Razor
|
21
|
+
module Control
|
22
|
+
module CucumberHelpers
|
23
|
+
|
24
|
+
include ::Pantheios
|
25
|
+
include ::Xqsr3::Quality::ParameterChecking
|
26
|
+
|
27
|
+
# Consolidate multiple Cucumber Reports.
|
28
|
+
#
|
29
|
+
# @param directory [::String] The path to the directory containing
|
30
|
+
# Cucumber results JSON files.
|
31
|
+
# @param report_path [::String] The path to where the output file should
|
32
|
+
# be written.
|
33
|
+
# @param report_name [::String] The name of the output report file.
|
34
|
+
# @param **options [::Hash] The options hash.
|
35
|
+
#
|
36
|
+
# @option options [::String] :title The tile of the report.
|
37
|
+
# @option options [::Hash] :additional_info Any additional information
|
38
|
+
# for the report.
|
39
|
+
#
|
40
|
+
def self.consolidate_reports directory, report_path, report_name, **options
|
41
|
+
|
42
|
+
trace ParamNames[ :directory, :report_path, :options ], directory, report_path, **options
|
43
|
+
|
44
|
+
check_parameter directory, 'directory', type: ::String
|
45
|
+
check_parameter report_path, 'report_path', type: ::String
|
46
|
+
check_parameter report_name, 'report_name', type: ::String
|
47
|
+
check_option options, :title, type: ::String, allow_nil: true
|
48
|
+
check_option options, :additional_info, type: ::Hash, allow_nil: true
|
49
|
+
|
50
|
+
input_files = if Dir[ "#{directory}/*.json" ].empty?
|
51
|
+
Dir[ "#{directory}/*" ].map do |t|
|
52
|
+
[
|
53
|
+
File.basename(t),
|
54
|
+
Dir[ "#{t}/**/*.json" ],
|
55
|
+
] if File.directory? t
|
56
|
+
end.compact.to_h
|
57
|
+
else
|
58
|
+
Dir[ "#{directory}/**/*.json" ]
|
59
|
+
end
|
60
|
+
|
61
|
+
ReportBuilder.configure do |config|
|
62
|
+
config.input_path = input_files
|
63
|
+
config.report_types = [ :html ]
|
64
|
+
config.report_path = File.join(report_path, report_name)
|
65
|
+
config.report_title = options[:title]
|
66
|
+
# NOTE: ReportBuilder will fail if this is set to nil
|
67
|
+
config.additional_info = options[:additional_info] || {}
|
68
|
+
config.color = 'blue'
|
69
|
+
end
|
70
|
+
ReportBuilder.build_report
|
71
|
+
end
|
72
|
+
|
73
|
+
end # module RakeHelpers
|
74
|
+
end # module Razor
|
75
|
+
end # module Razor
|
76
|
+
end # module Razor
|
77
|
+
|
78
|
+
# ############################## end of file ############################# #
|
79
|
+
|
80
|
+
|
@@ -0,0 +1,108 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
# ######################################################################## #
|
4
|
+
#
|
5
|
+
# Cucumber Rake task library.
|
6
|
+
#
|
7
|
+
# Copyright (c) 2019 Razor Risk Technologies Pty Limited. All rights reserved.
|
8
|
+
#
|
9
|
+
# ######################################################################## #
|
10
|
+
|
11
|
+
# ######################################################################## #
|
12
|
+
# requires
|
13
|
+
|
14
|
+
require 'pantheios'
|
15
|
+
require 'xqsr3/quality/parameter_checking'
|
16
|
+
|
17
|
+
require 'fileutils'
|
18
|
+
|
19
|
+
module RazorRisk
|
20
|
+
module Razor
|
21
|
+
module Control
|
22
|
+
module CucumberHelpers
|
23
|
+
|
24
|
+
include ::Pantheios
|
25
|
+
include ::Xqsr3::Quality::ParameterChecking
|
26
|
+
|
27
|
+
# Execute Cucumber tests.
|
28
|
+
#
|
29
|
+
# @param cucumber [::Module] The cucumber module.
|
30
|
+
# @param name [::String] The name of the group of tests.
|
31
|
+
# @param tags [::String] The tags string for filtering cucumber tests.
|
32
|
+
# @param **options [::Hash] The options hash.
|
33
|
+
#
|
34
|
+
# @option options [::String] :report_directory (.) The directory to write
|
35
|
+
# results files into.
|
36
|
+
# @option options [::String] :console (progress) The format to print to
|
37
|
+
# console.
|
38
|
+
# @option options [::String] :group The name of the group this test is part
|
39
|
+
# of.
|
40
|
+
# @option options [boolean] :html Write results to file in HTML format.
|
41
|
+
# @option options [boolean] :json Write results to file in JSON format.
|
42
|
+
# @option options [boolean] :junit Write results to file in JUnit XML format.
|
43
|
+
#
|
44
|
+
# @return [boolean] Whether the cucumber tests succeeded.
|
45
|
+
def self.execute cucumber, name, tags = nil, **options
|
46
|
+
|
47
|
+
trace ParamNames[ :name, :tags, :options ], name, tags, **options
|
48
|
+
|
49
|
+
check_parameter cucumber, 'cucumber', type: ::Module
|
50
|
+
check_parameter name, 'name', type: ::String, reject_empty: true
|
51
|
+
check_parameter tags, 'tags', type: ::String, allow_nil: true, reject_empty: true
|
52
|
+
|
53
|
+
check_option options, :report_directory, type: ::String, allow_nil: true
|
54
|
+
check_option options, :console, type: ::String, allow_nil: true
|
55
|
+
check_option options, :group, type: ::String, allow_nil: true
|
56
|
+
check_option options, :html, type: :boolean, allow_nil: true
|
57
|
+
check_option options, :json, type: :boolean, allow_nil: true
|
58
|
+
check_option options, :junit, type: :boolean, allow_nil: true
|
59
|
+
|
60
|
+
if [ :html, :json, :junit ].any? { |t| options.keys.include? t }
|
61
|
+
report_directory = options[:report_directory] || '.'
|
62
|
+
report_directory = File.join(report_directory, options[:group]) if options[:group]
|
63
|
+
FileUtils.mkdir_p(report_directory)
|
64
|
+
end
|
65
|
+
|
66
|
+
args = []
|
67
|
+
args << '-s' # Don't print the step source location.
|
68
|
+
args << '-x' # Expand scenario template tables.
|
69
|
+
|
70
|
+
if tags
|
71
|
+
args << '-t' << tags
|
72
|
+
end
|
73
|
+
|
74
|
+
if options[:html]
|
75
|
+
args << '--format' << 'html'
|
76
|
+
args << '-o' << File.join(report_directory, "#{name}.html")
|
77
|
+
end
|
78
|
+
|
79
|
+
if options[:junit]
|
80
|
+
args << '--format' << 'junit'
|
81
|
+
args << '-o' << File.join(report_directory, 'JUnit')
|
82
|
+
end
|
83
|
+
|
84
|
+
if options[:json]
|
85
|
+
args << '--format' << 'json'
|
86
|
+
args << '-o' << File.join(report_directory, "#{name}.json")
|
87
|
+
end
|
88
|
+
|
89
|
+
if options[:console]
|
90
|
+
args << '--format' << options[:console]
|
91
|
+
else
|
92
|
+
args << '--format' << 'progress'
|
93
|
+
end
|
94
|
+
|
95
|
+
begin
|
96
|
+
cucumber::Cli::Main.new(args).execute!
|
97
|
+
rescue SystemExit => x
|
98
|
+
x.success?
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end # module CucumberHelpers
|
102
|
+
end # module Control
|
103
|
+
end # module Razor
|
104
|
+
end # module RazorRisk
|
105
|
+
|
106
|
+
# ############################## end of file ############################# #
|
107
|
+
|
108
|
+
|
@@ -0,0 +1,203 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
# ######################################################################## #
|
4
|
+
#
|
5
|
+
# Centralised diagnostics utility functions.
|
6
|
+
#
|
7
|
+
# Copyright (c) 2019 Razor Risk Technologies Pty Limited. All rights reserved.
|
8
|
+
#
|
9
|
+
# ######################################################################## #
|
10
|
+
|
11
|
+
require 'pantheios/application_layer/stock_severity_levels'
|
12
|
+
require 'pantheios/services/multiplexing_log_service'
|
13
|
+
require 'pantheios/services/null_log_service'
|
14
|
+
require 'pantheios/services/simple_console_log_service'
|
15
|
+
require 'pantheios/services/simple_file_log_service'
|
16
|
+
|
17
|
+
require 'xqsr3/quality/parameter_checking'
|
18
|
+
|
19
|
+
require 'fileutils'
|
20
|
+
|
21
|
+
require 'razor_risk/core/diagnostics/logger'
|
22
|
+
|
23
|
+
module RazorRisk
|
24
|
+
module Razor
|
25
|
+
module Control
|
26
|
+
|
27
|
+
module Diagnostics
|
28
|
+
include ::RazorRisk::Core::Diagnostics::Logger
|
29
|
+
module SetupDiagnosticLogging_Constants
|
30
|
+
|
31
|
+
STOCK_SEVERITY_LEVEL_VALUES = Pantheios::ApplicationLayer::StockSeverityLevels::STOCK_SEVERITY_LEVEL_VALUES
|
32
|
+
|
33
|
+
DEFAULT_LOG_THRESHOLD_MAIN = :debug4
|
34
|
+
DEFAULT_LOG_THRESHOLD_CONSOLE = :informational
|
35
|
+
|
36
|
+
BENCHMARK_SEVERITY_VALUE = STOCK_SEVERITY_LEVEL_VALUES[:benchmark]
|
37
|
+
|
38
|
+
DEFAULT_LOG_SIZE_MAIN = 1024 * 1024 * 100
|
39
|
+
|
40
|
+
DEFAULT_LOG_DEPTH = 20
|
41
|
+
end # module SetupDiagnosticLogging_Constants
|
42
|
+
|
43
|
+
# configure diagnostic logging:
|
44
|
+
#
|
45
|
+
# - set program name
|
46
|
+
# - set services:
|
47
|
+
# * main file logger : file, stores all except :benchmark, according to
|
48
|
+
# :log_threshold
|
49
|
+
# * main cons logger : stdout/stderr, only :notice and above
|
50
|
+
#
|
51
|
+
# === Signature
|
52
|
+
#
|
53
|
+
# * *Parameters:*
|
54
|
+
# - +program_name+:: (::String) The program name. May not be +nil+
|
55
|
+
# - +log_directory+:: (::String) The directory in which log-files
|
56
|
+
# will be created. May not be +nil+
|
57
|
+
# - +log_threshold+:: (::String | ::Symbol |[ ::Symbol, ::Symbol ] )
|
58
|
+
# Specifies the log-threshold(s). The threshold(s) is specified as a
|
59
|
+
# string containing comma-separated values, or as a single symbol,
|
60
|
+
# or as an array of symbols, all of which are treated as a sequence
|
61
|
+
# of severity thresholds. The severity thresholds apply,
|
62
|
+
# respectively, to the modifiable-sequence of Console and Main.
|
63
|
+
#
|
64
|
+
# * *Options:*
|
65
|
+
# - +:no_console_log+:: (boolean) Unless truey, a console log will be
|
66
|
+
# created
|
67
|
+
#
|
68
|
+
def self.setup_diagnostic_logging program_name, **options
|
69
|
+
|
70
|
+
program_name = ::Xqsr3::Quality::ParameterChecking.check_parameter program_name, :program_name, type: ::String, treat_as_option: true
|
71
|
+
log_directory = ::Xqsr3::Quality::ParameterChecking.check_parameter options[:log_directory], :log_directory, type: ::String, treat_as_option: true, allow_nil: true
|
72
|
+
log_threshold = ::Xqsr3::Quality::ParameterChecking.check_parameter options[:log_threshold], :log_threshold, types: [ ::Array, ::Integer, ::Symbol ], treat_as_option: true, allow_nil: true
|
73
|
+
|
74
|
+
case log_threshold
|
75
|
+
when ::Array
|
76
|
+
|
77
|
+
log_thresholds = log_threshold.dup
|
78
|
+
when ::Symbol
|
79
|
+
|
80
|
+
log_thresholds = [ log_threshold ]
|
81
|
+
else
|
82
|
+
|
83
|
+
log_thresholds = []
|
84
|
+
end
|
85
|
+
|
86
|
+
console_threshold = log_thresholds.shift || options[:console_threshold] || SetupDiagnosticLogging_Constants::DEFAULT_LOG_THRESHOLD_CONSOLE
|
87
|
+
main_threshold = log_thresholds.shift || options[:main_threshold] || SetupDiagnosticLogging_Constants::DEFAULT_LOG_THRESHOLD_MAIN
|
88
|
+
|
89
|
+
console_threshold_v = ::Integer === console_threshold ? console_threshold : SetupDiagnosticLogging_Constants::STOCK_SEVERITY_LEVEL_VALUES[console_threshold]
|
90
|
+
main_threshold_v = ::Integer === main_threshold ? main_threshold : SetupDiagnosticLogging_Constants::STOCK_SEVERITY_LEVEL_VALUES[main_threshold]
|
91
|
+
|
92
|
+
services = []
|
93
|
+
|
94
|
+
if log_directory
|
95
|
+
|
96
|
+
unless File.directory?(log_directory)
|
97
|
+
|
98
|
+
climate.abort "log directory '#{log_directory}' exists and is not a directory" if File.exist?(log_directory)
|
99
|
+
|
100
|
+
begin
|
101
|
+
|
102
|
+
FileUtils.mkdir_p log_directory
|
103
|
+
rescue => x
|
104
|
+
|
105
|
+
log :alert, "exception(#{x.class}): #{x.message}"
|
106
|
+
|
107
|
+
climate.abort x.message
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
mf_log_file_name = program_name + '-main.log'
|
112
|
+
|
113
|
+
mf_log_file_path = File.join(log_directory, mf_log_file_name)
|
114
|
+
|
115
|
+
mf_logger = Pantheios::Services::SimpleFileLogService.new mf_log_file_path, roll_size: SetupDiagnosticLogging_Constants::DEFAULT_LOG_SIZE_MAIN, roll_depth: SetupDiagnosticLogging_Constants::DEFAULT_LOG_DEPTH
|
116
|
+
|
117
|
+
mf_logger.instance_variable_set :@main_threshold_v_, main_threshold_v
|
118
|
+
|
119
|
+
def mf_logger.severity_logged? severity
|
120
|
+
|
121
|
+
return true unless @main_threshold_v_
|
122
|
+
|
123
|
+
severity = :debug4 if :debug == severity
|
124
|
+
|
125
|
+
severity_v = nil
|
126
|
+
|
127
|
+
case severity
|
128
|
+
when :benchmark, SetupDiagnosticLogging_Constants::BENCHMARK_SEVERITY_VALUE
|
129
|
+
|
130
|
+
return false
|
131
|
+
when ::Symbol
|
132
|
+
|
133
|
+
severity_v = SetupDiagnosticLogging_Constants::STOCK_SEVERITY_LEVEL_VALUES[severity]
|
134
|
+
when ::Integer
|
135
|
+
|
136
|
+
severity_v = severity
|
137
|
+
;
|
138
|
+
end
|
139
|
+
|
140
|
+
return true unless severity_v
|
141
|
+
|
142
|
+
severity_v <= @main_threshold_v_
|
143
|
+
end
|
144
|
+
|
145
|
+
services << mf_logger
|
146
|
+
end
|
147
|
+
|
148
|
+
unless options[:no_console_log]
|
149
|
+
|
150
|
+
mc_logger = Pantheios::Services::SimpleConsoleLogService.new
|
151
|
+
|
152
|
+
mc_logger.instance_variable_set :@console_threshold_v_, console_threshold_v
|
153
|
+
|
154
|
+
def mc_logger.severity_logged? severity
|
155
|
+
|
156
|
+
return true unless @console_threshold_v_
|
157
|
+
|
158
|
+
severity = :debug4 if :debug == severity
|
159
|
+
|
160
|
+
severity_v = nil
|
161
|
+
|
162
|
+
case severity
|
163
|
+
when :benchmark, SetupDiagnosticLogging_Constants::BENCHMARK_SEVERITY_VALUE
|
164
|
+
|
165
|
+
return false
|
166
|
+
when ::Symbol
|
167
|
+
|
168
|
+
severity_v = SetupDiagnosticLogging_Constants::STOCK_SEVERITY_LEVEL_VALUES[severity]
|
169
|
+
when ::Integer
|
170
|
+
|
171
|
+
severity_v = severity
|
172
|
+
else
|
173
|
+
|
174
|
+
;
|
175
|
+
end
|
176
|
+
|
177
|
+
return true unless severity_v
|
178
|
+
|
179
|
+
severity_v <= @console_threshold_v_
|
180
|
+
end
|
181
|
+
|
182
|
+
services << mc_logger
|
183
|
+
end
|
184
|
+
|
185
|
+
if services.empty?
|
186
|
+
|
187
|
+
mx_logger = Pantheios::Services::NullLogService.new
|
188
|
+
else
|
189
|
+
|
190
|
+
mx_logger = Pantheios::Services::MultiplexingLogService.new services, level_cache_mode: :thread_fixed
|
191
|
+
end
|
192
|
+
|
193
|
+
::Pantheios::Core.set_service mx_logger
|
194
|
+
end
|
195
|
+
end # module Diagnostics
|
196
|
+
|
197
|
+
end # module Control
|
198
|
+
end # module Razor
|
199
|
+
end # module RazorRisk
|
200
|
+
|
201
|
+
# ############################## end of file ############################# #
|
202
|
+
|
203
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
# ######################################################################## #
|
4
|
+
#
|
5
|
+
# When required as the very first file it sets up, for diagnostics, the main
|
6
|
+
# thread name and the process name
|
7
|
+
#
|
8
|
+
# Copyright (c) 2019 Razor Risk Technologies Pty Limited. All rights reserved.
|
9
|
+
#
|
10
|
+
# ######################################################################## #
|
11
|
+
|
12
|
+
# ##########################################################################
|
13
|
+
# requires
|
14
|
+
|
15
|
+
require 'pantheios/globals'
|
16
|
+
require 'pantheios/services/null_log_service'
|
17
|
+
|
18
|
+
# ##########################################################
|
19
|
+
# Loggin
|
20
|
+
|
21
|
+
Pantheios::Globals.MAIN_THREAD_NAME = [ Thread.current, 'main' ]
|
22
|
+
Pantheios::Globals.PROCESS_NAME = :script_stem
|
23
|
+
Pantheios::Globals.INITIAL_SERVICE_CLASSES = [ ::Pantheios::Services::NullLogService ]
|
24
|
+
|
25
|
+
# ############################## end of file ############################# #
|
26
|
+
|
27
|
+
|
@@ -0,0 +1,121 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
# ######################################################################## #
|
4
|
+
#
|
5
|
+
# Exceptions
|
6
|
+
#
|
7
|
+
# Copyright (c) 2019 Razor Risk Technologies Pty Limited. All rights reserved.
|
8
|
+
#
|
9
|
+
# ######################################################################## #
|
10
|
+
|
11
|
+
|
12
|
+
# ##########################################################################
|
13
|
+
# requires
|
14
|
+
|
15
|
+
require 'razor_risk/core/diagnostics/exceptions'
|
16
|
+
|
17
|
+
require 'pantheios'
|
18
|
+
require 'xqsr3/quality/parameter_checking'
|
19
|
+
|
20
|
+
module RazorRisk
|
21
|
+
module Razor
|
22
|
+
module Control
|
23
|
+
|
24
|
+
# Module for exceptions for control:
|
25
|
+
#
|
26
|
+
# Exceptions:
|
27
|
+
#
|
28
|
+
# (::RazorRisk::Core::Diagnostics::Exceptions::RRCSBaseException)
|
29
|
+
# |
|
30
|
+
# +- ControlException (abstract)
|
31
|
+
# |
|
32
|
+
# +- GemDeploymentException
|
33
|
+
# |
|
34
|
+
# +- RazorControlException
|
35
|
+
#
|
36
|
+
module Exceptions
|
37
|
+
|
38
|
+
# @abstract
|
39
|
+
#
|
40
|
+
# Root exception class for Control module
|
41
|
+
#
|
42
|
+
class ControlException < ::RazorRisk::Core::Diagnostics::Exceptions::RRCSBaseException
|
43
|
+
|
44
|
+
include ::Pantheios
|
45
|
+
|
46
|
+
# ControlException Constants
|
47
|
+
module Constants
|
48
|
+
|
49
|
+
# List of derived classes that are abstract.
|
50
|
+
ABSTRACT_CLASSES = %w{
|
51
|
+
ControlException
|
52
|
+
}
|
53
|
+
|
54
|
+
end # module Constants
|
55
|
+
|
56
|
+
# Override of +new+ to enforce abstract exception classes cannot be
|
57
|
+
# constructed.
|
58
|
+
def self.new *args
|
59
|
+
|
60
|
+
if Constants::ABSTRACT_CLASSES.include?(self.name.split('::')[-1])
|
61
|
+
|
62
|
+
raise NoMethodError, "private method `new' called for #{self}:Class"
|
63
|
+
end
|
64
|
+
|
65
|
+
super
|
66
|
+
end
|
67
|
+
|
68
|
+
# @return [::Hash] the options hash.
|
69
|
+
attr_reader :options
|
70
|
+
|
71
|
+
# Initialises an instance, based on the given message and options
|
72
|
+
#
|
73
|
+
# @param message [String] The exception message/
|
74
|
+
# @param options [Hash] The options hash.
|
75
|
+
#
|
76
|
+
# @option cause [Exception] The cause.
|
77
|
+
#
|
78
|
+
def initialize message, **options
|
79
|
+
|
80
|
+
trace ParamNames[ :message, :options ], message, options
|
81
|
+
|
82
|
+
super message, **options
|
83
|
+
|
84
|
+
@options = {}.merge! options
|
85
|
+
end
|
86
|
+
end # class ControlException
|
87
|
+
|
88
|
+
# Exception thrown if an operation fails while building/testing/deploying a
|
89
|
+
# gem.
|
90
|
+
class GemDeploymentException < ControlException
|
91
|
+
|
92
|
+
# @see ControlException
|
93
|
+
def initialize message, **options
|
94
|
+
|
95
|
+
trace ParamNames[ :message, :options ], message, options
|
96
|
+
|
97
|
+
super message, **options
|
98
|
+
end
|
99
|
+
end # class GemDeploymentException
|
100
|
+
|
101
|
+
# Exception thrown if a Razor Control opteration fails.
|
102
|
+
class RazorControlException < ControlException
|
103
|
+
|
104
|
+
# @see ControlException
|
105
|
+
def initialize message, **options
|
106
|
+
|
107
|
+
trace ParamNames[ :message, :options ], message, options
|
108
|
+
|
109
|
+
super message, **options
|
110
|
+
end
|
111
|
+
end # class RazorControlException
|
112
|
+
|
113
|
+
end # module Exceptions
|
114
|
+
|
115
|
+
end # module Control
|
116
|
+
end # module Razor
|
117
|
+
end # module RazorRisk
|
118
|
+
|
119
|
+
# ############################## end of file ############################# #
|
120
|
+
|
121
|
+
|