teuton 3.1.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.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/bin/teuton +2 -3
  4. data/docs/commands/readme.md +1 -1
  5. data/docs/devel/todo.md +87 -44
  6. data/docs/dsl/send.md +3 -3
  7. data/docs/dsl/show.md +2 -2
  8. data/docs/install/t-node.md +4 -14
  9. data/docs/learn/18-log.md +55 -20
  10. data/docs/tutorial/es/nginx/README.md +4 -4
  11. data/lib/teuton/case/action.rb +31 -0
  12. data/lib/teuton/case/case.rb +8 -12
  13. data/lib/teuton/case/close.rb +1 -1
  14. data/lib/teuton/case/dsl/expect.rb +10 -11
  15. data/lib/teuton/case/dsl/expect_sequence.rb +1 -2
  16. data/lib/teuton/case/dsl/macro.rb +3 -2
  17. data/lib/teuton/case/dsl/run.rb +4 -5
  18. data/lib/teuton/case/dsl/run_script.rb +3 -3
  19. data/lib/teuton/case/dsl/send.rb +2 -18
  20. data/lib/teuton/case/dsl/target.rb +6 -4
  21. data/lib/teuton/case/dsl/upload.rb +2 -5
  22. data/lib/teuton/case/dsl/weight.rb +3 -3
  23. data/lib/teuton/case/execute/execute_base.rb +4 -4
  24. data/lib/teuton/case/execute/execute_local.rb +2 -2
  25. data/lib/teuton/case/execute/execute_manager.rb +6 -6
  26. data/lib/teuton/case/execute/execute_ssh.rb +6 -6
  27. data/lib/teuton/case/execute/execute_telnet.rb +4 -4
  28. data/lib/teuton/case/play.rb +7 -8
  29. data/lib/teuton/case_manager/case_manager.rb +4 -4
  30. data/lib/teuton/case_manager/dsl.rb +7 -10
  31. data/lib/teuton/case_manager/export_manager.rb +6 -12
  32. data/lib/teuton/case_manager/ext/check_cases.rb +1 -1
  33. data/lib/teuton/cli/app.rb +123 -0
  34. data/lib/teuton/cli/run.rb +38 -0
  35. data/lib/teuton/errors.rb +94 -0
  36. data/lib/teuton/readme/action.rb +29 -0
  37. data/lib/teuton/readme/dsl/all.rb +7 -5
  38. data/lib/teuton/readme/dsl/expect.rb +3 -3
  39. data/lib/teuton/readme/dsl/run.rb +5 -11
  40. data/lib/teuton/readme/main.rb +13 -6
  41. data/lib/teuton/readme/readme.rb +12 -15
  42. data/lib/teuton/report/formatter/base_formatter.rb +2 -2
  43. data/lib/teuton/report/formatter/default/txt.rb +2 -2
  44. data/lib/teuton/report/formatter/formatter.rb +4 -13
  45. data/lib/teuton/report/formatter/resume/txt.rb +2 -2
  46. data/lib/teuton/utils/config_file_reader.rb +4 -12
  47. data/lib/teuton/utils/logger.rb +15 -10
  48. data/lib/teuton/utils/name_file_finder.rb +3 -11
  49. data/lib/teuton/version.rb +1 -1
  50. data/lib/teuton.rb +6 -11
  51. metadata +6 -2
  52. data/lib/teuton/cli.rb +0 -120
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a570d2b6215ff6b0ec6b1f2c7b8335fae59bc09fa431ccfe2b53d5915741973a
4
- data.tar.gz: 71faaf841d291094d9d31712788984b698e190399232f8ea9ef3b9d05dd6ebff
3
+ metadata.gz: 3516a5e7aa9c634173b9e5eb7861ff1714ee4e583da4bcad3c01ac8400831313
4
+ data.tar.gz: c551387224c5c47a545c4455a673d7401495b0a2ef000770010c8d0d3926079d
5
5
  SHA512:
