teuton 2.1.9 → 2.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -12
- data/bin/check_teuton +0 -2
- data/docs/changelog/ideas.md +132 -0
- data/docs/changelog/v2.1.md +14 -122
- data/docs/changelog/v2.2.md +52 -28
- data/docs/changelog/version2.1.md +4 -0
- data/docs/commands/README.md +58 -15
- data/docs/commands/example_check.md +0 -4
- data/docs/commands/example_run.md +0 -4
- data/docs/dsl/README.md +1 -1
- data/docs/dsl/definition/result.md +1 -0
- data/docs/dsl/definition/run_remote.md +12 -6
- data/docs/dsl/definition/target.md +9 -10
- data/docs/dsl/execution/export.md +27 -20
- data/docs/install/README.md +13 -18
- data/docs/install/vagrant_docker.md +1 -1
- data/docs/learn/README.md +8 -8
- data/docs/learn/example-01-target.md +25 -25
- data/docs/learn/example-02-config.md +38 -49
- data/docs/learn/example-03-remote-hosts.md +22 -22
- data/docs/learn/{example-11-first-test.md → example-04-new-test.md} +23 -24
- data/docs/learn/{example-04-use.md → example-05-use.md} +6 -6
- data/docs/learn/{example-05-debug.md → example-06-debug.md} +8 -8
- data/docs/learn/{example-06-log.md → example-07-log.md} +7 -7
- data/docs/learn/example-08-readme.md +59 -0
- data/docs/learn/example-09-preserve.md +41 -0
- data/docs/videos.md +19 -0
- data/lib/teuton/application.rb +22 -3
- data/lib/teuton/case_manager/case/builtin/main.rb +3 -19
- data/lib/teuton/case_manager/case/builtin/package.rb +7 -6
- data/lib/teuton/case_manager/case/builtin/service.rb +9 -8
- data/lib/teuton/case_manager/case/builtin/teuton_file.rb +28 -0
- data/lib/teuton/case_manager/case/builtin/teuton_host.rb +31 -0
- data/lib/teuton/case_manager/case/builtin/user.rb +8 -7
- data/lib/teuton/case_manager/case/case.rb +1 -1
- data/lib/teuton/case_manager/case/dsl/goto.rb +2 -2
- data/lib/teuton/case_manager/case/dsl/log.rb +1 -1
- data/lib/teuton/case_manager/case/dsl/macro.rb +4 -1
- data/lib/teuton/case_manager/case/dsl/send.rb +2 -1
- data/lib/teuton/case_manager/case/play.rb +2 -0
- data/lib/teuton/case_manager/case/result/ext_compare.rb +16 -0
- data/lib/teuton/case_manager/case/result/result.rb +1 -1
- data/lib/teuton/case_manager/case/runner.rb +30 -4
- data/lib/teuton/case_manager/case_manager.rb +1 -1
- data/lib/teuton/case_manager/dsl.rb +10 -0
- data/lib/teuton/case_manager/export_manager.rb +24 -5
- data/lib/teuton/case_manager/utils.rb +1 -1
- data/lib/teuton/{project/laboratory → check}/builtin.rb +0 -0
- data/lib/teuton/{project/laboratory → check}/dsl.rb +40 -28
- data/lib/teuton/{project/laboratory → check}/laboratory.rb +3 -8
- data/lib/teuton/{project/laboratory → check}/show.rb +53 -59
- data/lib/teuton/cli.rb +85 -14
- data/lib/teuton/{project/readme → readme}/dsl.rb +0 -0
- data/lib/teuton/{project/readme → readme}/lang.rb +1 -1
- data/lib/teuton/{project/readme → readme}/readme.rb +22 -18
- data/lib/teuton/report/formatter/array_formatter.rb +13 -1
- data/lib/teuton/report/formatter/base_formatter.rb +18 -5
- data/lib/teuton/{project/skeleton.rb → skeleton.rb} +8 -20
- data/lib/teuton/utils/configfile_reader.rb +121 -0
- data/lib/teuton/{project → utils}/name_file_finder.rb +46 -26
- data/lib/teuton/version.rb +8 -0
- data/lib/teuton.rb +39 -32
- metadata +109 -61
- data/lib/teuton/case_manager/case/dsl/deprecated.rb +0 -14
- data/lib/teuton/cli/check.rb +0 -38
- data/lib/teuton/cli/main.rb +0 -6
- data/lib/teuton/cli/play.rb +0 -38
- data/lib/teuton/cli/readme.rb +0 -26
- data/lib/teuton/cli/version.rb +0 -12
- data/lib/teuton/project/configfile_reader.rb +0 -49
- data/lib/teuton/project/project.rb +0 -80
@@ -9,9 +9,12 @@ module ExportManager
|
|
9
9
|
# Run export function
|
10
10
|
# @param main_report (Report)
|
11
11
|
# @param cases (Array)
|
12
|
-
# @param
|
13
|
-
# rubocop:
|
14
|
-
|
12
|
+
# @param input (Hash) Selected export options
|
13
|
+
# rubocop:disable Metrics/AbcSize
|
14
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
15
|
+
def self.run(main_report, cases, input)
|
16
|
+
args = strings2symbols(input)
|
17
|
+
|
15
18
|
# default :mode=>:all, :format=>:txt
|
16
19
|
format = args[:format] || Application.instance.default[:format]
|
17
20
|
mode = args[:mode] || :all
|
@@ -27,12 +30,29 @@ module ExportManager
|
|
27
30
|
preserve_files if args[:preserve] == true
|
28
31
|
end
|
29
32
|
# rubocop:enable Metrics/AbcSize
|
33
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
34
|
+
|
35
|
+
##
|
36
|
+
# Convert Hash String values into Symbol values
|
37
|
+
# @param input (Hash)
|
38
|
+
# rubocop:disable Style/ConditionalAssignment
|
39
|
+
private_class_method def self.strings2symbols(input)
|
40
|
+
args = {}
|
41
|
+
input.each_pair do |key, value|
|
42
|
+
if value.class == String
|
43
|
+
args[key] = value.to_sym
|
44
|
+
else
|
45
|
+
args[key] = value
|
46
|
+
end
|
47
|
+
end
|
48
|
+
args
|
49
|
+
end
|
50
|
+
# rubocop:enable Style/ConditionalAssignment
|
30
51
|
|
31
52
|
##
|
32
53
|
# Preserve output files for current project
|
33
54
|
# rubocop:disable Metrics/AbcSize
|
34
55
|
# rubocop:disable Metrics/MethodLength
|
35
|
-
# rubocop:disable Layout/LineLength
|
36
56
|
private_class_method def self.preserve_files
|
37
57
|
app = Application.instance
|
38
58
|
t = Time.now
|
@@ -48,5 +68,4 @@ module ExportManager
|
|
48
68
|
end
|
49
69
|
# rubocop:enable Metrics/AbcSize
|
50
70
|
# rubocop:enable Metrics/MethodLength
|
51
|
-
# rubocop:enable Layout/LineLength
|
52
71
|
end
|
@@ -26,7 +26,7 @@ module Utils
|
|
26
26
|
text = ec.convert(text)
|
27
27
|
rescue StandardError => e
|
28
28
|
puts "[ERROR] #{e}: Declare text encoding..."
|
29
|
-
puts "
|
29
|
+
puts " run 'command', on: :host, :encoding => 'ISO-8859-1'"
|
30
30
|
end
|
31
31
|
|
32
32
|
text.split("\n")
|
File without changes
|
@@ -1,36 +1,27 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
4
|
-
#
|
5
|
-
# * goto
|
6
|
-
# * run
|
7
|
-
# * expect
|
8
|
-
# * get
|
9
|
-
# * unique
|
10
|
-
# * log
|
11
|
-
# * set
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
##
|
4
|
+
# Include Teuton DSL keywords into Laboratory class
|
12
5
|
class Laboratory
|
6
|
+
##
|
7
|
+
# Execute Teuton DSL readme keyword
|
13
8
|
def readme(_text)
|
14
9
|
# Usefull for "teuton readme" command action.
|
15
10
|
end
|
16
11
|
|
12
|
+
##
|
13
|
+
# Execute Teuton DSL target keyword
|
17
14
|
def target(desc, args = {})
|
18
15
|
@stats[:targets] += 1
|
19
16
|
@targetid += 1
|
20
17
|
weight = args[:weight] || 1.0
|
21
|
-
verboseln '(%
|
18
|
+
verboseln format('(%03<targetid>d) target %<desc>s', targetid: @targetid, desc: desc)
|
22
19
|
verboseln " weight #{weight}"
|
23
20
|
end
|
24
21
|
alias goal target
|
25
22
|
|
26
|
-
|
27
|
-
#
|
28
|
-
# end
|
29
|
-
|
30
|
-
def tempfile(_tempfile = nil)
|
31
|
-
'tempfile'
|
32
|
-
end
|
33
|
-
|
23
|
+
##
|
24
|
+
# Execute Teuton DSL run keyword
|
34
25
|
def run(command, args = {})
|
35
26
|
args[:exec] = command
|
36
27
|
host = :localhost
|
@@ -38,6 +29,8 @@ class Laboratory
|
|
38
29
|
goto(host, args)
|
39
30
|
end
|
40
31
|
|
32
|
+
##
|
33
|
+
# Execute Teuton DSL goto keyword
|
41
34
|
def goto(host = :localhost, args = {})
|
42
35
|
result.reset
|
43
36
|
args[:on] = host unless args[:on]
|
@@ -50,24 +43,32 @@ class Laboratory
|
|
50
43
|
verboseln " run '#{args[:exec]}' on #{args[:on]}"
|
51
44
|
end
|
52
45
|
|
53
|
-
|
46
|
+
##
|
47
|
+
# Execute Teuton DSL expect keyword
|
48
|
+
def expect(cond)
|
54
49
|
verboseln " alter #{result.alterations}" unless result.alterations.empty?
|
55
|
-
verboseln " expect #{
|
50
|
+
verboseln " expect #{cond} (#{cond.class})"
|
56
51
|
verboseln ''
|
57
52
|
end
|
58
53
|
|
59
|
-
|
54
|
+
##
|
55
|
+
# Execute Teuton DSL expect_one keyword
|
56
|
+
def expect_one(cond)
|
60
57
|
verboseln " alter #{result.alterations}" unless result.alterations.empty?
|
61
|
-
verboseln " expect_one #{
|
58
|
+
verboseln " expect_one #{cond} (#{cond.class})"
|
62
59
|
verboseln ''
|
63
60
|
end
|
64
61
|
|
65
|
-
|
62
|
+
##
|
63
|
+
# Execute Teuton DSL expect_none keyword
|
64
|
+
def expect_none(cond)
|
66
65
|
verboseln " alter #{result.alterations}" unless result.alterations.empty?
|
67
|
-
verboseln " expect_none #{
|
66
|
+
verboseln " expect_none #{cond} (#{cond.class})"
|
68
67
|
verboseln ''
|
69
68
|
end
|
70
69
|
|
70
|
+
##
|
71
|
+
# Execute Teuton DSL get keyword
|
71
72
|
def get(varname)
|
72
73
|
@stats[:gets] += 1
|
73
74
|
|
@@ -80,17 +81,24 @@ class Laboratory
|
|
80
81
|
"get(#{varname})"
|
81
82
|
end
|
82
83
|
|
83
|
-
# If a method call is missing, then
|
84
|
+
# If a method call is missing, then try to call get(var)
|
85
|
+
# rubocop:disable Style/MissingRespondToMissing
|
84
86
|
def method_missing(method)
|
85
87
|
a = method.to_s
|
86
|
-
instance_eval("get(:#{a[0, a.size - 1]})") if a[a.size - 1] == '?'
|
88
|
+
instance_eval("get(:#{a[0, a.size - 1]})", __FILE__, __LINE__) if a[a.size - 1] == '?'
|
87
89
|
end
|
90
|
+
# rubocop:enable Style/MissingRespondToMissing
|
88
91
|
|
92
|
+
##
|
93
|
+
# Execute Teuton DSL gett keyword
|
94
|
+
# Same as get keyword, but show pretty output when used by readme command.
|
89
95
|
def gett(option)
|
90
96
|
value = get(option)
|
91
97
|
value
|
92
98
|
end
|
93
99
|
|
100
|
+
##
|
101
|
+
# Execute Teuton DSL unique keyword
|
94
102
|
def unique(key, _value)
|
95
103
|
@stats[:uniques] += 1
|
96
104
|
|
@@ -98,11 +106,15 @@ class Laboratory
|
|
98
106
|
verboseln ''
|
99
107
|
end
|
100
108
|
|
109
|
+
##
|
110
|
+
# Execute Teuton DSL log keyword
|
101
111
|
def log(text = '', type = :info)
|
102
112
|
@stats[:logs] += 1
|
103
113
|
verboseln " log [#{type}]: " + text.to_s
|
104
114
|
end
|
105
115
|
|
116
|
+
##
|
117
|
+
# Execute Teuton DSL set keyword
|
106
118
|
def set(key, value)
|
107
119
|
@stats[:sets] += 1
|
108
120
|
|
@@ -1,10 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
require_relative '../../application'
|
7
|
-
require_relative '../../case_manager/case/result/result'
|
3
|
+
require_relative '../application'
|
4
|
+
require_relative '../case_manager/case/result/result'
|
8
5
|
require_relative 'show'
|
9
6
|
require_relative 'dsl'
|
10
7
|
require_relative 'builtin'
|
@@ -35,7 +32,7 @@ alias task group
|
|
35
32
|
# DSL start: Define main teuton test execution
|
36
33
|
# @param block (Proc)
|
37
34
|
def start(&block)
|
38
|
-
#
|
35
|
+
# Don't do nothing. We are checking test not running it
|
39
36
|
end
|
40
37
|
alias play start
|
41
38
|
|
@@ -54,8 +51,6 @@ class Laboratory
|
|
54
51
|
reset
|
55
52
|
end
|
56
53
|
|
57
|
-
##
|
58
|
-
# Set attibutes to default values
|
59
54
|
def reset
|
60
55
|
@result = Result.new
|
61
56
|
@targetid = 0
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'terminal-table'
|
2
2
|
require 'rainbow'
|
3
3
|
|
4
|
-
require_relative '
|
5
|
-
require_relative '../configfile_reader'
|
4
|
+
require_relative '../application'
|
5
|
+
require_relative '../utils/configfile_reader'
|
6
6
|
|
7
7
|
# Laboratory
|
8
8
|
# * show_dsl
|
@@ -10,68 +10,23 @@ require_relative '../configfile_reader'
|
|
10
10
|
# * show_config
|
11
11
|
class Laboratory
|
12
12
|
##
|
13
|
-
# Display DSL on screen
|
14
|
-
def
|
13
|
+
# Display DSL checking on screen
|
14
|
+
def show
|
15
15
|
@verbose = true
|
16
16
|
process_content
|
17
17
|
show_stats
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
##
|
22
|
-
# Display stats on screen
|
23
|
-
def show_stats
|
24
|
-
@stats[:hosts] = 0
|
25
|
-
@hosts.each_pair { |_k, v| @stats[:hosts] += v }
|
26
|
-
|
27
|
-
my_screen_table = Terminal::Table.new do |st|
|
28
|
-
st.add_row ['DSL Stats', 'Count']
|
29
|
-
st.add_separator
|
30
|
-
st.add_row ['Groups', @stats[:groups]]
|
31
|
-
st.add_row ['Targets', @stats[:targets]]
|
32
|
-
st.add_row ['Goto', @stats[:hosts]]
|
33
|
-
@hosts.each_pair { |k, v| st.add_row [" * #{k}", v] }
|
34
|
-
st.add_row ['Uniques', @stats[:uniques]]
|
35
|
-
st.add_row ['Logs', @stats[:uniques]]
|
36
|
-
st.add_row [' ', ' ']
|
37
|
-
|
38
|
-
st.add_row ['Gets', @stats[:gets]]
|
39
|
-
if @gets.count > 0
|
40
|
-
list = @gets.sort_by { |_k, v| v }
|
41
|
-
list.reverse_each { |item| st.add_row [" * #{item[0]}", item[1].to_s] }
|
42
|
-
end
|
43
|
-
|
44
|
-
st.add_row ['Sets', @stats[:sets]]
|
45
|
-
if @sets.count > 0
|
46
|
-
@sets.each_pair { |k, v| st.add_row [" * #{k}", v.to_s] }
|
47
|
-
end
|
48
|
-
end
|
49
|
-
verboseln my_screen_table.to_s + "\n"
|
18
|
+
revise_config_content
|
50
19
|
end
|
51
20
|
|
52
21
|
##
|
53
|
-
# Display config on screen
|
54
|
-
def
|
22
|
+
# Display config for teuton panel on screen
|
23
|
+
def show_panelconfig
|
55
24
|
@verbose = false
|
56
25
|
process_content
|
57
26
|
@verbose = true
|
58
|
-
|
27
|
+
recomended_panelconfig_content
|
59
28
|
end
|
60
29
|
|
61
|
-
# def show_requests
|
62
|
-
# @verbose = false
|
63
|
-
# process_content
|
64
|
-
# @verbose = true
|
65
|
-
# my_screen_table = Terminal::Table.new do |st|
|
66
|
-
# st.add_row ['Lines', 'REQUEST description']
|
67
|
-
# st.add_separator
|
68
|
-
# @requests.each_with_index do |line, index|
|
69
|
-
# st.add_row ['%03d' % index, line]
|
70
|
-
# end
|
71
|
-
# end
|
72
|
-
# verboseln my_screen_table
|
73
|
-
# end
|
74
|
-
|
75
30
|
private
|
76
31
|
|
77
32
|
def verbose(text)
|
@@ -84,14 +39,16 @@ class Laboratory
|
|
84
39
|
|
85
40
|
def process_content
|
86
41
|
groups = Application.instance.groups
|
42
|
+
option = Application.instance.options
|
43
|
+
|
87
44
|
verboseln ''
|
88
45
|
groups.each do |t|
|
89
46
|
@stats[:groups] += 1
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
47
|
+
unless option[:panel]
|
48
|
+
msg = "GROUP: #{t[:name]}"
|
49
|
+
my_screen_table = Terminal::Table.new { |st| st.add_row [msg] }
|
50
|
+
verboseln my_screen_table
|
51
|
+
end
|
95
52
|
instance_eval(&t[:block])
|
96
53
|
end
|
97
54
|
end
|
@@ -127,10 +84,16 @@ class Laboratory
|
|
127
84
|
verboseln YAML.dump(output)
|
128
85
|
end
|
129
86
|
|
87
|
+
def recomended_panelconfig_content
|
88
|
+
output = { global: {}, cases: nil }
|
89
|
+
script_vars = find_script_vars
|
90
|
+
script_vars.each { |i| output[:global][i] = 'VALUE' }
|
91
|
+
verboseln YAML.dump(output)
|
92
|
+
end
|
93
|
+
|
130
94
|
##
|
131
95
|
# Revive and check config content
|
132
96
|
def revise_config_content
|
133
|
-
@verbose = true
|
134
97
|
my_screen_table = Terminal::Table.new do |st|
|
135
98
|
st.add_row ['Revising CONFIG file']
|
136
99
|
end
|
@@ -166,4 +129,35 @@ class Laboratory
|
|
166
129
|
end
|
167
130
|
end
|
168
131
|
end
|
132
|
+
|
133
|
+
##
|
134
|
+
# Display stats on screen
|
135
|
+
def show_stats
|
136
|
+
@stats[:hosts] = 0
|
137
|
+
@hosts.each_pair { |_k, v| @stats[:hosts] += v }
|
138
|
+
|
139
|
+
my_screen_table = Terminal::Table.new do |st|
|
140
|
+
st.add_row ['DSL Stats', 'Count']
|
141
|
+
st.add_separator
|
142
|
+
st.add_row ['Groups', @stats[:groups]]
|
143
|
+
st.add_row ['Targets', @stats[:targets]]
|
144
|
+
st.add_row ['Goto', @stats[:hosts]]
|
145
|
+
@hosts.each_pair { |k, v| st.add_row [" * #{k}", v] }
|
146
|
+
st.add_row ['Uniques', @stats[:uniques]]
|
147
|
+
st.add_row ['Logs', @stats[:uniques]]
|
148
|
+
st.add_row [' ', ' ']
|
149
|
+
|
150
|
+
st.add_row ['Gets', @stats[:gets]]
|
151
|
+
if @gets.count > 0
|
152
|
+
list = @gets.sort_by { |_k, v| v }
|
153
|
+
list.reverse_each { |item| st.add_row [" * #{item[0]}", item[1].to_s] }
|
154
|
+
end
|
155
|
+
|
156
|
+
st.add_row ['Sets', @stats[:sets]]
|
157
|
+
if @sets.count > 0
|
158
|
+
@sets.each_pair { |k, v| st.add_row [" * #{k}", v.to_s] }
|
159
|
+
end
|
160
|
+
end
|
161
|
+
verboseln my_screen_table.to_s + "\n"
|
162
|
+
end
|
169
163
|
end
|
data/lib/teuton/cli.rb
CHANGED
@@ -1,39 +1,110 @@
|
|
1
|
+
|
1
2
|
require 'thor'
|
2
|
-
require_relative '
|
3
|
-
require_relative '
|
4
|
-
require_relative 'project/skeleton.rb'
|
5
|
-
require_relative 'cli/main'
|
3
|
+
require_relative 'version'
|
4
|
+
require_relative '../teuton'
|
6
5
|
|
7
|
-
##
|
8
|
-
# Command Line User Interface
|
9
6
|
class CLI < Thor
|
10
7
|
map ['h', '-h', '--help'] => 'help'
|
11
8
|
|
12
|
-
map ['
|
9
|
+
map ['v', '-v', '--version'] => 'version'
|
10
|
+
desc 'version', 'Show the program version'
|
11
|
+
def version
|
12
|
+
puts "#{Teuton::APPNAME} (version #{Teuton::VERSION})"
|
13
|
+
end
|
14
|
+
|
15
|
+
map ['n', '-n', '--new'] => 'new'
|
13
16
|
desc 'new DIRECTORY', 'Create skeleton for a new project'
|
14
17
|
long_desc <<-LONGDESC
|
15
18
|
Create files for a new project.
|
19
|
+
LONGDESC
|
20
|
+
def new(projectpath)
|
21
|
+
Teuton.create(projectpath)
|
22
|
+
end
|
23
|
+
|
24
|
+
map ['c', '-c', '--check'] => 'check'
|
25
|
+
option :panelconfig, type: :boolean
|
26
|
+
option :cname, type: :string
|
27
|
+
option :cpath, type: :string
|
28
|
+
desc 'check [OPTIONS] DIRECTORY',
|
29
|
+
'Check test and config file content'
|
30
|
+
long_desc <<-LONGDESC
|
31
|
+
|
32
|
+
(1) teuton check path/to/dir/foo
|
33
|
+
, Check content of start.rb and config.yaml files.
|
16
34
|
|
17
|
-
|
35
|
+
(2) teuton check path/to/dir/foo --cname=demo
|
36
|
+
, Check content of start.rb and demo.yaml files.
|
37
|
+
|
38
|
+
(3) teuton check path/to/file/foo.rb
|
39
|
+
, Check content of foo.rb and foo.yaml files.
|
40
|
+
|
41
|
+
(4) teuton check path/to/file/foo.rb --cname=demo
|
42
|
+
, Check content of foo.rb and demo.yaml files.
|
18
43
|
|
19
|
-
#{$PROGRAM_NAME} create dir/foo
|
20
44
|
LONGDESC
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
45
|
+
def check(projectpath)
|
46
|
+
Teuton.check(projectpath, options)
|
47
|
+
end
|
48
|
+
|
49
|
+
map ['--run', 'run'] => 'play'
|
50
|
+
option :export, type: :string
|
51
|
+
option :cname, type: :string
|
52
|
+
option :cpath, type: :string
|
53
|
+
option :case, type: :string
|
54
|
+
option :color, type: :boolean
|
55
|
+
option :quiet, type: :boolean
|
56
|
+
desc '[run] [OPTIONS] DIRECTORY',
|
57
|
+
'Run test from directory'
|
58
|
+
long_desc <<-LONGDESC
|
59
|
+
This function execute challenge from specified directory.
|
60
|
+
By default, show progress on the screen.
|
61
|
+
|
62
|
+
Let's see others options:
|
63
|
+
|
64
|
+
(1) teuton foo, run challenge from foo/start.rb with foo/config.yaml config file.
|
65
|
+
|
66
|
+
(2) teuton run foo, same as (1).
|
67
|
+
|
68
|
+
(3) teuton run --export=json foo, run challenge and export using json format.
|
69
|
+
Others output formats availables are: txt, html, yaml, json and colored_text.
|
70
|
+
|
71
|
+
(4) teuton run --cname=demo foo, run challenge from foo/start.rb with foo/demo.yaml config file.
|
72
|
+
|
73
|
+
(5) teuton foo/demo.rb, Run challenge from foo/demo.rb with foo/demo.yaml config file.
|
74
|
+
|
75
|
+
LONGDESC
|
76
|
+
def play(filepath)
|
77
|
+
Teuton.run(filepath, options)
|
78
|
+
end
|
79
|
+
|
80
|
+
map ['--readme'] => 'readme'
|
81
|
+
option :lang, type: :string
|
82
|
+
desc 'readme DIRECTORY',
|
83
|
+
'Show README extracted from test contents'
|
84
|
+
long_desc <<-LONGDESC
|
85
|
+
|
86
|
+
(1) teuton readme foo
|
87
|
+
, Create README.md from foo/start.rb.
|
88
|
+
|
89
|
+
(2) teuton readme foo/demo.rb
|
90
|
+
, Create README.md from foo/demo.rb.
|
91
|
+
LONGDESC
|
92
|
+
|
93
|
+
def readme(projectpath)
|
94
|
+
# Create README from teuton test
|
95
|
+
Teuton.readme(projectpath, options)
|
25
96
|
end
|
26
97
|
|
27
98
|
##
|
28
99
|
# These inputs are equivalents:
|
29
100
|
# * teuton dir/foo
|
30
101
|
# * teuton run dir/foo
|
31
|
-
# * teuton play dir/foo
|
32
102
|
def method_missing(method, *_args, &_block)
|
33
103
|
play(method.to_s)
|
34
104
|
end
|
35
105
|
|
36
106
|
def respond_to_missing?(method_name, include_private = false)
|
107
|
+
# Respond to missing methods name
|
37
108
|
super
|
38
109
|
end
|
39
110
|
end
|
File without changes
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '
|
4
|
-
require_relative '../configfile_reader'
|
5
|
-
require_relative '
|
3
|
+
require_relative '../application'
|
4
|
+
require_relative '../utils/configfile_reader'
|
5
|
+
require_relative '../case_manager/case/result/result'
|
6
6
|
require_relative 'dsl'
|
7
7
|
require_relative 'lang'
|
8
8
|
|
@@ -44,6 +44,19 @@ class Readme
|
|
44
44
|
reset
|
45
45
|
end
|
46
46
|
|
47
|
+
##
|
48
|
+
# Show README on screen
|
49
|
+
def show
|
50
|
+
process_content
|
51
|
+
show_head
|
52
|
+
show_content
|
53
|
+
show_tail
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
##
|
59
|
+
# Reset attributes
|
47
60
|
def reset
|
48
61
|
app = Application.instance
|
49
62
|
@config = ConfigFileReader.read(app.config_path)
|
@@ -73,13 +86,6 @@ class Readme
|
|
73
86
|
@action = { readme: [] }
|
74
87
|
end
|
75
88
|
|
76
|
-
def show
|
77
|
-
process_content
|
78
|
-
show_head
|
79
|
-
show_content
|
80
|
-
show_tail
|
81
|
-
end
|
82
|
-
|
83
89
|
##
|
84
90
|
# Show README head
|
85
91
|
def show_head
|
@@ -97,23 +103,21 @@ class Readme
|
|
97
103
|
puts Lang::get(:hosts)
|
98
104
|
puts "\n"
|
99
105
|
puts '| ID | Host | Configuration |'
|
100
|
-
puts '|
|
106
|
+
puts '| --- | --- | --- |'
|
101
107
|
@required_hosts.each_pair do |k, v|
|
102
108
|
c = []
|
103
109
|
v.each_pair { |k2,v2| c << "#{k2}=#{v2}" }
|
104
|
-
puts "
|
110
|
+
puts "| #{i} | #{k.upcase} | #{c.join(', ')} |"
|
105
111
|
i += 1
|
106
112
|
end
|
107
113
|
puts "\n> NOTE: SSH Service installation is required on every host."
|
108
114
|
end
|
109
115
|
|
110
116
|
unless @cases_params.empty?
|
111
|
-
@cases_params.
|
117
|
+
@cases_params.sort!
|
112
118
|
puts Lang::get(:params)
|
113
119
|
@cases_params.uniq.each { |i| puts format('* %s', i) }
|
114
|
-
puts "\n> NOTE:"
|
115
|
-
puts "> * Teuton software must known this information!"
|
116
|
-
puts "> * Save every ':param: value' into config file."
|
120
|
+
puts "\n> NOTE: Save every ':param: value' into config file."
|
117
121
|
end
|
118
122
|
end
|
119
123
|
|
@@ -156,13 +160,13 @@ class Readme
|
|
156
160
|
puts Lang::get(:global)
|
157
161
|
puts "\n"
|
158
162
|
puts '| Global param | Value |'
|
159
|
-
puts '|
|
163
|
+
puts '| --- | --- |'
|
160
164
|
@global_params.each_pair { |k,v| puts "|#{k}|#{v}|" }
|
161
165
|
puts "\n\#\# Created params"
|
162
166
|
puts Lang::get(:created)
|
163
167
|
puts "\n"
|
164
168
|
puts '| Created params | Value |'
|
165
|
-
puts '|
|
169
|
+
puts '| --- | --- |'
|
166
170
|
@setted_params.each_pair { |k,v| puts "|#{k}|#{v}|" }
|
167
171
|
end
|
168
172
|
end
|
@@ -2,13 +2,19 @@
|
|
2
2
|
|
3
3
|
require_relative 'base_formatter'
|
4
4
|
|
5
|
+
##
|
5
6
|
# ArrayFormatter class: format report data into an array
|
6
7
|
class ArrayFormatter < BaseFormatter
|
8
|
+
##
|
9
|
+
# Initialize class
|
10
|
+
# @param report (Report) Format report data into Array
|
7
11
|
def initialize(report)
|
8
12
|
super(report)
|
9
13
|
@data = {}
|
10
14
|
end
|
11
15
|
|
16
|
+
##
|
17
|
+
# Execute format action
|
12
18
|
def process
|
13
19
|
build_data
|
14
20
|
w @data.to_s # Write data into ouput file
|
@@ -28,6 +34,8 @@ class ArrayFormatter < BaseFormatter
|
|
28
34
|
@data[:config] = head
|
29
35
|
end
|
30
36
|
|
37
|
+
# rubocop:disable Metrics/AbcSize
|
38
|
+
# rubocop:disable Metrics/MethodLength
|
31
39
|
def build_history_data
|
32
40
|
@data[:logs] = []
|
33
41
|
groups = []
|
@@ -46,7 +54,8 @@ class ArrayFormatter < BaseFormatter
|
|
46
54
|
end
|
47
55
|
|
48
56
|
target = {}
|
49
|
-
target[:target_id] = format('%02d', i[:id])
|
57
|
+
# target[:target_id] = format('%02d', i[:id])
|
58
|
+
target[:target_id] = format('%<id>02d', id: i[:id])
|
50
59
|
target[:check] = i[:check]
|
51
60
|
target[:score] = value
|
52
61
|
target[:weight] = i[:weight]
|
@@ -66,6 +75,8 @@ class ArrayFormatter < BaseFormatter
|
|
66
75
|
groups << { title: title, targets: targets } unless title.nil?
|
67
76
|
@data[:groups] = groups
|
68
77
|
end
|
78
|
+
# rubocop:enable Metrics/AbcSize
|
79
|
+
# rubocop:enable Metrics/MethodLength
|
69
80
|
|
70
81
|
def build_final_data
|
71
82
|
tail = {}
|
@@ -77,6 +88,7 @@ class ArrayFormatter < BaseFormatter
|
|
77
88
|
app = Application.instance
|
78
89
|
@data[:hall_of_fame] = {}
|
79
90
|
return if app.options[:case_number] < 3
|
91
|
+
|
80
92
|
fame = {}
|
81
93
|
app.hall_of_fame.each { |line| fame[line[0]] = line[1] }
|
82
94
|
@data[:hall_of_fame] = fame
|