teuton 2.3.5 → 2.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -5
- data/bin/teuton +1 -1
- data/docs/CHANGELOG.md +8 -0
- data/docs/changelog/v2.4.md +16 -0
- data/docs/dsl/definition/expect.md +11 -7
- data/docs/dsl/definition/result.md +7 -6
- data/docs/dsl/definition/run_local.md +0 -1
- data/docs/dsl/definition/target.md +1 -1
- data/docs/dsl/execution/export.md +14 -16
- data/docs/dsl/execution/send.md +12 -12
- data/docs/dsl/setting/get.md +5 -5
- data/docs/es/exit_code.md +59 -0
- data/docs/es/guess_os.md +28 -0
- data/docs/{Challenge-Server-Project.md → ideas/Challenge-Server-Project.md} +0 -0
- data/docs/{changelog → ideas}/contributions.md +0 -0
- data/docs/{changelog → ideas}/ideas.md +0 -0
- data/docs/{changelog → ideas}/servidor-de-retos.md +0 -0
- data/docs/learn/{example-01-target.md → 01-target.md} +1 -3
- data/docs/learn/{example-02-config.md → 02-config.md} +1 -3
- data/docs/learn/{example-03-remote-hosts.md → 03-remote_hosts.md} +10 -10
- data/docs/learn/{example-04-new-test.md → 04-new_test.md} +8 -16
- data/docs/learn/{example-05-use.md → 05-use.md} +1 -3
- data/docs/learn/{example-06-debug.md → 06-debug.md} +1 -3
- data/docs/learn/{example-07-log.md → 07-log.md} +1 -3
- data/docs/learn/{example-08-readme.md → 08-readme.md} +1 -3
- data/docs/learn/{example-09-preserve.md → 09-preserve.md} +7 -4
- data/docs/learn/10-result.md +36 -0
- data/docs/learn/11-moodle_id.md +19 -0
- data/docs/learn/12-get_vars.md +37 -0
- data/docs/learn/13-include.md +59 -0
- data/docs/learn/16-exit_codes.md +24 -0
- data/docs/learn/README.md +19 -17
- data/lib/teuton/application.rb +24 -17
- data/lib/teuton/case_manager/case/builtin/main.rb +2 -3
- data/lib/teuton/case_manager/case/builtin/package.rb +2 -3
- data/lib/teuton/case_manager/case/builtin/service.rb +4 -5
- data/lib/teuton/case_manager/case/builtin/teuton_file.rb +3 -4
- data/lib/teuton/case_manager/case/builtin/teuton_host.rb +5 -6
- data/lib/teuton/case_manager/case/builtin/user.rb +1 -2
- data/lib/teuton/case_manager/case/case.rb +27 -27
- data/lib/teuton/case_manager/case/close.rb +2 -2
- data/lib/teuton/case_manager/case/config.rb +14 -14
- data/lib/teuton/case_manager/case/dsl/expect.rb +46 -39
- data/lib/teuton/case_manager/case/dsl/goto.rb +2 -2
- data/lib/teuton/case_manager/case/dsl/log.rb +5 -6
- data/lib/teuton/case_manager/case/dsl/macro.rb +11 -7
- data/lib/teuton/case_manager/case/dsl/main.rb +8 -8
- data/lib/teuton/case_manager/case/dsl/send.rb +12 -14
- data/lib/teuton/case_manager/case/dsl/unique.rb +1 -3
- data/lib/teuton/case_manager/case/main.rb +5 -5
- data/lib/teuton/case_manager/case/play.rb +1 -1
- data/lib/teuton/case_manager/case/result/ext_array.rb +9 -9
- data/lib/teuton/case_manager/case/result/ext_compare.rb +44 -58
- data/lib/teuton/case_manager/case/result/ext_filter.rb +20 -8
- data/lib/teuton/case_manager/case/result/result.rb +19 -18
- data/lib/teuton/case_manager/case/runner.rb +53 -60
- data/lib/teuton/case_manager/case_manager.rb +15 -15
- data/lib/teuton/case_manager/check_cases.rb +1 -4
- data/lib/teuton/case_manager/dsl.rb +5 -5
- data/lib/teuton/case_manager/export_manager.rb +8 -19
- data/lib/teuton/case_manager/hall_of_fame.rb +4 -6
- data/lib/teuton/case_manager/main.rb +4 -5
- data/lib/teuton/case_manager/report.rb +21 -16
- data/lib/teuton/case_manager/show.rb +2 -2
- data/lib/teuton/case_manager/utils.rb +13 -14
- data/lib/teuton/check/builtin.rb +5 -1
- data/lib/teuton/check/dsl.rb +10 -11
- data/lib/teuton/check/laboratory.rb +13 -15
- data/lib/teuton/check/show.rb +33 -35
- data/lib/teuton/cli.rb +31 -35
- data/lib/teuton/files/start.rb +3 -6
- data/lib/teuton/readme/dsl.rb +12 -6
- data/lib/teuton/readme/lang.rb +20 -21
- data/lib/teuton/readme/readme.rb +40 -42
- data/lib/teuton/report/close.rb +1 -8
- data/lib/teuton/report/formatter/array_formatter.rb +28 -39
- data/lib/teuton/report/formatter/base_formatter.rb +2 -13
- data/lib/teuton/report/formatter/csv_formatter.rb +12 -18
- data/lib/teuton/report/formatter/formatter_factory.rb +31 -29
- data/lib/teuton/report/formatter/html_formatter.rb +37 -21
- data/lib/teuton/report/formatter/json_formatter.rb +2 -8
- data/lib/teuton/report/formatter/list_formatter.rb +6 -12
- data/lib/teuton/report/formatter/moodle_csv_formatter.rb +3 -6
- data/lib/teuton/report/formatter/resume_array_formatter.rb +1 -1
- data/lib/teuton/report/formatter/resume_html_formatter.rb +29 -19
- data/lib/teuton/report/formatter/resume_json_formatter.rb +2 -3
- data/lib/teuton/report/formatter/resume_list_formatter.rb +4 -4
- data/lib/teuton/report/formatter/resume_txt_formatter.rb +14 -18
- data/lib/teuton/report/formatter/resume_yaml_formatter.rb +1 -9
- data/lib/teuton/report/formatter/txt_formatter.rb +19 -22
- data/lib/teuton/report/formatter/xml_formatter.rb +29 -37
- data/lib/teuton/report/formatter/yaml_formatter.rb +2 -12
- data/lib/teuton/report/report.rb +10 -10
- data/lib/teuton/report/show.rb +14 -33
- data/lib/teuton/skeleton.rb +6 -14
- data/lib/teuton/utils/configfile_reader.rb +22 -21
- data/lib/teuton/utils/name_file_finder.rb +21 -26
- data/lib/teuton/utils/verbose.rb +1 -2
- data/lib/teuton/version.rb +3 -4
- data/lib/teuton.rb +5 -6
- metadata +60 -86
- data/bin/check_teuton +0 -41
@@ -1,18 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
4
|
-
require_relative
|
5
|
-
require_relative
|
6
|
-
require_relative
|
7
|
-
require_relative
|
3
|
+
require_relative "../application"
|
4
|
+
require_relative "../case_manager/case/result/result"
|
5
|
+
require_relative "show"
|
6
|
+
require_relative "dsl"
|
7
|
+
require_relative "builtin"
|
8
8
|
|
9
9
|
##
|
10
10
|
# DSL use: import filename instructions
|
11
11
|
# @param filename (String)
|
12
12
|
def use(filename)
|
13
|
-
filename +=
|
13
|
+
filename += ".rb"
|
14
14
|
app = Application.instance
|
15
|
-
rbfiles = File.join(app.project_path,
|
15
|
+
rbfiles = File.join(app.project_path, "**", filename)
|
16
16
|
files = Dir.glob(rbfiles)
|
17
17
|
use = []
|
18
18
|
files.sort.each { |f| use << f if f.include?(filename) }
|
@@ -24,7 +24,7 @@ end
|
|
24
24
|
# @param name (String or Symbol)
|
25
25
|
# @param block (Proc)
|
26
26
|
def group(name, &block)
|
27
|
-
Application.instance.groups << {
|
27
|
+
Application.instance.groups << {name: name, block: block}
|
28
28
|
end
|
29
29
|
alias task group
|
30
30
|
|
@@ -40,21 +40,19 @@ alias play start
|
|
40
40
|
class Laboratory
|
41
41
|
attr_reader :result
|
42
42
|
|
43
|
-
##
|
44
|
-
# Initialize instance
|
45
43
|
def initialize(script_path, config_path)
|
46
44
|
@path = {}
|
47
|
-
@path[:script]
|
48
|
-
@path[:dirname]
|
49
|
-
@path[:filename] = File.basename(script_path,
|
50
|
-
@path[:config]
|
45
|
+
@path[:script] = script_path
|
46
|
+
@path[:dirname] = File.dirname(script_path)
|
47
|
+
@path[:filename] = File.basename(script_path, ".rb")
|
48
|
+
@path[:config] = config_path
|
51
49
|
reset
|
52
50
|
end
|
53
51
|
|
54
52
|
def reset
|
55
53
|
@result = Result.new
|
56
54
|
@targetid = 0
|
57
|
-
@stats = {
|
55
|
+
@stats = {groups: 0, targets: 0, uniques: 0, gets: 0, logs: 0, sets: 0}
|
58
56
|
@gets = {}
|
59
57
|
@sets = {}
|
60
58
|
@hosts = {}
|
data/lib/teuton/check/show.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "terminal-table"
|
2
|
+
require "rainbow"
|
3
3
|
|
4
|
-
require_relative
|
5
|
-
require_relative
|
4
|
+
require_relative "../application"
|
5
|
+
require_relative "../utils/configfile_reader"
|
6
6
|
|
7
7
|
# Laboratory
|
8
8
|
# * show_dsl
|
@@ -41,7 +41,7 @@ class Laboratory
|
|
41
41
|
groups = Application.instance.groups
|
42
42
|
option = Application.instance.options
|
43
43
|
|
44
|
-
verboseln
|
44
|
+
verboseln ""
|
45
45
|
groups.each do |t|
|
46
46
|
@stats[:groups] += 1
|
47
47
|
unless option[:panel]
|
@@ -58,14 +58,14 @@ class Laboratory
|
|
58
58
|
@hosts.each_key do |k|
|
59
59
|
next if k == :localhost
|
60
60
|
|
61
|
-
if k.
|
62
|
-
script_vars << (k.to_s +
|
63
|
-
script_vars << (k.to_s +
|
64
|
-
script_vars << (k.to_s +
|
61
|
+
if k.instance_of? Symbol
|
62
|
+
script_vars << (k.to_s + "_ip").to_sym
|
63
|
+
script_vars << (k.to_s + "_username").to_sym
|
64
|
+
script_vars << (k.to_s + "_password").to_sym
|
65
65
|
else
|
66
|
-
script_vars << k.to_s +
|
67
|
-
script_vars << k.to_s +
|
68
|
-
script_vars << k.to_s +
|
66
|
+
script_vars << k.to_s + "_ip"
|
67
|
+
script_vars << k.to_s + "_username"
|
68
|
+
script_vars << k.to_s + "_password"
|
69
69
|
end
|
70
70
|
end
|
71
71
|
@gets.each_key { |k| script_vars << k }
|
@@ -73,29 +73,27 @@ class Laboratory
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def recomended_config_content
|
76
|
-
verbose Rainbow(
|
76
|
+
verbose Rainbow("[WARN] File ").yellow
|
77
77
|
verbose Rainbow(@path[:config]).yellow.bright
|
78
|
-
verboseln Rainbow(
|
79
|
-
verboseln
|
80
|
-
output = {
|
78
|
+
verboseln Rainbow(" not found!").yellow
|
79
|
+
verboseln "[INFO] Recomended content:"
|
80
|
+
output = {global: nil, cases: []}
|
81
81
|
output[:cases][0] = {}
|
82
82
|
script_vars = find_script_vars
|
83
|
-
script_vars.each { |i| output[:cases][0][i] =
|
83
|
+
script_vars.each { |i| output[:cases][0][i] = "VALUE" }
|
84
84
|
verboseln YAML.dump(output)
|
85
85
|
end
|
86
86
|
|
87
87
|
def recomended_panelconfig_content
|
88
|
-
output = {
|
88
|
+
output = {global: {}, cases: nil}
|
89
89
|
script_vars = find_script_vars
|
90
|
-
script_vars.each { |i| output[:global][i] =
|
90
|
+
script_vars.each { |i| output[:global][i] = "VALUE" }
|
91
91
|
verboseln YAML.dump(output)
|
92
92
|
end
|
93
93
|
|
94
|
-
##
|
95
|
-
# Revive and check config content
|
96
94
|
def revise_config_content
|
97
95
|
my_screen_table = Terminal::Table.new do |st|
|
98
|
-
st.add_row [
|
96
|
+
st.add_row ["Revising CONFIG file"]
|
99
97
|
end
|
100
98
|
verboseln my_screen_table
|
101
99
|
|
@@ -119,13 +117,13 @@ class Laboratory
|
|
119
117
|
script_vars.each do |value|
|
120
118
|
next unless item[value].nil?
|
121
119
|
|
122
|
-
next unless @sets[
|
120
|
+
next unless @sets[":" + value.to_s].nil?
|
123
121
|
|
124
|
-
verbose Rainbow(
|
122
|
+
verbose Rainbow(" * Define ").red
|
125
123
|
verbose Rainbow(value).red.bright
|
126
|
-
verbose Rainbow(
|
124
|
+
verbose Rainbow(" value for Case[").red
|
127
125
|
verbose Rainbow(index).red.bright
|
128
|
-
verboseln Rainbow(
|
126
|
+
verboseln Rainbow("] or set tt_skip = true").red
|
129
127
|
end
|
130
128
|
end
|
131
129
|
end
|
@@ -137,23 +135,23 @@ class Laboratory
|
|
137
135
|
@hosts.each_pair { |_k, v| @stats[:hosts] += v }
|
138
136
|
|
139
137
|
my_screen_table = Terminal::Table.new do |st|
|
140
|
-
st.add_row [
|
138
|
+
st.add_row ["DSL Stats", "Count"]
|
141
139
|
st.add_separator
|
142
|
-
st.add_row [
|
143
|
-
st.add_row [
|
144
|
-
st.add_row [
|
140
|
+
st.add_row ["Groups", @stats[:groups]]
|
141
|
+
st.add_row ["Targets", @stats[:targets]]
|
142
|
+
st.add_row ["Goto", @stats[:hosts]]
|
145
143
|
@hosts.each_pair { |k, v| st.add_row [" * #{k}", v] }
|
146
|
-
st.add_row [
|
147
|
-
st.add_row [
|
148
|
-
st.add_row [
|
144
|
+
st.add_row ["Uniques", @stats[:uniques]]
|
145
|
+
st.add_row ["Logs", @stats[:uniques]]
|
146
|
+
st.add_row [" ", " "]
|
149
147
|
|
150
|
-
st.add_row [
|
148
|
+
st.add_row ["Gets", @stats[:gets]]
|
151
149
|
if @gets.count > 0
|
152
150
|
list = @gets.sort_by { |_k, v| v }
|
153
151
|
list.reverse_each { |item| st.add_row [" * #{item[0]}", item[1].to_s] }
|
154
152
|
end
|
155
153
|
|
156
|
-
st.add_row [
|
154
|
+
st.add_row ["Sets", @stats[:sets]]
|
157
155
|
if @sets.count > 0
|
158
156
|
@sets.each_pair { |k, v| st.add_row [" * #{k}", v.to_s] }
|
159
157
|
end
|
data/lib/teuton/cli.rb
CHANGED
@@ -1,19 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require_relative
|
4
|
-
require_relative '../teuton'
|
1
|
+
require "thor"
|
2
|
+
require_relative "version"
|
3
|
+
require_relative "../teuton"
|
5
4
|
|
6
5
|
class CLI < Thor
|
7
|
-
map [
|
6
|
+
map ["h", "-h", "--help"] => "help"
|
8
7
|
|
9
|
-
map [
|
10
|
-
desc
|
11
|
-
def version
|
12
|
-
puts "#{Teuton::APPNAME} (version #{Teuton::VERSION})"
|
13
|
-
end
|
14
|
-
|
15
|
-
map ['n', '-n', '--new'] => 'new'
|
16
|
-
desc 'new DIRECTORY', 'Create skeleton for a new project'
|
8
|
+
map ["n", "-n", "--new"] => "new"
|
9
|
+
desc "new DIRECTORY", "Create skeleton for a new project"
|
17
10
|
long_desc <<-LONGDESC
|
18
11
|
Create files for a new project.
|
19
12
|
LONGDESC
|
@@ -21,12 +14,11 @@ class CLI < Thor
|
|
21
14
|
Teuton.create(projectpath)
|
22
15
|
end
|
23
16
|
|
24
|
-
map [
|
17
|
+
map ["c", "-c", "--check"] => "check"
|
25
18
|
option :panelconfig, type: :boolean
|
26
19
|
option :cname, type: :string
|
27
20
|
option :cpath, type: :string
|
28
|
-
desc
|
29
|
-
'Check test and config file content'
|
21
|
+
desc "check [OPTIONS] DIRECTORY", "Check test and config file content"
|
30
22
|
long_desc <<-LONGDESC
|
31
23
|
|
32
24
|
(1) teuton check path/to/dir/foo
|
@@ -46,15 +38,31 @@ class CLI < Thor
|
|
46
38
|
Teuton.check(projectpath, options)
|
47
39
|
end
|
48
40
|
|
49
|
-
map [
|
41
|
+
map ["--readme"] => "readme"
|
42
|
+
option :lang, type: :string
|
43
|
+
desc "readme DIRECTORY", "Show README extracted from test contents"
|
44
|
+
long_desc <<-LONGDESC
|
45
|
+
|
46
|
+
(1) teuton readme foo
|
47
|
+
, Create README.md from foo/start.rb.
|
48
|
+
|
49
|
+
(2) teuton readme foo/demo.rb
|
50
|
+
, Create README.md from foo/demo.rb.
|
51
|
+
LONGDESC
|
52
|
+
|
53
|
+
def readme(projectpath)
|
54
|
+
# Create README from teuton test
|
55
|
+
Teuton.readme(projectpath, options)
|
56
|
+
end
|
57
|
+
|
58
|
+
map ["--run", "run"] => "play"
|
50
59
|
option :export, type: :string
|
51
60
|
option :cname, type: :string
|
52
61
|
option :cpath, type: :string
|
53
62
|
option :case, type: :string
|
54
63
|
option :color, type: :boolean
|
55
64
|
option :quiet, type: :boolean
|
56
|
-
desc
|
57
|
-
'Run test from directory'
|
65
|
+
desc "[run] [OPTIONS] DIRECTORY", "Run test from directory"
|
58
66
|
long_desc <<-LONGDESC
|
59
67
|
This function execute challenge from specified directory.
|
60
68
|
By default, show progress on the screen.
|
@@ -77,22 +85,10 @@ class CLI < Thor
|
|
77
85
|
Teuton.run(filepath, options)
|
78
86
|
end
|
79
87
|
|
80
|
-
map [
|
81
|
-
|
82
|
-
|
83
|
-
|
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)
|
88
|
+
map ["v", "-v", "--version"] => "version"
|
89
|
+
desc "version", "Show the program version"
|
90
|
+
def version
|
91
|
+
puts "#{Teuton::APPNAME} version #{Teuton::VERSION}"
|
96
92
|
end
|
97
93
|
|
98
94
|
##
|
data/lib/teuton/files/start.rb
CHANGED
data/lib/teuton/readme/dsl.rb
CHANGED
@@ -20,7 +20,7 @@ class Readme
|
|
20
20
|
|
21
21
|
def target(desc, args = {})
|
22
22
|
previous_host = @action[:host]
|
23
|
-
@action = {
|
23
|
+
@action = {target: desc, host: previous_host, readme: []}
|
24
24
|
weight = 1.0
|
25
25
|
weight = args[:weight].to_f if args[:weight]
|
26
26
|
@action[:weight] = weight
|
@@ -54,7 +54,7 @@ class Readme
|
|
54
54
|
@required_hosts[host.to_s] = b
|
55
55
|
end
|
56
56
|
@action[:host] = host
|
57
|
-
@action[:exec] = args[:exec] ||
|
57
|
+
@action[:exec] = args[:exec] || "noexec"
|
58
58
|
end
|
59
59
|
|
60
60
|
def run(command, args = {})
|
@@ -85,9 +85,15 @@ class Readme
|
|
85
85
|
end
|
86
86
|
|
87
87
|
# If a method call is missing, then delegate to concept parent.
|
88
|
-
def method_missing(method)
|
89
|
-
|
90
|
-
|
88
|
+
def method_missing(method, args = {})
|
89
|
+
m = method.to_s
|
90
|
+
if m[0] == "_"
|
91
|
+
instance_eval("get(:#{m[1, m.size - 1]})", __FILE__, __LINE__)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def respond_to_missing?(method_name, include_private = false)
|
96
|
+
true
|
91
97
|
end
|
92
98
|
|
93
99
|
def gett(value)
|
@@ -106,7 +112,7 @@ class Readme
|
|
106
112
|
# don't do nothing
|
107
113
|
end
|
108
114
|
|
109
|
-
def log(text =
|
115
|
+
def log(text = "", type = :info)
|
110
116
|
@data[:logs] << "[#{type}]: " + text.to_s
|
111
117
|
end
|
112
118
|
end
|
data/lib/teuton/readme/lang.rb
CHANGED
@@ -1,30 +1,29 @@
|
|
1
|
-
|
2
|
-
require_relative '../application'
|
1
|
+
require_relative "../application"
|
3
2
|
|
4
3
|
module Lang
|
5
4
|
def self.get(key)
|
6
5
|
lang = {}
|
7
|
-
lang[
|
8
|
-
version:
|
9
|
-
testname:
|
10
|
-
date:
|
11
|
-
hosts:
|
12
|
-
params:
|
13
|
-
goto:
|
14
|
-
global:
|
15
|
-
created:
|
6
|
+
lang["en"] = {
|
7
|
+
version: "Teuton version : %s",
|
8
|
+
testname: "Test unit name : %s",
|
9
|
+
date: "Date : %s",
|
10
|
+
hosts: "\n\#\#\# Required hosts\n",
|
11
|
+
params: "\n\#\#\# Required params\n",
|
12
|
+
goto: "\nGo to [%s](\#required-hosts) host, and do next:\n",
|
13
|
+
global: "\nGlobal parameters that can be modified:\n",
|
14
|
+
created: "\nParams created during challenge execution:\n"
|
16
15
|
}
|
17
|
-
lang[
|
18
|
-
version:
|
19
|
-
testname:
|
20
|
-
date:
|
21
|
-
hosts:
|
22
|
-
params:
|
23
|
-
goto:
|
24
|
-
global:
|
25
|
-
created:
|
16
|
+
lang["es"] = {
|
17
|
+
version: "Versión de Teuton : %s",
|
18
|
+
testname: "Nombre del test : %s",
|
19
|
+
date: "Fecha : %s",
|
20
|
+
hosts: "\n\#\#\# Máquinas que se necesitan\n",
|
21
|
+
params: "\n\#\#\# Parámetros de necesarios\n",
|
22
|
+
goto: "\nIr a la máquina [%s](\#required-hosts), y hacer lo siguiente:\n",
|
23
|
+
global: "\nParámetros globales que pueden ser modificados:\n",
|
24
|
+
created: "\nParámetros creados durante la ejecución del reto:\n"
|
26
25
|
}
|
27
|
-
locale = Application.instance.options[
|
26
|
+
locale = Application.instance.options["lang"].downcase
|
28
27
|
lang[locale][key]
|
29
28
|
end
|
30
29
|
end
|
data/lib/teuton/readme/readme.rb
CHANGED
@@ -1,14 +1,13 @@
|
|
1
|
-
|
2
|
-
require_relative
|
3
|
-
require_relative
|
4
|
-
require_relative
|
5
|
-
require_relative
|
6
|
-
require_relative 'lang'
|
1
|
+
require_relative "../application"
|
2
|
+
require_relative "../utils/configfile_reader"
|
3
|
+
require_relative "../case_manager/case/result/result"
|
4
|
+
require_relative "dsl"
|
5
|
+
require_relative "lang"
|
7
6
|
|
8
7
|
def use(filename)
|
9
|
-
filename +=
|
8
|
+
filename += ".rb"
|
10
9
|
app = Application.instance
|
11
|
-
rbfiles = File.join(app.project_path,
|
10
|
+
rbfiles = File.join(app.project_path, "**", filename)
|
12
11
|
files = Dir.glob(rbfiles)
|
13
12
|
use = []
|
14
13
|
files.sort.each { |f| use << f if f.include?(filename) }
|
@@ -16,13 +15,14 @@ def use(filename)
|
|
16
15
|
end
|
17
16
|
|
18
17
|
def group(name, &block)
|
19
|
-
Application.instance.groups << {
|
18
|
+
Application.instance.groups << {name: name, block: block}
|
20
19
|
end
|
21
20
|
alias task group
|
22
21
|
|
23
22
|
def start(&block)
|
24
23
|
# don't do nothing
|
25
24
|
end
|
25
|
+
# alias_method "play", "start" # REVISE THIS
|
26
26
|
alias play start
|
27
27
|
|
28
28
|
# Creates README.md file from RB script file
|
@@ -36,10 +36,10 @@ class Readme
|
|
36
36
|
# @param config_path (String) Path to main config file (config.yaml)
|
37
37
|
def initialize(script_path, config_path)
|
38
38
|
@path = {}
|
39
|
-
@path[:script]
|
40
|
-
@path[:dirname]
|
41
|
-
@path[:filename] = File.basename(script_path,
|
42
|
-
@path[:config]
|
39
|
+
@path[:script] = script_path
|
40
|
+
@path[:dirname] = File.dirname(script_path)
|
41
|
+
@path[:filename] = File.basename(script_path, ".rb")
|
42
|
+
@path[:config] = config_path
|
43
43
|
reset
|
44
44
|
end
|
45
45
|
|
@@ -70,7 +70,7 @@ class Readme
|
|
70
70
|
|
71
71
|
def process_content
|
72
72
|
Application.instance.groups.each do |g|
|
73
|
-
@current = {
|
73
|
+
@current = {name: g[:name], readme: [], actions: []}
|
74
74
|
@data[:groups] << @current
|
75
75
|
reset_action
|
76
76
|
instance_eval(&g[:block])
|
@@ -78,29 +78,29 @@ class Readme
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def reset_action
|
81
|
-
@action = {
|
81
|
+
@action = {readme: []}
|
82
82
|
end
|
83
83
|
|
84
84
|
def show_head
|
85
85
|
app = Application.instance
|
86
|
-
puts
|
87
|
-
puts format(Lang
|
88
|
-
puts format(Lang
|
89
|
-
puts format(Lang
|
90
|
-
puts
|
86
|
+
puts "```"
|
87
|
+
puts format(Lang.get(:testname), app.test_name)
|
88
|
+
puts format(Lang.get(:date), Time.now)
|
89
|
+
puts format(Lang.get(:version), Application::VERSION)
|
90
|
+
puts "```"
|
91
91
|
puts "\n"
|
92
92
|
puts "# #{app.test_name}\n"
|
93
93
|
|
94
94
|
i = 1
|
95
95
|
unless @required_hosts.empty?
|
96
|
-
puts Lang
|
96
|
+
puts Lang.get(:hosts)
|
97
97
|
puts "\n"
|
98
|
-
puts
|
99
|
-
puts
|
98
|
+
puts "| ID | Host | Configuration |"
|
99
|
+
puts "| --- | --- | --- |"
|
100
100
|
@required_hosts.each_pair do |k, v|
|
101
101
|
c = []
|
102
|
-
v.each_pair { |k2,v2| c << "#{k2}=#{v2}" }
|
103
|
-
puts "| #{i} | #{k.upcase} | #{c.join(
|
102
|
+
v.each_pair { |k2, v2| c << "#{k2}=#{v2}" }
|
103
|
+
puts "| #{i} | #{k.upcase} | #{c.join(", ")} |"
|
104
104
|
i += 1
|
105
105
|
end
|
106
106
|
puts "\n> NOTE: SSH Service installation is required on every host."
|
@@ -108,8 +108,8 @@ class Readme
|
|
108
108
|
|
109
109
|
unless @cases_params.empty?
|
110
110
|
@cases_params.sort!
|
111
|
-
puts Lang
|
112
|
-
@cases_params.uniq.each { |i| puts format(
|
111
|
+
puts Lang.get(:params)
|
112
|
+
@cases_params.uniq.each { |i| puts format("* %s", i) }
|
113
113
|
puts "\n> NOTE: Save every 'param: value' into config file."
|
114
114
|
end
|
115
115
|
end
|
@@ -126,13 +126,13 @@ class Readme
|
|
126
126
|
item[:host] = group[:actions][0][:host]
|
127
127
|
end
|
128
128
|
if previous_host.nil? || item[:host] != previous_host
|
129
|
-
previous_host = item[:host] ||
|
130
|
-
puts format(Lang
|
129
|
+
previous_host = item[:host] || "null"
|
130
|
+
puts format(Lang.get(:goto), previous_host.upcase)
|
131
131
|
end
|
132
132
|
|
133
|
-
weight =
|
134
|
-
weight = "(x#{item[:weight]}) " if item[:weight] != 1
|
135
|
-
last = (item[:target].end_with?(
|
133
|
+
weight = ""
|
134
|
+
weight = "(x#{item[:weight]}) " if item[:weight].to_i != 1
|
135
|
+
last = (item[:target].end_with?(".") ? "" : ".")
|
136
136
|
puts "* #{weight}#{item[:target]}#{last}"
|
137
137
|
item[:readme].each { |line| puts " * #{line}\n" }
|
138
138
|
end
|
@@ -142,21 +142,19 @@ class Readme
|
|
142
142
|
def show_tail
|
143
143
|
return if @global_params.empty?
|
144
144
|
|
145
|
-
app = Application.instance
|
146
145
|
puts "\n---"
|
147
146
|
puts "# ANEXO"
|
148
147
|
puts "\n\#\# Global params"
|
149
|
-
puts Lang
|
148
|
+
puts Lang.get(:global)
|
150
149
|
puts "\n"
|
151
|
-
puts
|
152
|
-
puts
|
153
|
-
@global_params.each_pair { |k,v| puts "|#{k}|#{v}|" }
|
150
|
+
puts "| Global param | Value |"
|
151
|
+
puts "| --- | --- |"
|
152
|
+
@global_params.each_pair { |k, v| puts "|#{k}|#{v}|" }
|
154
153
|
puts "\n\#\# Created params"
|
155
|
-
puts Lang
|
154
|
+
puts Lang.get(:created)
|
156
155
|
puts "\n"
|
157
|
-
puts
|
158
|
-
puts
|
159
|
-
@setted_params.each_pair { |k,v| puts "|#{k}|#{v}|" }
|
156
|
+
puts "| Created params | Value |"
|
157
|
+
puts "| --- | --- |"
|
158
|
+
@setted_params.each_pair { |k, v| puts "|#{k}|#{v}|" }
|
160
159
|
end
|
161
160
|
end
|
162
|
-
|
data/lib/teuton/report/close.rb
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Close Show methods for Report class.
|
4
1
|
class Report
|
5
2
|
##
|
6
3
|
# Calculate final values:
|
@@ -9,8 +6,6 @@ class Report
|
|
9
6
|
# * good_weight,d
|
10
7
|
# * fail_weight
|
11
8
|
# * fail_counter
|
12
|
-
# rubocop:disable Metrics/AbcSize
|
13
|
-
# rubocop:disable Metrics/MethodLength
|
14
9
|
def close
|
15
10
|
app = Application.instance
|
16
11
|
max = 0.0
|
@@ -18,7 +13,7 @@ class Report
|
|
18
13
|
fail = 0.0
|
19
14
|
fail_counter = 0
|
20
15
|
@lines.each do |i|
|
21
|
-
next unless i.
|
16
|
+
next unless i.instance_of? Hash
|
22
17
|
|
23
18
|
max += i[:weight] if i[:weight].positive?
|
24
19
|
if i[:check]
|
@@ -40,6 +35,4 @@ class Report
|
|
40
35
|
@tail[:grade] = (100.0 * i).round
|
41
36
|
@tail[:grade] = 0 if @tail[:unique_fault].positive?
|
42
37
|
end
|
43
|
-
# rubocop:enable Metrics/AbcSize
|
44
|
-
# rubocop:enable Metrics/MethodLength
|
45
38
|
end
|