6
- metadata.gz: 52d80646fd74c71ba0b1b9d4a678cbf3af441f6c1bd8b376cc05d9be43d0c22522b847364ae85c2979618b426c88ef2a0220c9c9f033b1c020767d22159ab960
7
- data.tar.gz: 4ff1a2f3cd3d2e0c68e3b7b08e58deef6d96a153e4610378a20be7d22902f9ab6767c80db2c42517454c13178b4cb811147dc9f2b3386c70ec48bc3d0e81b331
6
+ metadata.gz: 320eb8621ce4b42c2f5316a2b8edb7a8a6ea01abf9fc2e42588df583bd3baa10a22b51b9389d829544a1fae82a84934f6e1c82d98624a6bd263a8cafb5db2678
7
+ data.tar.gz: 80cc780a54d6b2771904475f5cd89b6954b46c9cf9e04a173cc6dc0e996db13eb3bed7dd2c92b252ae8d58faedb16d1f361d4e151fb26f8baab4f812349086c1
data/README.md CHANGED
@@ -37,7 +37,7 @@ group "Learn about targets" do
37
37
  expect_fail
38
38
  end
39
39
 
40
- start do
40
+ play do
41
41
  show
42
42
  export
43
43
  end
data/bin/teuton CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
+ require "teuton/cli/run"
2
3
 
3
- require "teuton/cli"
4
-
5
- CLI.start(ARGV)
4
+ Teuton::CLI.run(ARGV)
@@ -28,7 +28,7 @@ group "Learn about targets" do
28
28
  expect_fail
29
29
  end
30
30
 
31
- start do
31
+ play do
32
32
  show
33
33
  export
34
34
  end
data/docs/devel/todo.md CHANGED
@@ -7,9 +7,9 @@
7
7
  * Revisar (tests): result.grep(a).grep(b)
8
8
  * "Limpiar" las funciones "deprecated"
9
9
  * Aplicar las recomendaciones del informe de seguridad de Andrés.
10
- * Eliminar/limpiar toda referencia a Vagrant.
11
10
  * verify get(:key) and get('key') works fine!
12
11
  * Formatter: xml
12
+ * Revisar la utilidad de action.assets al generar README.
13
13
 
14
14
  # 2. Documentacion
15
15
 
@@ -46,7 +46,7 @@ Ampliar las estadísticas de salida en el report `resume`:
46
46
 
47
47
  Nueva feature "eventos".
48
48
 
