teuton 2.3.6 → 2.3.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -4
  3. data/bin/teuton +1 -1
  4. data/docs/CHANGELOG.md +8 -0
  5. data/docs/changelog/v2.4.md +16 -0
  6. data/docs/dsl/definition/expect.md +11 -7
  7. data/docs/dsl/definition/result.md +7 -6
  8. data/docs/dsl/definition/run_local.md +0 -1
  9. data/docs/dsl/definition/target.md +1 -1
  10. data/docs/dsl/execution/export.md +14 -16
  11. data/docs/dsl/execution/send.md +1 -1
  12. data/docs/dsl/setting/get.md +5 -5
  13. data/docs/es/exit_code.md +59 -0
  14. data/docs/es/guess_os.md +28 -0
  15. data/docs/{Challenge-Server-Project.md → ideas/Challenge-Server-Project.md} +0 -0
  16. data/docs/{changelog → ideas}/contributions.md +0 -0
  17. data/docs/{changelog → ideas}/ideas.md +0 -0
  18. data/docs/{changelog → ideas}/servidor-de-retos.md +0 -0
  19. data/docs/learn/{example-01-target.md → 01-target.md} +1 -3
  20. data/docs/learn/{example-02-config.md → 02-config.md} +1 -3
  21. data/docs/learn/{example-03-remote-hosts.md → 03-remote_hosts.md} +10 -10
  22. data/docs/learn/{example-04-new-test.md → 04-new_test.md} +8 -16
  23. data/docs/learn/{example-05-use.md → 05-use.md} +1 -3
  24. data/docs/learn/{example-06-debug.md → 06-debug.md} +1 -3
  25. data/docs/learn/{example-07-log.md → 07-log.md} +1 -3
  26. data/docs/learn/{example-08-readme.md → 08-readme.md} +1 -3
  27. data/docs/learn/{example-09-preserve.md → 09-preserve.md} +7 -4
  28. data/docs/learn/10-result.md +36 -0
  29. data/docs/learn/11-moodle_id.md +19 -0
  30. data/docs/learn/12-get_vars.md +37 -0
  31. data/docs/learn/13-include.md +59 -0
  32. data/docs/learn/14-alias.md +47 -0
  33. data/docs/learn/16-exit_codes.md +24 -0
  34. data/docs/learn/README.md +19 -17
  35. data/lib/teuton/application.rb +24 -17
  36. data/lib/teuton/case_manager/case/builtin/main.rb +2 -3
  37. data/lib/teuton/case_manager/case/builtin/package.rb +2 -3
  38. data/lib/teuton/case_manager/case/builtin/service.rb +4 -5
  39. data/lib/teuton/case_manager/case/builtin/teuton_file.rb +3 -4
  40. data/lib/teuton/case_manager/case/builtin/teuton_host.rb +5 -6
  41. data/lib/teuton/case_manager/case/builtin/user.rb +1 -2
  42. data/lib/teuton/case_manager/case/case.rb +27 -27
  43. data/lib/teuton/case_manager/case/close.rb +2 -2
  44. data/lib/teuton/case_manager/case/config.rb +14 -14
  45. data/lib/teuton/case_manager/case/dsl/expect.rb +46 -39
  46. data/lib/teuton/case_manager/case/dsl/goto.rb +2 -2
  47. data/lib/teuton/case_manager/case/dsl/log.rb +5 -6
  48. data/lib/teuton/case_manager/case/dsl/macro.rb +11 -7
  49. data/lib/teuton/case_manager/case/dsl/main.rb +8 -8
  50. data/lib/teuton/case_manager/case/dsl/send.rb +11 -14
  51. data/lib/teuton/case_manager/case/dsl/unique.rb +1 -3
  52. data/lib/teuton/case_manager/case/main.rb +5 -5
  53. data/lib/teuton/case_manager/case/play.rb +1 -1
  54. data/lib/teuton/case_manager/case/result/ext_array.rb +9 -9
  55. data/lib/teuton/case_manager/case/result/ext_compare.rb +44 -58
  56. data/lib/teuton/case_manager/case/result/ext_filter.rb +20 -8
  57. data/lib/teuton/case_manager/case/result/result.rb +19 -18
  58. data/lib/teuton/case_manager/case/runner.rb +53 -60
  59. data/lib/teuton/case_manager/case_manager.rb +15 -15
  60. data/lib/teuton/case_manager/check_cases.rb +1 -4
  61. data/lib/teuton/case_manager/dsl.rb +5 -5
  62. data/lib/teuton/case_manager/export_manager.rb +8 -19
  63. data/lib/teuton/case_manager/hall_of_fame.rb +4 -6
  64. data/lib/teuton/case_manager/main.rb +4 -5
  65. data/lib/teuton/case_manager/report.rb +21 -16
  66. data/lib/teuton/case_manager/show.rb +2 -2
  67. data/lib/teuton/case_manager/utils.rb +13 -14
  68. data/lib/teuton/check/builtin.rb +5 -1
  69. data/lib/teuton/check/dsl.rb +10 -11
  70. data/lib/teuton/check/laboratory.rb +13 -15
  71. data/lib/teuton/check/show.rb +33 -35
  72. data/lib/teuton/cli.rb +31 -35
  73. data/lib/teuton/files/start.rb +3 -6
  74. data/lib/teuton/readme/dsl.rb +12 -6
  75. data/lib/teuton/readme/lang.rb +20 -21
  76. data/lib/teuton/readme/readme.rb +40 -42
  77. data/lib/teuton/report/close.rb +1 -3
  78. data/lib/teuton/report/formatter/array_formatter.rb +28 -39
  79. data/lib/teuton/report/formatter/base_formatter.rb +2 -13
  80. data/lib/teuton/report/formatter/csv_formatter.rb +12 -18
  81. data/lib/teuton/report/formatter/formatter_factory.rb +31 -29
  82. data/lib/teuton/report/formatter/html_formatter.rb +37 -21
  83. data/lib/teuton/report/formatter/json_formatter.rb +2 -8
  84. data/lib/teuton/report/formatter/list_formatter.rb +6 -12
  85. data/lib/teuton/report/formatter/moodle_csv_formatter.rb +3 -6
  86. data/lib/teuton/report/formatter/resume_array_formatter.rb +1 -1
  87. data/lib/teuton/report/formatter/resume_html_formatter.rb +29 -19
  88. data/lib/teuton/report/formatter/resume_json_formatter.rb +2 -3
  89. data/lib/teuton/report/formatter/resume_list_formatter.rb +4 -4
  90. data/lib/teuton/report/formatter/resume_txt_formatter.rb +14 -18
  91. data/lib/teuton/report/formatter/resume_yaml_formatter.rb +1 -9
  92. data/lib/teuton/report/formatter/txt_formatter.rb +19 -20
  93. data/lib/teuton/report/formatter/xml_formatter.rb +29 -37
  94. data/lib/teuton/report/formatter/yaml_formatter.rb +2 -12
  95. data/lib/teuton/report/report.rb +10 -10
  96. data/lib/teuton/report/show.rb +14 -33
  97. data/lib/teuton/skeleton.rb +6 -14
  98. data/lib/teuton/utils/configfile_reader.rb +22 -21
  99. data/lib/teuton/utils/name_file_finder.rb +21 -26
  100. data/lib/teuton/utils/verbose.rb +1 -2
  101. data/lib/teuton/version.rb +3 -4
  102. data/lib/teuton.rb +5 -6
  103. metadata +62 -86
  104. data/bin/check_teuton +0 -41
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a57c245ece6497c75d1132e50cfaa722be5fae7df918ffa8b0af4e109f600cee
4
- data.tar.gz: 8159ac8b86278ada1e0fac691d91b37d146cb5c336ec2f4babe729d8150063ae
3
+ metadata.gz: '0873f32e05d17fdf4c3903594c5e7fa63746afe919b186900ca5e123358ebb08'
4
+ data.tar.gz: fba17dd71e723d555eeca03a671cb2b171a00b4c874d763325e0dd5921162da4
5
5
  SHA512:
