teuton 3.2.0 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/bin/teuton +2 -3
- data/docs/commands/readme.md +1 -1
- data/docs/devel/todo.md +74 -1
- data/docs/dsl/send.md +3 -3
- data/docs/dsl/show.md +2 -2
- data/docs/tutorial/es/nginx/README.md +4 -4
- data/lib/teuton/case/action.rb +31 -0
- data/lib/teuton/case/case.rb +8 -12
- data/lib/teuton/case/close.rb +1 -1
- data/lib/teuton/case/dsl/expect.rb +9 -10
- data/lib/teuton/case/dsl/expect_sequence.rb +1 -2
- data/lib/teuton/case/dsl/macro.rb +3 -2
- data/lib/teuton/case/dsl/run.rb +4 -5
- data/lib/teuton/case/dsl/send.rb +1 -17
- data/lib/teuton/case/dsl/target.rb +6 -4
- data/lib/teuton/case/dsl/upload.rb +1 -4
- data/lib/teuton/case/dsl/weight.rb +3 -3
- data/lib/teuton/case/execute/execute_base.rb +1 -1
- data/lib/teuton/case/execute/execute_local.rb +2 -2
- data/lib/teuton/case/execute/execute_manager.rb +6 -6
- data/lib/teuton/case/execute/execute_ssh.rb +6 -6
- data/lib/teuton/case/execute/execute_telnet.rb +4 -4
- data/lib/teuton/case/play.rb +7 -8
- data/lib/teuton/case_manager/case_manager.rb +4 -4
- data/lib/teuton/case_manager/dsl.rb +6 -9
- data/lib/teuton/case_manager/export_manager.rb +6 -12
- data/lib/teuton/case_manager/ext/check_cases.rb +1 -1
- data/lib/teuton/cli/app.rb +123 -0
- data/lib/teuton/cli/run.rb +38 -0
- data/lib/teuton/errors.rb +94 -0
- data/lib/teuton/readme/action.rb +29 -0
- data/lib/teuton/readme/dsl/all.rb +7 -5
- data/lib/teuton/readme/dsl/expect.rb +3 -3
- data/lib/teuton/readme/dsl/run.rb +5 -11
- data/lib/teuton/readme/main.rb +13 -6
- data/lib/teuton/readme/readme.rb +12 -15
- data/lib/teuton/report/formatter/default/txt.rb +2 -2
- data/lib/teuton/report/formatter/formatter.rb +4 -13
- data/lib/teuton/report/formatter/resume/txt.rb +2 -2
- data/lib/teuton/utils/config_file_reader.rb +3 -11
- data/lib/teuton/utils/logger.rb +15 -10
- data/lib/teuton/utils/name_file_finder.rb +3 -11
- data/lib/teuton/version.rb +1 -1
- data/lib/teuton.rb +6 -11
- metadata +6 -2
- data/lib/teuton/cli.rb +0 -120
data/lib/teuton/utils/logger.rb
CHANGED
|
@@ -3,30 +3,35 @@ require "rainbow"
|
|
|
3
3
|
class Logger
|
|
4
4
|
@verbose = true
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
class << self
|
|
7
|
+
attr_writer :verbose
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
class << self
|
|
11
|
+
attr_reader :verbose
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.puts(message)
|
|
15
|
+
Kernel.puts message if @verbose
|
|
12
16
|
end
|
|
13
17
|
|
|
14
18
|
def self.info(message)
|
|
15
|
-
|
|
19
|
+
text = Rainbow("Info | #{message}").white
|
|
20
|
+
Kernel.puts text if @verbose
|
|
16
21
|
end
|
|
17
22
|
|
|
18
23
|
def self.warn(message)
|
|
19
|
-
text = Rainbow(message).bright.yellow
|
|
20
|
-
|
|
24
|
+
text = Rainbow("Warn | #{message}").bright.yellow
|
|
25
|
+
Kernel.warn text if @verbose
|
|
21
26
|
end
|
|
22
27
|
|
|
23
28
|
def self.error(message)
|
|
24
|
-
text = Rainbow(message).bright.red
|
|
25
|
-
|
|
29
|
+
text = Rainbow("Error | #{message}").bright.red
|
|
30
|
+
Kernel.warn text if @verbose
|
|
26
31
|
end
|
|
27
32
|
|
|
28
33
|
def self.debug(message)
|
|
29
34
|
text = Rainbow(message).white
|
|
30
|
-
|
|
35
|
+
puts text if @verbose
|
|
31
36
|
end
|
|
32
37
|
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
require_relative "logger"
|
|
2
2
|
|
|
3
3
|
class NameFileFinder
|
|
4
4
|
attr_reader :options, :project_path, :script_path, :config_path, :testname
|
|
@@ -33,10 +33,7 @@ class NameFileFinder
|
|
|
33
33
|
# Find project filenames into directory <folder path>
|
|
34
34
|
# COMPLEX MODE: main RB file is <start.rb>
|
|
35
35
|
script_path = File.join(folder_path, "start.rb")
|
|
36
|
-
unless File.exist? script_path
|
|
37
|
-
warn Rainbow("[ERROR] Main script file not found! <#{script_path}>").bright.red
|
|
38
|
-
exit 1
|
|
39
|
-
end
|
|
36
|
+
raise Teuton::MainScriptNotFoundError, script_path unless File.exist? script_path
|
|
40
37
|
|
|
41
38
|
@project_path = folder_path
|
|
42
39
|
@script_path = script_path
|
|
@@ -66,12 +63,7 @@ class NameFileFinder
|
|
|
66
63
|
def find_filenames_from_rb(script_path)
|
|
67
64
|
# SIMPLE MODE: We use script_path as main RB file
|
|
68
65
|
# This must be fullpath to DSL script file
|
|
69
|
-
if File.extname(script_path) != ".rb"
|
|
70
|
-
warn Rainbow("[ERROR] Main script file not found!").bright.red
|
|
71
|
-
warn Rainbow("[ERROR] Not found <#{script_path}/start.rb>").white
|
|
72
|
-
warn Rainbow("[ERROR] Not found <#{script_path}.rb>").white
|
|
73
|
-
exit 1
|
|
74
|
-
end
|
|
66
|
+
raise Teuton::MainScriptNotFoundError, script_path if File.extname(script_path) != ".rb"
|
|
75
67
|
|
|
76
68
|
@project_path = File.dirname(script_path)
|
|
77
69
|
@script_path = script_path
|
data/lib/teuton/version.rb
CHANGED
data/lib/teuton.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require_relative "teuton/utils/project"
|
|
2
|
-
|
|
2
|
+
require_relative "teuton/errors"
|
|
3
3
|
|
|
4
4
|
module Teuton
|
|
5
5
|
def self.create(path_to_new_dir)
|
|
@@ -36,15 +36,10 @@ module Teuton
|
|
|
36
36
|
private_class_method def self.require_dsl_and_script(dslpath)
|
|
37
37
|
# Load DSL file and then load script file
|
|
38
38
|
require_relative dslpath
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
e.backtrace&.first(3)&.each do |line|
|
|
45
|
-
warn Rainbow("[ERROR] #{line}").white
|
|
46
|
-
end
|
|
47
|
-
exit 1
|
|
48
|
-
end
|
|
39
|
+
|
|
40
|
+
mainscriptfile = Project.value[:script_path]
|
|
41
|
+
raise MainScriptNotFoundError.new(mainscriptfile) unless File.exist?(mainscriptfile)
|
|
42
|
+
|
|
43
|
+
require_relative mainscriptfile
|
|
49
44
|
end
|
|
50
45
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: teuton
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.2.
|
|
4
|
+
version: 3.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Vargas Ruiz
|
|
@@ -252,6 +252,7 @@ files:
|
|
|
252
252
|
- docs/more.md
|
|
253
253
|
- docs/tutorial/es/nginx/README.md
|
|
254
254
|
- lib/teuton.rb
|
|
255
|
+
- lib/teuton/case/action.rb
|
|
255
256
|
- lib/teuton/case/builtin/main.rb
|
|
256
257
|
- lib/teuton/case/builtin/package.rb
|
|
257
258
|
- lib/teuton/case/builtin/service.rb
|
|
@@ -305,12 +306,15 @@ files:
|
|
|
305
306
|
- lib/teuton/check/dsl/run.rb
|
|
306
307
|
- lib/teuton/check/main.rb
|
|
307
308
|
- lib/teuton/check/show.rb
|
|
308
|
-
- lib/teuton/cli.rb
|
|
309
|
+
- lib/teuton/cli/app.rb
|
|
310
|
+
- lib/teuton/cli/run.rb
|
|
309
311
|
- lib/teuton/deprecated/utils.rb
|
|
312
|
+
- lib/teuton/errors.rb
|
|
310
313
|
- lib/teuton/files/config.yaml
|
|
311
314
|
- lib/teuton/files/start.rb
|
|
312
315
|
- lib/teuton/files/template/case.html
|
|
313
316
|
- lib/teuton/files/template/resume.html
|
|
317
|
+
- lib/teuton/readme/action.rb
|
|
314
318
|
- lib/teuton/readme/dsl/all.rb
|
|
315
319
|
- lib/teuton/readme/dsl/expect.rb
|
|
316
320
|
- lib/teuton/readme/dsl/getset.rb
|
data/lib/teuton/cli.rb
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
require "thor"
|
|
2
|
-
require_relative "version"
|
|
3
|
-
require_relative "../teuton"
|
|
4
|
-
|
|
5
|
-
class CLI < Thor
|
|
6
|
-
map ["h", "-h", "--help"] => "help"
|
|
7
|
-
|
|
8
|
-
map ["n", "-n", "--new"] => "new"
|
|
9
|
-
desc "new DIRECTORY", "Create skeleton for a new project"
|
|
10
|
-
long_desc <<-LONGDESC
|
|
11
|
-
Create files for a new project.
|
|
12
|
-
LONGDESC
|
|
13
|
-
def new(projectpath)
|
|
14
|
-
Teuton.create(projectpath)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
map ["c", "-c", "--check"] => "check"
|
|
18
|
-
option :onlyconfig, type: :boolean
|
|
19
|
-
option :color, type: :boolean
|
|
20
|
-
option :cname, type: :string
|
|
21
|
-
option :cpath, type: :string
|
|
22
|
-
desc "check [OPTIONS] DIRECTORY", "Check test and config file content"
|
|
23
|
-
long_desc <<~LONGDESC
|
|
24
|
-
|
|
25
|
-
(1) teuton check PATH/TO/DIR , Check content of start.rb and config.yaml files.
|
|
26
|
-
|
|
27
|
-
(2) teuton check PATH/TO/DIR --cname=demo , Check content of start.rb and demo.yaml files:
|
|
28
|
-
|
|
29
|
-
(3) teuton check PATH/TO/DIR --onlyconfig , Only show config file recomendations
|
|
30
|
-
|
|
31
|
-
(4) teuton check PATH/TO/DIR/foo.rb , Check content of foo.rb and foo.yaml files.
|
|
32
|
-
|
|
33
|
-
(5) teuton check PATH/TO/DIR/foo.rb --cname=demo , Check content of foo.rb and demo.yaml files.
|
|
34
|
-
|
|
35
|
-
LONGDESC
|
|
36
|
-
def check(projectpath)
|
|
37
|
-
Teuton.check(projectpath, options)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
map ["co", "-co", "--config"] => "config"
|
|
41
|
-
desc "config [OPTIONS] DIRECTORY", "Suggest configuration."
|
|
42
|
-
long_desc <<~LONGDESC
|
|
43
|
-
config DIRECTORY, "Suggest the content of the configuration file based on the test"
|
|
44
|
-
LONGDESC
|
|
45
|
-
def config(projectpath)
|
|
46
|
-
# Check Test: suggest the content of the configuration file based on the test
|
|
47
|
-
opt = {"onlyconfig" => true}
|
|
48
|
-
Teuton.check(projectpath, opt)
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
map ["--readme"] => "readme"
|
|
52
|
-
option :lang, type: :string
|
|
53
|
-
desc "readme DIRECTORY", "Show README extracted from test contents"
|
|
54
|
-
long_desc <<-LONGDESC
|
|
55
|
-
|
|
56
|
-
(1) teuton readme foo
|
|
57
|
-
, Create README.md from foo/start.rb.
|
|
58
|
-
|
|
59
|
-
(2) teuton readme foo/demo.rb
|
|
60
|
-
, Create README.md from foo/demo.rb.
|
|
61
|
-
LONGDESC
|
|
62
|
-
|
|
63
|
-
def readme(projectpath)
|
|
64
|
-
# Create README from teuton test
|
|
65
|
-
Teuton.readme(projectpath, options)
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
map ["--run", "run"] => "play"
|
|
69
|
-
option :export, type: :string
|
|
70
|
-
option :cname, type: :string
|
|
71
|
-
option :cpath, type: :string
|
|
72
|
-
option :case, type: :string
|
|
73
|
-
option :color, type: :boolean
|
|
74
|
-
option :quiet, type: :boolean
|
|
75
|
-
desc "[run] [OPTIONS] DIRECTORY", "Run test from directory"
|
|
76
|
-
long_desc <<-LONGDESC
|
|
77
|
-
This function execute challenge from specified directory.
|
|
78
|
-
By default, show progress on the screen.
|
|
79
|
-
|
|
80
|
-
Let's see others options:
|
|
81
|
-
|
|
82
|
-
(1) teuton foo, run challenge from foo/start.rb with foo/config.yaml config file.
|
|
83
|
-
|
|
84
|
-
(2) teuton run foo, same as (1).
|
|
85
|
-
|
|
86
|
-
(3) teuton run --export=json foo, run challenge and export using json format.
|
|
87
|
-
Others output formats availables are: txt, html, yaml, json and colored_text.
|
|
88
|
-
|
|
89
|
-
(4) teuton run --cname=demo foo, run challenge from foo/start.rb with foo/demo.yaml config file.
|
|
90
|
-
|
|
91
|
-
(5) teuton foo/demo.rb, Run challenge from foo/demo.rb with foo/demo.yaml config file.
|
|
92
|
-
|
|
93
|
-
LONGDESC
|
|
94
|
-
def play(filepath)
|
|
95
|
-
Teuton.run(filepath, options)
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
map ["v", "-v", "--version"] => "version"
|
|
99
|
-
desc "version", "Show the program version"
|
|
100
|
-
def version
|
|
101
|
-
puts "#{Teuton::APPNAME} version #{Teuton::VERSION}"
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
##
|
|
105
|
-
# These inputs are equivalents:
|
|
106
|
-
# * teuton dir/foo
|
|
107
|
-
# * teuton run dir/foo
|
|
108
|
-
def method_missing(method, *_args, &_block)
|
|
109
|
-
play(method.to_s)
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
def respond_to_missing?(method_name, include_private = false)
|
|
113
|
-
# Respond to missing methods name
|
|
114
|
-
super
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
def self.exit_on_failure?
|
|
118
|
-
true
|
|
119
|
-
end
|
|
120
|
-
end
|