49
- * La idea está documentada mejor en el enlace siguiente.
49
+ * La idea está desarrollada en el enlace siguiente.
50
50
  * [Propuesta](https://github.com/dvarrui/teuton-book/blob/main/docs/03.eventos/index.md)
51
51
 
52
52
  Idea antigua: `ensure`
@@ -71,7 +71,7 @@ libs/module
71
71
 
72
72
  Modificar el DSL/configuración para mejorar la integración con los contenidores Docker/podman:
73
73
 
74
- > * Docker en vez de vagrant?? → https://www.cloudbees.com/blog/ssh-into-a-docker-container-how-to-execute-your-commands
74
+ > * Docker?? → https://www.cloudbees.com/blog/ssh-into-a-docker-container-how-to-execute-your-commands
75
75
 
76
76
  Host definition example:
77
77
 
@@ -147,7 +147,6 @@ var
147
147
  * Unify messages ERROR, INFO, WARN. etc
148
148
  * **TEST**:
149
149
  * HallOfFame test
150
- * actualizar las pruebas con vagrant para la versión actual. Mejora de la calidad del código (Todo lo de Vagrant debería estar deprecated).
151
150
 
152
151
  ## 4.3 FEATURE - SAVE STATE
153
152
 
@@ -170,48 +169,92 @@ var
170
169
  * Documentación en https://readthedocs.org/ ??
171
170
  * FEATURE: Auto Parse new input format, and detect parse errors
172
171
 
172
+ ## 4.5 Async or Ractors
173
+
174
+ Expandir el modo de ejecución y medir rendimiento:
175
+
176
+ - Secuencial
177
+ - Hilos
178
+ - Fibras
179
+ - Actores
180
+
181
+ ## 4.6 Excepciones vs exit
182
+
183
+ La buena práctica es la separación de responsabilidades:
184
+
185
+ * La librería nunca debe hacer exit ni abort. Su trabajo es exclusivamente levantar excepciones personalizadas cuando algo sale mal.
186
+ * El ejecutable (CLI) es el único que debe capturar esas excepciones, mostrarlas de forma amigable por la terminal y decidir cuándo terminar el proceso con exit 1.
187
+
188
+ * **Paso 1: Definir excepciones personalizadas**:
189
+
190
+ ```ruby
191
+ # lib/teuton/errors.rb
192
+ module Teuton
193
+ class Error < StandardError; end
194
+ class ConfigurationError < Error; end
195
+ class ExecutionError < Error; end
196
+ end
197
+ ```
198
+ * **Paso 2: Reemplazar los exit 1 en la librería por `raise`**
199
+
200
+ ```ruby
201
+ # lib/teuton/runner.rb
202
+ def run
203
+ if invalid_config?
204
+ raise Teuton::ConfigurationError, "Configuración inválida"
205
+ end
206
+ end
207
+ ```
208
+
209
+ * Paso 3: Capturar las excepciones en CLI
210
+ * Integración con Thor
211
+
212
+ 1. Hacer que Thor devuelva un código de salida 1 en errores de Thor
213
+
214
+ ```ruby
215
+ # lib/teuton/cli.rb
216
+ require "thor"
217
+
218
+ module Teuton
219
+ class CLI < Thor
220
+ # Esto asegura que si Thor falla internamente (ej: comandos/opciones inválidas),
221
+ # el programa salga con código 1 en lugar de 0.
222
+ def self.exit_on_failure?
223
+ true
224
+ end
225
+
226
+ desc "run", "Ejecuta un script de Teuton"
227
+ def run
228
+ # Aquí llamas a la lógica de tu gema
229
+ # Si hay un error, tu lógica lanzará una excepción (ej: Teuton::Error)
230
+ Teuton::Runner.new.execute
231
+ end
232
+ end
233
+ end
234
+ ```
235
+
236
+ 2. Lanzar excepciones personalizadas en la lógica de tu librería.
237
+
238
+ ```ruby
239
+ # lib/teuton/runner.rb
240
+ module Teuton
241
+ class Runner
242
+ def execute
243
+ if algun_error_detectado?
244
+ raise Teuton::Error, "Ocurrió un error al ejecutar los tests"
245
+ end
246
+ end
247
+ end
248
+ end
249
+ ```
250
+
251
+ 3. Capturar excepciones en el ejecutable bin/teuton
252
+
173
253
  # 5. Proyectos
174
254
 
175
- Empezó como un nuevo feature pero por su dimensión, funcionalidad y características ha derivado en su propio proyecto indepemndiente:
176
-
177
- * La gema `teuton-panel`
178
-
179
- ## 5.1. Nueva gema teuton-panel (v2.0.0)
180
-
181
- > Consultar en el repostorio `teuton-panel`. EN PROCESO!!!
182
-
183
- Este TO-DO debería estar en el propio repo de la nueva gema.
184
-
185
- * Crear nueva gema `teuton-panel` (v2) que sustituirá la versión obsoleta actual.
186
- * Modificar/ampliar las funciones de `teuton config` para facilitar el trabajo a `teuton-panel`.
187
- * tt_include
188
- * tt_include_params
189
- * aplanar/desaplanar config file.
190
- * En las pruebas hemos usado `sinatra` para implementarlo.
191
-
192
- Funcionalidades del interfaz web:
193
-
194
- * config cases:
195
- * config/remote:
196
- * accept-remote-config. activar/desactivar configuraciones remotas
197
- * Aceptar post formulario y vía get curl con ruta.
198
- * config/list: mostrar listado con info de alumnos
199
- * Elegir ubicación de almacenamiento de las configuraciones
200
- * run:
201
- * Ejecutar por el profesor
202
- * Todos
203
- * Una selección de cases
204
- * every: repeticiones en bucle de I iteraciones, cada T tiempo.
205
- * El alumno solicita su propia ejecución vía curl
206
- * Elegir ubicación de almacenamiento de los informes
207
- * Al finalizar cada ejecución se muestre un listado con los resultados
208
- * readme/doc:
209
- * activar auto "teuton doc" a página web para los alumnos.
210
- * config panel:
211
- * panel/new: crear fichero de configuración del panel
212
- * panel/save: save configuración del panel
213
-
214
- ## 5.2 Editor de tests
255
+ Ideas que emepzaron como un nuevo feature pero por sus dimensiones, funcionalidades y características van ha derivar a su propio proyecto independiente:
256
+
257
+ ## 5.1 Editor de tests
215
258
 
216
259
  * Editor de tests ?! .... lo veo complejo... a menos que se empiece por una versión simplificada..
217
260
  * El DSL es tan sencillo que no le veo sentido a un editor de retos.
data/docs/dsl/send.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  Usage:
8
8
  ```ruby
9
- start do
9
+ play do
10
10
  export
11
11
  send copy_to: :host1
12
12
  end
@@ -31,7 +31,7 @@ If you export several files using differents output formats, you will use severa
31
31
  In this example we export html and txt files, but only send txt to remote hosts:
32
32
 
33
33
  ```ruby
34
- start do
34
+ play do
35
35
  export format: :json
36
36
  export format: :txt
37
37
 
@@ -42,7 +42,7 @@ end
42
42
  If you want to send every exported output file, then do like this:
43
43
 
44
44
  ```ruby
45
- start do
45
+ play do
46
46
  export format: :html
47
47
  send copy_to: :host1
48
48
 
data/docs/dsl/show.md CHANGED
@@ -5,7 +5,7 @@
5
5
  When all tests are finished, the `show` command displays information on the screen about the final results.
6
6
 
7
7
  ```ruby
8
- start do
8
+ play do
9
9
  show
10
10
  end
11
11
  ```
@@ -18,7 +18,7 @@ end
18
18
  | `show verbose: NUMBER` | NUMBER is the value of the verbose level |
19
19
 
20
20
  ```ruby
21
- start do
21
+ play do
22
22
  show verbose: 1
23
23
  end
24
24
  ```
@@ -57,19 +57,9 @@ Run this command as admin user (member of `admin` group):
57
57
  curl -sL https://raw.githubusercontent.com/teuton-software/teuton/master/install/mac/t-node_install.sh | bash
58
58
  ```
59
59
 
60
- ## 3. Vagrant and Docker installation
60
+ ## 3. Docker installation
61
61
 
62
- Choose this way if you plan to install Teuton into virtual machines or containers, and you are familiar with Vagrant and Docker technologies.
63
-
64
- ## 3.1 Install using Vagrant
65
-
66
- * First, install `Vagrant` and `VirtualBox` on your host.
67
- * Create directory for vagrant project. For example, `mkdir teuton-vagrant`.
68
- * Move into that directory: `cd teuton-vagrant`.
69
- * Choose and download [Vagrantfile](../../install/vagrant).
70
- * Run `vagrant up` to create your Virtual Machine.
71
-
72
- ## 3.2 Install using Docker
62
+ ## 3.1 Installation
73
63
 
74
64
  First:
75
65
  * Install `docker` on your host.
@@ -84,7 +74,7 @@ Run this command to pull **dvarrui/teuton** image from Docker Hub and create "te
84
74
 
85
75
  `docker run --name teuton -v /home/teuton -i -t dvarrui/teuton /bin/bash`
86
76
 
87
- ## 3.2 Rebuild local docker image
77
+ ## 3.3 Rebuild local docker image
88
78
 
89
79
  1. Create Dockerfile like this:
90
80
 
@@ -113,7 +103,7 @@ CMD ["/bin/bash"]
113
103
 
114
104
  ## 4. Source code
115
105
 
116
- If you want to install Teuton by your own, or there are not installation scripts for your OS, and you don't want to use Vagrant then... here you have information how to install all the required packages for Teuton.
106
+ If you want to install Teuton by your own, or there are not installation scripts for your OS, here you have information how to install all the required packages for Teuton.
117
107
 
118
108
  Manual installation:
119
109
  1. Git installation
data/docs/learn/18-log.md CHANGED
@@ -6,6 +6,8 @@
6
6
 
7
7
  ## Example
8
8
 
9
+ * Logging ERROR, WARN and INFO messages.
10
+
9
11
  ```ruby
10
12
  group "Learning about log messages" do
11
13
  log "Using log messages."
@@ -21,46 +23,79 @@ group "Learning about log messages" do
21
23
  end
22
24
  ```
23
25
 
26
+ * Logging an Array config param, and a Hash config param:
27
+
28
+ ```yaml
29
+ ---
30
+ global:
31
+ values1:
32
+ - A1
33
+ - B1
34
+ - C1
35
+ values2:
36
+ p1: A2
37
+ p2: B2
38
+ p3: C2
39
+ cases:
40
+ - tt_members: TOCHANGE
41
+ ```
42
+
43
+ ```ruby
44
+ group "Log: Array, Hash" do
45
+ log "-------------"
46
+ log "Array values : #{get(:values1)}"
47
+ log "Hash values : #{get(:values2)}"
48
+ end
49
+ ```
50
+
24
51
  ## Output
25
52
 
26
53
  Content of `var/18-log/case-01.txt` file.
27
54
 
28
- ```
55
+ ```txt
29
56
  CONFIGURATION
30
- +-------------+-----------+
31
- | tt_members | anonymous |
32
- | tt_sequence | false |
33
- | tt_skip | false |
34
- | tt_testname | 18-log |
35
- +-------------+-----------+
57
+ +----------------+-----------------------------------+
58
+ | tt_config_path | examples/18-log/config.yaml |
59
+ | tt_members | TOCHANGE |
60
+ | tt_script_path | examples/18-log/start.rb |
61
+ | tt_sequence | false |
62
+ | tt_skip | false |
63
+ | values1 | ["A1", "B1", "C1"] |
64
+ | values2 | {:p1=>"A2", :p2=>"B2", :p3=>"C2"} |
65
+ +----------------+-----------------------------------+
36
66
 
37
67
  LOGS
38
- [09:14:22] INFO: Using log messages.
39
- [09:14:22] INFO: uid=1000(david) gid=1000(david) grupos=495(cdrom),493(disk),487(video),474(wheel),464(wireshark),459(docker),456(vboxusers),1000(david)
40
- [09:14:22] ERROR: Problem detected!
41
- [09:14:22] WARN!: This is a warning
42
- [09:14:22] INFO: Hi, there!
68
+ [22:35:04] INFO: Using log messages.
69
+ [22:35:04] INFO: uid=1000(david) gid=1000(david) grupos=1000(david),478(wheel),464(vboxusers),108(libvirt),107(qemu),462(vagrant),460(docker),452(ollama)
70
+ [22:35:04] ERROR: Problem detected!
71
+ [22:35:04] WARN!: This is a warning
72
+ [22:35:04] INFO: Hi, there!
73
+ [22:35:04] INFO: -------------
74
+ [22:35:04] INFO: Array values : ["A1", "B1", "C1"]
75
+ [22:35:04] INFO: Hash values : {:p1=>"A2", :p2=>"B2", :p3=>"C2"}
43
76
 
44
77
  GROUPS
45
78
  - Learning about log messages
46
79
  01 (1.0/1.0)
47
80
  Description : Create user david
48
81
  Command : id david
49
- Duration : 0.002 (local)
82
+ Output : uid=1000(david) gid=1000(david) grupos=1000(david),478(wheel),464(vboxusers),108(libvirt),107(qemu),462(vagrant),460(docker),452(ollama)
83
+ Duration : 0.005 (local)
50
84
  Alterations : find(david) & count
51
- Expected : Greater than 0 (String)
52
- Result : 1 (Integer)
85
+ Expected : Greater than 0
86
+ Result : 1
53
87
 
54
88
  RESULTS
55
89
  +--------------+---------------------------+
56
- | case_id | 01 |
57
- | start_time | 2023-01-26 09:14:22 +0000 |
58
- | finish_time | 2023-01-26 09:14:22 +0000 |
59
- | duration | 0.002012326 |
60
90
  | unique_fault | 0 |
91
+ | case_id | 01 |
92
+ | start_time | 2026-10-12 22:35:04 +0100 |
93
+ | finish_time | 2026-10-12 22:35:04 +0100 |
94
+ | duration | 0.004786563 |
61
95
  | max_weight | 1.0 |
62
96
  | good_weight | 1.0 |
63
- | fail_weight | 0.0 |
97
+ | fail_weight | 0 |
64
98
  | fail_counter | 0 |
65
99
  | grade | 100 |
66
100
  +--------------+---------------------------+
101
+ ```
@@ -43,7 +43,7 @@ Usando la siguiente plantilla de ejemplo de la herramienta Teuton:
43
43
  expect_fail
44
44
  end
45
45
 
46
- start do
46
+ play do
47
47
  show
48
48
  export
49
49
  end
@@ -80,7 +80,7 @@ group "Nginx Web Service Checks" do
80
80
  expect ["Hola Mundo!"]
81
81
  end
82
82
 
83
- start do
83
+ play do
84
84
  show
85
85
  export
86
86
  end
@@ -109,7 +109,7 @@ group "Comprobar el servicio web Nginx" do
109
109
  expect "Hola Mundo!"
110
110
  end
111
111
 
112
- start do
112
+ play do
113
113
  show
114
114
  export
115
115
  end
@@ -129,7 +129,7 @@ end
129
129
  # File: start.rb (Script principal)
130
130
  use "nginx"
131
131
 
132
- start do
132
+ play do
133
133
  show
134
134
  export
135
135
  end
@@ -0,0 +1,31 @@
1
+ class Case
2
+ class Action
3
+ attr_reader :id
4
+ attr_accessor :groupname, :description, :weight, :asset,
5
+ :command, :encoding, :host, :exec, :conn_type, :duration,
6
+ :result, :output, :alterations, :expected, :check
7
+
8
+ def initialize
9
+ @id = 0
10
+ @groupname = nil
11
+ @description = "No description!"
12
+ @weight = 1.0
13
+ end
14
+
15
+ def next
16
+ @id += 1
17
+ self
18
+ end
19
+
20
+ def to_h
21
+ {
22
+ id: id,
23
+ groupname: groupname, description: description, weight: weight, asset: asset,
24
+ command: command, encoding: encoding, host: host, exec: exec,
25
+ conn_type: conn_type, duration: duration,
26
+ result: result, output: output,
27
+ alterations: alterations, expected: expected, check: check
28
+ }
29
+ end
30
+ end
31
+ end
@@ -4,6 +4,7 @@ require_relative "../utils/project"
4
4
  require_relative "../utils/verbose"
5
5
  require_relative "../report/report"
6
6
  require_relative "dsl/all"
7
+ require_relative "action"
7
8
  require_relative "config"
8
9
  require_relative "close"
9
10
  # require_relative "builtin/main"
@@ -20,7 +21,11 @@ class Case
20
21
  # Readed by ExecuteManager
21
22
  attr_reader :id, :config, :uniques, :skip
22
23
 
23
- @@id = "01" # First case ID value
24
+ @current_case_id = "00" # First case ID value
25
+
26
+ def self.next_id
27
+ @current_case_id = @current_case_id.next
28
+ end
24
29
 
25
30
  def initialize(config)
26
31
  @config = Case::Config.new(
@@ -28,9 +33,7 @@ class Case
28
33
  global: Project.value[:global]
29
34
  )
30
35
  @groups = Project.value[:groups]
31
-
32
- @id = @@id
33
- @@id = @@id.next
36
+ @id = Case.next_id
34
37
 
35
38
  # Define Case Report
36
39
  @report = Report.new(@id)
@@ -49,17 +52,10 @@ class Case
49
52
 
50
53
  @unique_values = {}
51
54
  @result = Result.new
52
- @action_counter = 0
53
- @action = {
54
- id: 0,
55
- weight: 1.0,
56
- description: "No description!",
57
- groupname: nil
58
- }
55
+ @action = Action.new
59
56
  @uniques = []
60
57
  @sessions = {} # Store opened sessions for this case
61
58
  @conn_status = {}
62
- tempfile :default
63
59
  end
64
60
 
65
61
  def export(format)
@@ -5,7 +5,7 @@ class Case
5
5
  # Invoked from check_cases!
6
6
 
7
7
  fails = 0
8
- @uniques.each do |key|
8
+ uniques.each do |key|
9
9
  next unless uniques[key].include?(id) && uniques[key].count > 1
10
10
 
11
11
  fails += 1
@@ -15,26 +15,25 @@ module DSL
15
15
  elsif input.instance_of?(String) || input.instance_of?(Regexp) || input.instance_of?(Array)
16
16
  expect_any input
17
17
  else
18
- puts Rainbow("[ERROR] Case expect TypeError: <expect #{input} (#{input.class})>").red
18
+ puts Rainbow("[ERROR] Case expect TypeError: <expect #{input} (#{input.class})>").bright.red
19
19
  end
20
20
  end
21
21
 
22
22
  def expect2(cond, args = {})
23
- @action_counter += 1
24
- @action[:id] = @action_counter
25
- if @result.exitcode < 0
23
+ @action.next
24
+ if @result.exitcode.negative?
26
25
  # When exitcode is less than zero, it is because there has been
27
26
  # an error in the remote connection (SSH or Telnet)
28
- @action[:check] = false
29
- @action[:result] = @action[:output]
27
+ @action.check = false
28
+ @action.result = @action.output
30
29
  else
31
- @action[:check] = cond
32
- @action[:result] = (args[:value] || @result.value)
30
+ @action.check = cond
31
+ @action.result = (args[:value] || @result.value)
33
32
  end
34
33
 
35
- @action[:alterations] = @result.alterations
36
- @action[:expected] = (args[:expected] || @result.expected)
37
- @report.lines << @action.clone
34
+ @action.alterations = @result.alterations
35
+ @action.expected = (args[:expected] || @result.expected)
36
+ @report.lines << @action.to_h
38
37
  weight(1.0)
39
38
 
40
39
  c = Settings.letter[:fail]
@@ -164,8 +164,7 @@ class ExpectSequence
164
164
  elsif value.is_a? Regexp
165
165
  return true << index if value.match(line)
166
166
  else
167
- puts "[ERROR] expect_sequence #{value.class}"
168
- exit 1
167
+ raise Teuton::UnexpectedSequenceTypeError, value.class
169
168
  end
170
169
  false
171
170
  end
@@ -11,9 +11,9 @@ module DSL
11
11
  def macro(name, input = {})
12
12
  macros = Project.value[:macros]
13
13
  unless macros[name]
14
- msg = "DSL '#{name}' not found!"
14
+ msg = "Unknown DSL keyword '#{name}'"
15
15
  log(msg, :error)
16
- Logger.error("ERROR #{msg}")
16
+ Logger.warn("Warn: #{msg}")
17
17
  return
18
18
  end
19
19
  input.each_pair { |k, v| set(k, v) }
@@ -39,6 +39,7 @@ module DSL
39
39
  elsif a[0, 6] == "macro_"
40
40
  return macro a[6, a.size], args
41
41
  end
42
+
42
43
  macro a, args
43
44
  end
44
45
 
@@ -19,13 +19,12 @@ module DSL
19
19
  def goto(host = :localhost, args = {})
20
20
  @result.reset
21
21
  args[:on] = host unless args[:on]
22
- @action[:command] = args[:execute].to_s if args[:execute]
23
- @action[:command] = args[:exec].to_s if args[:exec]
24
- tempfile(args[:tempfile]) if args[:tempfile]
25
- @action[:encoding] = args[:encoding] || "UTF-8"
22
+ @action.command = args[:execute].to_s if args[:execute]
23
+ @action.command = args[:exec].to_s if args[:exec]
24
+ @action.encoding = args[:encoding] || "UTF-8"
26
25
 
27
26
  ExecuteManager.new(self).call(host)
28
- @action[:output] = if @result.content.size < 2
27
+ @action.output = if @result.content.size < 2
29
28
  @result.value.clone
30
29
  else
31
30
  "(#{@result.content.size} lines)"
@@ -11,8 +11,8 @@ module DSL
11
11
  end
12
12
 
13
13
  items = script.split(" ")
14
- if items.size < 1
15
- msg = Rainbow("==> [ERROR] run_script: Incorrect command '#{command}'").red
14
+ if items.empty?
15
+ msg = Rainbow("[ERROR] run_script: Incorrect command '#{command}'").bright.red
16
16
  verboseln(msg)
17
17
  return
18
18
  end
@@ -28,7 +28,7 @@ module DSL
28
28
  command = items.join(" ")
29
29
  run(command, args)
30
30
  else
31
- msg = Rainbow("==> [ERROR] run_script: Incorrect protocol(#{host.protocol})").red
31
+ msg = Rainbow("[ERROR] run_script: Incorrect protocol(#{host.protocol})").bright.red
32
32
  verboseln(msg)
33
33
  end
34
34
  end