6
- metadata.gz: 28594d840fe733c4fbc0d28b6d81610ccea3011c5d8713ac279b85280ece74b74f37670125edab21eae0a1f93c740a882784757c81c792a2327336f03c995233
7
- data.tar.gz: 7f19810c16c1d3ad78b41de32a2b3a6f85dbff280972b9f6193d5b4ab86f470662357c7a29d2f5ae310246b7b6c3dfec3da95f2aab927c6f10e775bed8e0cb77
6
+ metadata.gz: e05506134ae1dc7a4a64b0c519221a466c35ac50b15770bde019cae780f940d244ba522f5a8932791c415ab37e0530741c5f9f894320b148be417a62d2a8dced
7
+ data.tar.gz: 40b76d2fb4de366748e261eb5d8350038ed3bdc7d5d2c2d63c2ce3f81b86886dcd39686c911e75c331c090ddeaadf383136509ed8e3e73b9ff9513265ca0d5f4
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  [![Gem Version](https://badge.fury.io/rb/teuton.svg)](https://badge.fury.io/rb/teuton)
3
3
  ![GitHub](https://img.shields.io/github/license/dvarrui/teuton)
4
- ![Gem](https://img.shields.io/gem/dv/teuton/2.3.1)
4
+ ![Gem](https://img.shields.io/gem/dv/teuton/2.3.7)
5
5
 
6
6
  # TEUTON
7
7
 
@@ -22,8 +22,8 @@ Teuton allow us:
22
22
  # Documentation
23
23
 
24
24
  * [Installation](https://github.com/teuton-software/teuton/tree/master/docs/install/README.md)
25
- 1. Install Ruby on your system.
26
- 1. Install Teuton with `gem install teuton`.
25
+ * Install Ruby on your system.
26
+ * Install Teuton as normal user: `gem install --user-install teuton` (or install as superuser `gem install teuton`).
27
27
  * [Videos, blogs, news](docs/videos.md)
28
28
  * [Learning](docs/learn/README.md)
29
29
  * [Commands](docs/commands/README.md)
@@ -39,4 +39,3 @@ Teuton allow us:
39
39
  # Contact
40
40
 
41
41
  * **Email**: `teuton.software@protonmail.com`
42
- * **Twitter**: `@SoftwareTeuton`
data/bin/teuton CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'teuton/cli'
3
+ require "teuton/cli"
4
4
 
5
5
  CLI.start(ARGV)
data/docs/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ [<< back](../README.md)
2
+
3
+ # Changelog
4
+
5
+ * [version 2.4](changelog/v2.4.md)
6
+ * [version 2.2](changelog/v2.2.md)
7
+ * [version 2.1](changelog/v2.1.md)
8
+ * [version 2.0](changelog/v2.0.md)
@@ -0,0 +1,16 @@
1
+
2
+ ## [2.4.0]
3
+
4
+ New features:
5
+ - Add new DSL keyword: expect_last, expect_fisrt
6
+ - New doc and example: learn-15-exit_codes
7
+ - Remove os gem.
8
+ - Change test output colors to green as use others test tools.
9
+
10
+ Bug fixed:
11
+ - All "expect*" keywords must require 2 arguments. The second is optional.
12
+
13
+ Revise
14
+ - Remove colors to log text
15
+ - teuton readme: macros, getvars, expect_last, expect_first
16
+ - Formatter: xml, csv, list, etc.
@@ -32,13 +32,17 @@ expect 'obiwan' # Expect previous command output contains obiwan text
32
32
 
33
33
  ## Basic
34
34
 
35
- * **expect 'obiwan'**, expect line/s with "obiwan".
36
- * **expect ['obiwan', 'kenobi'**, expect line/s with "obiwan" and kenobi".
37
- * **expect_one 'obiwan'**, expect only one line with "obiwan".
38
- * **expect_one ['obiwan','kenobi']**, expect only one line with "obiwan" and "kenobi".
39
- * **expect_none 'obiwan'**, expect no line with "obiwan".
40
- * **expect_none ['obiwan', 'kenobi']**, expect no line with "obiwan" and "kenobi".
41
- * **expect /Obiwan|obi-wan/**, Expect line/s with Obiwan or obi-wan. This example uses regular expresions.
35
+ | Command | Description |
36
+ | ------- | ----------- |
37
+ | expect "yoda" or expect_any "yoda" | one or more line/s with "yoda" |
38
+ | expect ["obiwan", "kenobi"] | one or more line/s with "obiwan" and kenobi" |
39
+ | expect_first "episode" | the first line with "episode" |
40
+ | expect_last "episode" | the last line with "episode" |
41
+ | expect_one "rogue" | only one line with "rogue" |
42
+ | expect_one ["obiwan","kenobi"] | only one line with "obiwan" and "kenobi" |
43
+ | expect_none "vader"| no line with "vader" |
44
+ | expect_none ["darth", "vader"] | no line with "darth" and "vader" |
45
+ | expect /Obiwan\|obi-wan/ | one or more line/s with Obiwan or obi-wan. This example uses regular expresions. |
42
46
 
43
47
  ## Advanced
44
48
 
@@ -68,21 +68,22 @@ result.grep_v("nologin").grep("/bin/bash").count.gt 0
68
68
 
69
69
  | Function | VALUE type | Description |
70
70
  | -------------------- | ----------- | ------------------------------------- |
71
+ | `result.count` | | Count lines from result and save this number into result object. |
72
+ | `result.first` | | Remove all lines except first one.|
71
73
  | `result.find(VALUE)` | String | Filter lines that contains VALUE text |
72
74
  | | RegExp | Filter lines that match VALUE regexp. For example `/?ello]`, filter lines with "Hello" or "hello" |
73
75
  | | Array | Apply filter to every array element. For example `["Hi","Hello"]`, filter lines with "Hi" or "Hello". |
74
- | `result.grep(VALUE)` | | Same as find |
76
+ | `result.grep(VALUE)` | String, RegExp, Array | Same as find |
77
+ | `result.grep_v(VALUE)` | String, RegExp, Array | Same as not_find |
78
+ | `result.last` | | Remove all lines except last one.|
75
79
  | `result.not_find(VALUE)` | | Filter lines that not contains VALUE. VALUE may be String, Regular Expresion or an Array. |
76
- | `result.grep_v(VALUE)` | | Same as not_find |
77
- | `result.count` | | Count lines from result and save this number into result object. |
78
80
  | `result.restore` | | Restore result data. After every filtering action result is modified, but this function restore data to their original state. |
79
81
 
80
82
  **Information functions:**
81
83
 
82
84
  | Function | Description |
83
85
  | -------------------- | --------------------------------- |
84
- | `result.exitstatus` | Return exit code from the last command executed by run statement |
85
- | `result.value` | Return first output line or value |
86
- | `result.content` | Return all output lines |
87
86
  | `result.alterations` | Return transformations applied to the output |
87
+ | `result.content` | Return all output lines |
88
88
  | `result.debug` | Print the result content on screen. Usefull for debugging process |
89
+ | `result.value` | Return first output line or value |
@@ -21,7 +21,6 @@ In fact it's the same as doing next:
21
21
 
22
22
  ```ruby
23
23
  run "COMMAND", on: :localhost
24
- run "COMMAND", :on => :localhost
25
24
  ```
26
25
 
27
26
  ## Example
@@ -22,7 +22,7 @@ target "Write here your description"
22
22
  By default weight is 1.0, but it's posible specified other value:
23
23
 
24
24
  ```ruby
25
- target "Write here your description", :weight => 2.5
25
+ target "Write here your description", weight: 2.5
26
26
  ```
27
27
 
28
28
  ## [DEPRECATED] Alias
@@ -23,7 +23,7 @@ Run test and build reports using `html` output format:
23
23
 
24
24
  ```ruby
25
25
  play do
26
- export :format => :html
26
+ export format: :html
27
27
  end
28
28
  ```
29
29
 
@@ -37,18 +37,16 @@ end
37
37
  | | Command | Description |
38
38
  | -- | ------------------------ | ----------- |
39
39
  | 01 | `export` | Export report files using default ouput format |
40
- | 02 | `export :format => :txt` | Export file using TXT ouput format |
41
- | 03 | `export :format => :html` | Export file using HTML ouput format |
42
- | 04 | `export :format => :yaml` | Export file using YAML ouput format |
43
- | 05 | `export :format => :json` | Export file using JSON ouput format |
44
- | 06 | `export :format => :colored_text` | Export file using colored TXT ouput format |
45
- | 07 | `export :preserve => true` | Same as 01 example buy preserving report copies |
46
- | 08 | `export :format => :html, :preserve => true` | Same as 03 example but preserving report copies |
47
- | 09 | `export format: :html, preserve: true` | Same as 08 example |
48
- | 12 | `export format: "txt"` | Same as 02 |
49
- | 13 | `export format: "html"` | Same as 03 |
50
- | 14 | `export format: "yaml"` | Same as 04 |
51
- | 15 | `export format: "json"` | Same as 05 |
52
- | 16 | `export format: "colored_text"` | Same as 06 |
53
- | 17 | `export preserve: true` | Same as 07 |
54
- | 18 | `export format: "html", preserve: true` | Same as 08 |
40
+ | 02 | `export format: :txt` | Export file using TXT ouput format |
41
+ | 03 | `export format: :html` | Export file using HTML ouput format |
42
+ | 04 | `export format: :yaml` | Export file using YAML ouput format |
43
+ | 05 | `export format: :json` | Export file using JSON ouput format |
44
+ | 06 | `export format: :colored_text` | Export file using colored TXT ouput format |
45
+ | 07 | `export preserve: true` | Same as 01 example buy preserving report copies |
46
+ | 08 | `export format: :html, preserve: true` | Same as 03 example but preserving report copies |
47
+ | 09 | `export format: "txt"` | Same as 02 |
48
+ | 10 | `export format: "html"` | Same as 03 |
49
+ | 11 | `export format: "yaml"` | Same as 04 |
50
+ | 12 | `export format: "json"` | Same as 05 |
51
+ | 13 | `export format: "colored_text"` | Same as 06 |
52
+ | 14 | `export format: "html", preserve: true` | Same as 08 |
@@ -14,7 +14,7 @@
14
14
  ```ruby
15
15
  start do
16
16
  export
17
- send :copy_to => :host1
17
+ send copy_to: :host1
18
18
  end
19
19
  ```
20
20
 
@@ -37,16 +37,16 @@ Supossing we are **case 01**, then:
37
37
  **Writting example**: We also can create new temporal params:
38
38
 
39
39
  ```ruby
40
- set(:greet, "Hello")
41
- var = get(:greet)
40
+ set(:name, "Obiwan")
41
+ var = get(:name)
42
42
  ```
43
43
 
44
- So `var` value is "Hello".
44
+ So `var` value is "Obiwan".
45
45
 
46
46
  **Simpler reading example**: Other ways or reading param values:
47
47
 
48
48
  ```ruby
49
- var = greet?
49
+ var = _name
50
50
  ```
51
51
 
52
- So `var` value is "Hello" too. `greet?` is an alias of `get(:greet)`.
52
+ So `var` value is "Obiwan" too. `_name` is an alias of `get(:name)`.
@@ -0,0 +1,59 @@
1
+
2
+ # Exit code
3
+
4
+ ## Introducción
5
+
6
+ Exit code o código de salida es un valor numérico que devuelven los programas cuando terminan su ejecución. Por defecto, el valor 0 indica que el programa/comando ha terminado correctamente. Un valor distinto de cero indica que ha ocurrido alguna situación inesperada o error, y su significado dependerá de cada programa concreto.
7
+
8
+ En SO GNU/Linux para consultar por terminal este valor hacemos `echo $?`. Veamos dos ejemplos:
9
+
10
+ * Ejemplo que termina correctamente:
11
+ ```
12
+ > id root
13
+ uid=0(root) gid=0(root) grupos=0(root)
14
+ > echo $?
15
+ 0
16
+ ```
17
+
18
+ * Ejemplo que termina con error:
19
+ ```
20
+ > id vader
21
+ id: «vader»: no existe ese usuario
22
+ > echo $?
23
+ 1
24
+ ```
25
+
26
+ ## Solicitud de nueva feature
27
+
28
+ Se nos ha solicitado incorporar en `Teuton` la opción de leer no sólo la salida del comando que se ejecuta con la instrucción `run`, sino también el valor devuelto por el **exit code** del mismo.
29
+
30
+ De momento no está implementado porque la forma de leer el valor exit code es diferente en cada SO, y `Teuton` (de momento) no tiene capacidad de "adivinar" el SO del host que se está monitorizando/evaluando.
31
+
32
+ > NOTA: Estamos trabajando en adivinar el SO de host con la nueva herramienta [guess_os](https://rubygems.org/gems/guess_os), pero todavía está un poco "verde".
33
+
34
+ _¿Cómo solucionamos el problema de leer el exit code en Teuton?_
35
+
36
+ ## Propuesta
37
+
38
+ De momento hacemos la siguiente propuesta (hay varias formas de afrontarlo) para leer el exit code con `Teuton`.
39
+
40
+ > NOTA: Para hacerlo todo más sencillo hemos creado dos instrucciones nuevas `expect_last` y `expect_first`.
41
+
42
+ * Veamos un ejemplo que devuelve 0:
43
+ ```ruby
44
+ target "Exist user root"
45
+ run "id root;echo $?"
46
+ expect_last "0"
47
+ ```
48
+ * Veamos un ejemplo que devuelve 1:
49
+ ```ruby
50
+ target "Exist user vader"
51
+ run "id vader;echo $?"
52
+ expect_last "1"
53
+ ```
54
+
55
+ > https://github.com/teuton-software/teuton/blob/master/docs/learn/example-15-exit_codes.md
56
+
57
+ ## Observaciones
58
+
59
+ Estos ejemplos se probaron en GNU/Linux pero para que sirvan en Windows, etc, hay que cambiar `echo $?` por su equivalente en cada SO.
@@ -0,0 +1,28 @@
1
+
2
+ # guess_os: Adivinar el sistema operativo
3
+
4
+ ## Situación actual
5
+
6
+ Cuando usamos `Teuton`, escribimos comandos que se ejecutarán en el host que deseamos monitorizar/evaluar. Estos comandos sabemos cómo escribirlos porque conocemos de antemano el SO de nuestro host.
7
+
8
+ `Teuton` (de momento) no tiene la capacidad de "adivinar" el SO del host, ni aún conociéndolo, tampoco tiene el conocimiento para saber qué comandos son válidos para cada SO, ni cómo convertir comandos de un SO en otro.
9
+
10
+ ## Propuesta
11
+
12
+ A pesar de todo, al recibir solicitudes en esta línea nos hemos puesto a trabajar en un módulo para intentar "adivinar" el SO de una máquina local o remota(SSH), y hemos creado [guess_os](https://rubygems.org/gems/guess_os).
13
+
14
+ Es la primera versión y de momento sólo reconoce correctamente algunos SO/versiones pero no todos. Tiene mucho que mejorar y por este motivo les pedimos un poco de colaboración (sólo te llevará unos minutos).
15
+
16
+ 1. Instalar `guess_os` en tu equipo (`gem install --user-install guess_os`).
17
+ 2. Ejecutar el comando `guess_os`.
18
+ 3. Pulsar ENTER en la pregunta de IP, para adivinar el SO de la máquina local (localhost).
19
+ * Si el resultado devuelto coincide con la realidad ¡Estupendo! Ya puedes desintalar la gema si quieres (`gem uninstall guess_os`) o la puedes seguir probando y reportarnos fallos/ideas/mejoras/etc.
20
+ * Si el resultado devuelto NO coincide con lo que debe salir... entonces envíanos los datos de tu sistema y los que devuelve `guess_os` para ir mejorando esta herramienta.
21
+
22
+ ¡Gracias!
23
+
24
+ ```
25
+ Contacto
26
+ email : teuton.software@protonmail.com
27
+ Telegram : @TeutonSoftware
28
+ ```
File without changes
File without changes
File without changes
@@ -1,8 +1,6 @@
1
1
  [<< back](README.md)
2
2
 
3
- # Example: learn-01-target
4
-
5
- > This example is on GitHub repository at `examples/learn-01-target/`.
3
+ # Example: 01-target
6
4
 
7
5
  Let's learn how to create our first target.
8
6
  A target is a feature you want to measure or check.
@@ -1,8 +1,6 @@
1
1
  [<< back](README.md)
2
2
 
3
- # Example: learn-02-config
4
-
5
- > This example is on GitHub repository at `examples/learn-02-config`.
3
+ # Example: 02-config
6
4
 
7
5
  * Learn how to use config file.
8
6
  * Use params defined into config files.
@@ -1,8 +1,6 @@
1
1
  [<< back](README.md)
2
2
 
3
- # Example: learn-03-remote-hosts
4
-
5
- > This example is on GitHub repository at `examples/learn-03-remote-hosts`.
3
+ # Example: 03-remote-hosts
6
4
 
7
5
  Summary:
8
6
  * Check a group of remote hosts.
@@ -47,7 +45,6 @@ Define 3 targets (items to be checked):
47
45
 
48
46
  ```ruby
49
47
  group "How to test remote Windows hosts" do
50
-
51
48
  target "Update hostname with #{gett(:host1_hostname)}"
52
49
  run "hostname", on: :host1
53
50
  expect_one get(:host1_hostname)
@@ -59,7 +56,6 @@ group "How to test remote Windows hosts" do
59
56
  target "Create user #{gett(:username)}"
60
57
  run "net user", on: :host1
61
58
  expect get(:username)
62
-
63
59
  end
64
60
  ```
65
61
 
@@ -71,15 +67,19 @@ end
71
67
  play do
72
68
  show
73
69
  # export using other output formats
74
- export :format => :txt
75
- export :format => :json
76
- send :copy_to => :host1
70
+ export format: :txt
71
+ export format: :html
72
+ send copy_to: :host1
77
73
  end
78
74
  ```
79
75
 
80
76
  * `show`, show process log on screen.
81
- * `export :format => :json`, create output reports into `var/learn-03-remote-host/` directory. We can use diferents format to export: txt, colored_text, json and yaml.
82
- * `send :copy_to => :host1` keyword copy output report into remote machine (host1).
77
+ * `export format: :txt`, create output reports files into `var/learn-03-remote-host/` directory using `txt` format.
78
+ * `export format: :html`, create output reports into `var/learn-03-remote-host/` directory using `html` format.
79
+
80
+ > Several output formats available: txt, colored_text, html, json and yaml.
81
+
82
+ * `send copy_to: :host1` keyword copy output report into remote machine (host1).
83
83
 
84
84
  ## Results
85
85
 
@@ -1,9 +1,7 @@
1
1
 
2
2
  [<< back](README.md)
3
3
 
4
- # Example: learn-04-new-test
5
-
6
- > This example is on GitHub repository at `examples/learn-04-new-test`.
4
+ # Example: 04-new_test
7
5
 
8
6
  Steps:
9
7
  1. Create skeleton
@@ -41,12 +39,10 @@ This command will create:
41
39
  Write your own targets using the keywords: `target`, `run` and `expect`. Let's see:
42
40
 
43
41
  ```ruby
44
- group "Demo group" do
45
-
46
- target "Exist </home/david> directory"
47
- run "file /home/david", :on => :host1
48
- expect ["/home/david", "directory"]
49
-
42
+ group "Create new test" do
43
+ target "Exist </home/vader> directory"
44
+ run "file /home/vader", on: :host1
45
+ expect_none "No such file or directory"
50
46
  end
51
47
  ```
52
48
 
@@ -54,12 +50,10 @@ The above example checks if exists '/home/david' directory, into *host1* device.
54
50
 
55
51
  > Let's see the keywords used:
56
52
  >
57
- > * `target "Exist </home/david> directory"`, Describe the target with our words, so every one could easily understand what we are trying
53
+ > * `target "Exist </home/vader> directory"`, Describe the target with our words, so every one could easily understand what we are trying
58
54
  to check.
59
- > * `run "file /home/david", :on => :host1`, : Execute the command into the remote machine (host1).
60
- > * `expect ["/home/david", "directory"]`: Compare command ouput with our expectations.
61
-
62
- ---
55
+ > * `run "file /home/vader", on: :host1`, : Execute the command into the remote machine (host1).
56
+ > * ` expect_none "No such file or directory"`: Compare command ouput with our expectations.
63
57
 
64
58
  ## STEP 3: Personalize Configfile
65
59
 
@@ -82,8 +76,6 @@ Use a YAML file (`foo/config.yaml`) or JSON for your own configurations. In this
82
76
 
83
77
  > The above file configures 2 differents cases with their own params. The script use this information when execute every case.
84
78
 
85
- ---
86
-
87
79
  ## STEP 4: run the challenge
88
80
 
89
81
  Now we only have to run the challenge:
@@ -1,8 +1,6 @@
1
1
  [<< back](README.md)
2
2
 
3
- # Example: learn-05-use
4
-
5
- > This example is on GitHub repository at `examples/learn-05-use`.
3
+ # Example: 05-use
6
4
 
7
5
  Learn how to:
8
6
  * Organize huge amount of groups/targets into several files.
@@ -1,9 +1,7 @@
1
1
 
2
2
  [<< back](README.md)
3
3
 
4
- # Example: learn-06-debug
5
-
6
- > This example is on GitHub repository at `examples/learn-06-debug`.
4
+ # Example: 06-debug
7
5
 
8
6
  Learn how to:
9
7
  * Check test syntax.
@@ -1,8 +1,6 @@
1
1
  [<< back](README.md)
2
2
 
3
- # Example: learn-07-log
4
-
5
- > This example is on GitHub repository at `examples/learn-06-log/`.
3
+ # Example: 07-log
6
4
 
7
5
  Let's learn how to create log messages.
8
6
 
@@ -1,8 +1,6 @@
1
1
  [<< back](README.md)
2
2
 
3
- # Example: learn-07-readme
4
-
5
- > This example is on GitHub repository at `examples/learn-08-readme/`.
3
+ # Example: 07-readme
6
4
 
7
5
  Create README files (with test instructions) from our test definition.
8
6
 
@@ -1,10 +1,10 @@
1
1
  [<< back](README.md)
2
2
 
3
- # Example: learn-09-preserve
3
+ # Example: 09-preserve
4
4
 
5
- > This example is on GitHub repository at `examples/learn-09-preserve/`.
5
+ Every time we run teuton test, older output report files are overwritten with new reports. if you want to preserve old versions then use `preserve`.
6
6
 
7
- Older output report files are overwritten with new reports, every time we run teuton test. With `preserve` option we keep copies.
7
+ With `preserve` option we keep older copies.
8
8
 
9
9
  1. [Execution section](#execution-section)
10
10
  2. [Result](#result)
@@ -20,6 +20,7 @@ end
20
20
  ```
21
21
 
22
22
  > More information about [export](../dsl/execution/export.md) keyword.
23
+
23
24
  ## Result
24
25
 
25
26
  Example, executing `teuton run example/learn-09-preserve` twice:
@@ -31,7 +32,7 @@ var
31
32
  │   ├── case-01.txt
32
33
  │   ├── moodle.csv
33
34
  │   └── resume.txt
34
- ├── 20200520-113039
35
+ ├── 20200519-123039
35
36
  │   ├── case-01.txt
36
37
  │   ├── moodle.csv
37
38
  │   └── resume.txt
@@ -39,3 +40,5 @@ var
39
40
  ├── moodle.csv
40
41
  └── resume.txt
41
42
  ```
43
+
44
+ * The first time test was launched at 11:30, and second at 12:30 the same day.
@@ -0,0 +1,36 @@
1
+ [<< back](README.md)
2
+
3
+ # Example: 10-result
4
+
5
+ Sometimes it can be useful to look at the information returned by the "run" command. For this we use the **"result" object**.
6
+
7
+ **Example 1:** In this example we run the "hostname" command on the machine and capture its output using "result". We'll use that value to make sure there isn't a user named as host name.
8
+
9
+ ```ruby
10
+ group "Using result object" do
11
+ # Capturing hostname value
12
+ run "hostname"
13
+ hostname = result.value
14
+
15
+ target "No #{hostname} user"
16
+ run "id hostname"
17
+ expect_none hostname
18
+ end
19
+ ```
20
+
21
+ **Example 2:** When we are debugging our test and we want to see the content of the "result" object on the screen, we will use `result.debug`.
22
+
23
+ ```
24
+ group "Checking users" do
25
+ users = ["root", "vader"]
26
+
27
+ users.each do |name|
28
+ target "Exists username #{name}"
29
+ run "id #{name}"
30
+ result.debug
31
+ expect "(#{name})"
32
+ end
33
+ end
34
+ ```
35
+
36
+ > More information about [result](../dsl/definition/result.md) keyword.
@@ -0,0 +1,19 @@
1
+ [<< back](README.md)
2
+
3
+ # Example: 11-moodle_id
4
+
5
+ If you are a teacher and are using the Moodle platform, probably you will want to upload the results of the evaluation carried out by Teuton in Moodle.
6
+
7
+ Teuton generates a file called "moodle.csv" with the grades of each student. Only have to import the file into Moodle.
8
+
9
+ In the configuration file "config.yaml" add a field called "moodle_id" to each case. Fill it with the student's identification (For example, the email registered on the Moodle).
10
+
11
+ Example:
12
+ ```
13
+ global:
14
+ cases:
15
+ - tt_members: Darth Vader
16
+ tt_moodle_id: vader@starwars.com
17
+ - tt_members: Obiwan Kenobi
18
+ tt_moodle_id: obiwan@starwars.com
19
+ ```
@@ -0,0 +1,37 @@
1
+ [<< back](README.md)
2
+
3
+ # Example: 12-get_vars
4
+
5
+ To read the variables from the configuration file we already have the `get` statement. Example, to read `dirname` we do `get(:dirname)`.
6
+
7
+ **Example 1:** Using `get` to read vars.
8
+
9
+ ```ruby
10
+ # "get(:dirname)" reads dirname var from config file
11
+ target "Exist #{get(:dirname)} directory"
12
+ run "file #{get(:dirname)}"
13
+ expect_none "No such file or directory"
14
+ ```
15
+
16
+ Since the "get" instruction is frequently used, It is good to have a fast path. Let's see another shorter way to read variables using the "_" operator.
17
+
18
+ **Example 2:** Using `_` to read vars.
19
+
20
+ ```ruby
21
+ # "_dirname" is equivalet to "get(:dirname)"
22
+ target "Exist #{_dirname} directory"
23
+ run "file #{_dirname}"
24
+ expect_none "No such file or directory"
25
+ ```
26
+
27
+ The Teuton language is a DSL built on top of the Ruby programming language, so we can also use variables like any programming language.
28
+
29
+ **Example 3:** Using variables.
30
+
31
+ ```ruby
32
+ # "dirname" is a variable
33
+ dirname = get(:dirname)
34
+ target "Exist #{dirname} directory"
35
+ run "file #{dirname}"
36
+ expect_none "No such file or directory"
37
+ ```