teuton 2.10.8 → 3.0.0

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 (91) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +373 -674
  3. data/README.md +65 -18
  4. data/docs/commands/README.md +18 -81
  5. data/docs/commands/check.md +66 -0
  6. data/docs/commands/config.md +120 -0
  7. data/docs/commands/help.md +37 -0
  8. data/docs/commands/new.md +34 -0
  9. data/docs/commands/readme.md +52 -0
  10. data/docs/commands/{run-tests.md → run.md} +1 -1
  11. data/docs/config_file.md +125 -0
  12. data/docs/devel/contribute.md +52 -0
  13. data/docs/devel/todo.md +162 -0
  14. data/docs/dsl/expect.md +7 -5
  15. data/docs/dsl/run.md +30 -67
  16. data/docs/install/s-node.md +9 -7
  17. data/docs/install/t-node.md +18 -19
  18. data/docs/learn/11-export.md +1 -1
  19. data/docs/learn/13-feedback.md +1 -1
  20. data/docs/learn/14-moodle_id.md +4 -4
  21. data/docs/learn/15-readme.md +14 -8
  22. data/docs/learn/16-include.md +21 -16
  23. data/docs/learn/17-alias.md +2 -2
  24. data/docs/learn/18-log.md +5 -3
  25. data/docs/learn/19-read_vars.md +7 -3
  26. data/docs/learn/20-macros.md +6 -4
  27. data/docs/learn/21-exit_codes.md +3 -3
  28. data/docs/learn/22-result.md +7 -3
  29. data/docs/learn/23-test-code.md +17 -7
  30. data/docs/learn/24-test-sql.md +19 -18
  31. data/docs/learn/25-expect-result.md +1 -0
  32. data/docs/learn/26-expect_sequence.md +12 -7
  33. data/docs/learn/27-run_script.md +11 -5
  34. data/docs/tutorial/es/nginx/README.md +546 -0
  35. data/lib/teuton/case/case.rb +0 -2
  36. data/lib/teuton/case/dsl/expect.rb +2 -2
  37. data/lib/teuton/case/dsl/log.rb +1 -1
  38. data/lib/teuton/case/dsl/run.rb +2 -3
  39. data/lib/teuton/case/dsl/upload.rb +1 -1
  40. data/lib/teuton/case/execute/execute_base.rb +3 -6
  41. data/lib/teuton/case/execute/execute_local.rb +5 -2
  42. data/lib/teuton/case/execute/execute_ssh.rb +0 -1
  43. data/lib/teuton/case/execute/execute_telnet.rb +0 -2
  44. data/lib/teuton/case/play.rb +2 -2
  45. data/lib/teuton/case/result/result.rb +1 -3
  46. data/lib/teuton/case_manager/case_manager.rb +14 -17
  47. data/lib/teuton/case_manager/dsl.rb +4 -4
  48. data/lib/teuton/case_manager/export_manager.rb +22 -17
  49. data/lib/teuton/case_manager/{check_cases.rb → ext/check_cases.rb} +7 -6
  50. data/lib/teuton/case_manager/ext/hall_of_fame.rb +28 -0
  51. data/lib/teuton/case_manager/{report.rb → ext/report.rb} +6 -8
  52. data/lib/teuton/case_manager/send_manager.rb +1 -0
  53. data/lib/teuton/case_manager/{show_report.rb → show_resume_report.rb} +12 -26
  54. data/lib/teuton/case_manager/stats_manager.rb +26 -0
  55. data/lib/teuton/check/checker.rb +16 -8
  56. data/lib/teuton/check/main.rb +2 -2
  57. data/lib/teuton/check/show.rb +3 -3
  58. data/lib/teuton/cli.rb +3 -2
  59. data/lib/teuton/readme/dsl/getset.rb +1 -0
  60. data/lib/teuton/readme/main.rb +2 -2
  61. data/lib/teuton/readme/readme.rb +2 -2
  62. data/lib/teuton/report/formatter/default/array.rb +1 -3
  63. data/lib/teuton/report/formatter/default/markdown.rb +1 -1
  64. data/lib/teuton/report/formatter/default/txt.rb +1 -1
  65. data/lib/teuton/report/formatter/default/xml.rb +93 -29
  66. data/lib/teuton/report/formatter/formatter.rb +2 -1
  67. data/lib/teuton/report/formatter/resume/array.rb +1 -3
  68. data/lib/teuton/report/formatter/resume/txt.rb +6 -2
  69. data/lib/teuton/report/formatter/resume/xml.rb +92 -0
  70. data/lib/teuton/report/report.rb +1 -1
  71. data/lib/teuton/utils/config_file_reader.rb +141 -0
  72. data/lib/teuton/utils/name_file_finder.rb +12 -15
  73. data/lib/teuton/utils/project.rb +19 -21
  74. data/lib/teuton/utils/settings.rb +3 -1
  75. data/lib/teuton/version.rb +1 -1
  76. data/lib/teuton.rb +11 -10
  77. metadata +37 -32
  78. data/docs/commands/check-example.md +0 -53
  79. data/docs/es/aprender/01-cmd_new.md +0 -27
  80. data/docs/es/aprender/02-target.md +0 -131
  81. data/docs/es/aprender/README.md +0 -36
  82. data/docs/ideas/contributions.md +0 -32
  83. data/docs/ideas/todo.md +0 -44
  84. data/docs/install/README.md +0 -38
  85. data/lib/teuton/case_manager/hall_of_fame.rb +0 -29
  86. data/lib/teuton/files/README.md +0 -9
  87. data/lib/teuton/utils/configfile_reader.rb +0 -135
  88. /data/docs/{ideas → es}/Challenge-Server-Project.md +0 -0
  89. /data/docs/{ideas → es}/servidor-de-retos.md +0 -0
  90. /data/docs/{install/modes_of_use.md → modes_of_use.md} +0 -0
  91. /data/lib/teuton/{case_manager → deprecated}/utils.rb +0 -0
@@ -2,7 +2,9 @@
2
2
 
3
3
  # include
4
4
 
5
- Use `tt-include` to include several config files into your main config file.
5
+ Use `tt-include` configuration param to include several config files into your main config file.
6
+
7
+ ## Description
6
8
 
7
9
  Until now, all the examples we have seen use one configuration file (`config.yaml`) that contain all the parameters required by the test. It is possible to save configuration distributed among several files.
8
10
 
@@ -18,9 +20,11 @@ Suppose we have the following file structure.
18
20
  └── start.rb
19
21
  ```
20
22
 
21
- `config.yaml` will be the main config file. We have defined `tt_include` parameter with a folder wich contains more configuration files.
23
+ `config.yaml` will be the main config file. Then we define `tt_include` parameter with a folder wich contains more configuration files.
24
+
25
+ In this example the contents of all files into `moreconfigfiles` folder will be included when reading the config parameters:
22
26
 
23
- In this example the contents of all files in `moreconfigfiles` folder will be included when reading the config parameters:
27
+ ## Config files
24
28
 
25
29
  ```yaml
26
30
  ---
@@ -30,19 +34,6 @@ In this example the contents of all files in `moreconfigfiles` folder will be in
30
34
  :cases:
31
35
  ```
32
36
 
33
- If we execute the test we will see that 3 cases are processed. Which are defined in the files `file01.yaml`, `02/file02.yaml` and `file03.yml`.
34
-
35
-
36
- ```
37
- CASE RESULTS
38
- +------+---------+-------+-------+
39
- | CASE | MEMBERS | GRADE | STATE |
40
- | 01 | file02 | 0.0 | ? |
41
- | 02 | file01 | 100.0 | ✔ |
42
- | 03 | file03 | 0.0 | ? |
43
- +------+---------+-------+-------+
44
- ```
45
-
46
37
  Config files into `moreconfigfiles` folder:
47
38
 
48
39
  ```yaml
@@ -62,3 +53,17 @@ Config files into `moreconfigfiles` folder:
62
53
  :tt_members: file03
63
54
  :username: vader
64
55
  ```
56
+
57
+ ## Output
58
+
59
+ If we execute the test we will see that 3 cases are processed. Which are defined in the files `file01.yaml`, `02/file02.yaml` and `file03.yml`.
60
+
61
+ ```
62
+ CASE RESULTS
63
+ +------+---------+-------+-------+
64
+ | CASE | MEMBERS | GRADE | STATE |
65
+ | 01 | file02 | 0.0 | ? |
66
+ | 02 | file01 | 100.0 | ✔ |
67
+ | 03 | file03 | 0.0 | ? |
68
+ +------+---------+-------+-------+
69
+ ```
@@ -1,10 +1,10 @@
1
1
  [<< back](README.md)
2
2
 
3
- # Example: 14-alias
3
+ # alias
4
4
 
5
5
  By using aliases we can adapt a configuration file, so that it can be used with many different tests.
6
6
 
7
- ## Exanation
7
+ ## Example
8
8
 
9
9
  Suppose we have a test like the following:
10
10
 
data/docs/learn/18-log.md CHANGED
@@ -1,10 +1,10 @@
1
1
  [<< back](README.md)
2
2
 
3
- # 18-log
3
+ # log
4
4
 
5
- * `log TEXT`, save TEXT into output report.
5
+ `log TEXT`, save TEXT into output report.
6
6
 
7
- Example
7
+ ## Example
8
8
 
9
9
  ```ruby
10
10
  group "Learning about log messages" do
@@ -21,6 +21,8 @@ group "Learning about log messages" do
21
21
  end
22
22
  ```
23
23
 
24
+ ## Output
25
+
24
26
  Content of `var/18-log/case-01.txt` file.
25
27
 
26
28
  ```
@@ -4,7 +4,9 @@
4
4
 
5
5
  To get paramm values from the configuration file we already have the `get` statement. Example, to read `dirname` we do `get(:dirname)`.
6
6
 
7
- **Example 1:** Using `get` to get values.
7
+ ## Example 1: get
8
+
9
+ Using `get` to get/read values from config file.
8
10
 
9
11
  ```ruby
10
12
  # "get(:dirname)" reads dirname var from config file
@@ -15,7 +17,9 @@ To get paramm values from the configuration file we already have the `get` state
15
17
 
16
18
  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
19
 
18
- **Example 2:** Using `_` to read vars.
20
+ ## Example 2: `_VARNAME`
21
+
22
+ Using `_VARNAME` to get/read values from config file.
19
23
 
20
24
  ```ruby
21
25
  # "_dirname" is equivalet to "get(:dirname)"
@@ -26,7 +30,7 @@ Since the "get" instruction is frequently used, It is good to have a fast path.
26
30
 
27
31
  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
32
 
29
- **Example 3:** Using variables.
33
+ ## Example 3: Using variables
30
34
 
31
35
  ```ruby
32
36
  # "dirname" is a variable
@@ -4,7 +4,7 @@
4
4
 
5
5
  Macros is a technique to make it easier to write and reuse code.
6
6
 
7
- **Example**
7
+ ## Example
8
8
 
9
9
  * We start from a set of repeated targets.
10
10
 
@@ -22,7 +22,7 @@ run "id david"
22
22
  expect_one "david"
23
23
  ```
24
24
 
25
- * Define a macro with the repeated block:
25
+ * So we define a macro with the repeated block:
26
26
 
27
27
  ```ruby
28
28
  define_macro "user_exists", :name do
@@ -32,7 +32,7 @@ define_macro "user_exists", :name do
32
32
  end
33
33
  ```
34
34
 
35
- * Replace the previous targets with macro calls. There are 3 ways to invoke the macro:
35
+ * Then replace the previous targets with macro calls.
36
36
 
37
37
  ```ruby
38
38
  user_exists(name: "fran")
@@ -40,7 +40,9 @@ user_exists(name: "root")
40
40
  user_exists(name: "david")
41
41
  ```
42
42
 
43
- **Notice**: There are 3 ways to invoke the macro:
43
+ ## Invoking macros
44
+
45
+ There are 3 ways to invoke the macro:
44
46
 
45
47
  ```ruby
46
48
  user_exists(name: "fran")
@@ -2,9 +2,9 @@
2
2
 
3
3
  # Example: exit_codes
4
4
 
5
- `result` stores information from the last command executed by a "run" action. [Offers many functions](../dsl/definition/result.md)) that transforms output data, and also exitcode is captured.
5
+ `result` stores information from the last command executed by a "run" action. [Offers many functions](../dsl/result.md)) that transforms output data, and also exitcode is captured.
6
6
 
7
- ## Example
7
+ ## Example 1: ok and fail
8
8
 
9
9
  ```ruby
10
10
  target "Exist user root (exit code ok)"
@@ -16,7 +16,7 @@
16
16
  expect_exit 1
17
17
  ```
18
18
 
19
- ## More examples
19
+ ## Example 2: range and array
20
20
 
21
21
  ```ruby
22
22
  target "Using a range"
@@ -4,7 +4,9 @@
4
4
 
5
5
  Sometimes it can be useful to look at the information returned by the "run" command. For this we use the **"result" object**.
6
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.
7
+ ## Example 1
8
+
9
+ 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
10
 
9
11
  ```ruby
10
12
  group "Using result object" do
@@ -18,7 +20,9 @@ group "Using result object" do
18
20
  end
19
21
  ```
20
22
 
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`.
23
+ ## Example 2
24
+
25
+ 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
26
 
23
27
  ```ruby
24
28
  group "Checking users" do
@@ -33,4 +37,4 @@ group "Checking users" do
33
37
  end
34
38
  ```
35
39
 
36
- > More information about [result](../dsl/definition/result.md) keyword.
40
+ > More information about [result](../dsl/result.md) keyword.
@@ -4,10 +4,20 @@
4
4
 
5
5
  Let's test code using teuton.
6
6
 
7
- **Example:**
7
+ ## Exercise
8
8
 
9
- * Ask students to make a program that performs addition and multiplication.
10
- * Define targets `sum` and `mul`:
9
+ Ask students to make a program that performs addition and multiplication.
10
+
11
+ Usage:
12
+ ```
13
+ $ examples/23-test-code/code/math_1.py 3 4
14
+ Sum = 7
15
+ Mul = 12
16
+ ```
17
+
18
+ ## Example
19
+
20
+ Define targets `sum` and `mul`:
11
21
 
12
22
  ```ruby
13
23
  # File: start.rb
@@ -25,7 +35,7 @@ group "Test code example" do
25
35
  end
26
36
  ```
27
37
 
28
- * Define config params:
38
+ Define config params:
29
39
 
30
40
  ```yaml
31
41
  # File: config.yaml
@@ -36,14 +46,14 @@ cases:
36
46
  - tt_members: student_1
37
47
  filename: math_1.py
38
48
  - tt_members: student_2
39
- filename: math_2b.py
49
+ filename: math_2.py
40
50
  ```
41
51
 
42
- * Put students files into `code` folder.
52
+ * Copy students files into `code` subfolder.
43
53
  * Now run Teuton test:
44
54
 
45
55
  ```
46
- teuton examples/23-test-code
56
+ $ teuton examples/23-test-code
47
57
 
48
58
  CASE RESULTS
49
59
  +------+-----------+-------+-------+
@@ -1,14 +1,15 @@
1
1
  [<<back](README.md)
2
2
 
3
- # Test SQL and database
3
+ # Test SQL and database content
4
4
 
5
- **Exercise**
5
+ ## Exercise
6
6
 
7
- * Ask students to make a Sqlite Database. Create a table called `characters` with `name` varchar, and `rol` varchar.
8
- * Database example:
7
+ * Ask students to make a Sqlite Database.
8
+ * Create a table called `characters` with `name` varchar, and `rol` varchar.
9
9
 
10
+ Database example:
10
11
  ```
11
- sqlite3 examples/24-test-sql/database_01.db
12
+ $ sqlite3 examples/24-test-sql/database_01.db
12
13
 
13
14
  sqlite> .schema characters
14
15
  CREATE TABLE characters ( name varchar(255), rol varchar(255));
@@ -17,20 +18,20 @@ sqlite> select * from characters;
17
18
  Obiwan|Jedi
18
19
  ```
19
20
 
20
- * Query example:
21
+ * Ask students to create SQL queries inside a file. For example: select all Jedi characters.
21
22
 
22
23
  ```
23
- cat examples/24-test-sql/query_01.sql
24
+ $ cat examples/24-test-sql/query_01.sql
24
25
 
25
26
  select * from characters where rol='Jedi';
26
27
  ```
27
28
 
28
- **Teuton test**
29
+ ## Teuton test
29
30
 
30
- * Define targets:
31
+ Define targets (start.rb file):
31
32
 
32
33
  ```ruby
33
- group "Test SQL and database" do
34
+ group "Test SQL and database content" do
34
35
  database = "#{get(:folder)}/#{get(:database)}"
35
36
  query = "#{get(:folder)}/#{get(:query)}"
36
37
 
@@ -44,26 +45,26 @@ group "Test SQL and database" do
44
45
  end
45
46
  ```
46
47
 
47
- * Configure params:
48
+ Configure params (config.yaml file):
48
49
 
49
50
  ```yaml
50
51
  ---
51
52
  global:
52
53
  folder: examples/24-test-sql
53
54
  cases:
54
- - tt_members: student_1_name
55
+ - tt_members: student_1
55
56
  database: database_01.db
56
57
  query: query_01.sql
57
58
  ```
58
59
 
59
- **Test output**
60
+ ## Run test
60
61
 
61
62
  ```
62
- teuton examples/24-test-sql
63
+ $ teuton examples/24-test-sql
63
64
 
64
65
  CASE RESULTS
65
- +------+----------------+-------+-------+
66
- | CASE | MEMBERS | GRADE | STATE |
67
- | 01 | student_1_name | 100.0 | ✔ |
68
- +------+----------------+-------+-------+
66
+ +------+-----------+-------+-------+
67
+ | CASE | MEMBERS | GRADE | STATE |
68
+ | 01 | student_1 | 100.0 | ✔ |
69
+ +------+-----------+-------+-------+
69
70
  ```
@@ -21,6 +21,7 @@
21
21
  | expect_exit NUMBER | Exit code is NUMBER |
22
22
  | expect_ok | Exit code 0 |
23
23
  | expect_fail | Exit code > 0 |
24
+ | expect_sequence | Validates sequences |
24
25
 
25
26
  > Learn more about [expect](../dsl/expect.md)
26
27
 
@@ -23,8 +23,7 @@ expect /a.*?b.*?c/
23
23
 
24
24
  > Regular expressions are very powerful but they are also complex to use.
25
25
 
26
- To evaluate the occurrence of a certain sequence that takes place in different lines of the output we will use the new "expect_sequence" instruction.
27
-
26
+ To evaluate the occurrence of a certain sequence that takes place in different lines of the output we use the "expect_sequence" instruction.
28
27
 
29
28
  ```ruby
30
29
  # Example:
@@ -37,11 +36,13 @@ expect_sequence do
37
36
  end
38
37
  ```
39
38
 
40
- > NOTE: expect_sequence can be useful for evaluating iptables firewall configurations where permission assignment order is relevant.
39
+ > NOTE: `expect_sequence` can be useful for evaluating iptables firewall configurations where permission assignment order is relevant.
40
+
41
+ ## Usage
41
42
 
42
- ## Evaluating different sequences
43
+ ### Simple sequence
43
44
 
44
- * **Simple sequence**. Validate sequences where the elements are in order. Use `find` statement to find each element of the sequence.
45
+ Validate sequences where the elements are in order. Use `find` statement to find each element of the sequence.
45
46
 
46
47
  ```ruby
47
48
  # Examples: [A,B,C], [A,s,B,s,C], [x,A,B,s,C,x], etc.
@@ -53,7 +54,9 @@ expect_sequence do
53
54
  end
54
55
  ```
55
56
 
56
- * **Strict sequence**. validate sequences where the elements are in strict consecutive order. First use `find` to find an element in the sequence and then `next_to` for the next element in strict order.
57
+ ### Strict sequence
58
+
59
+ Validate sequences where the elements are in strict consecutive order. First use `find` to find an element in the sequence and then `next_to` for the next element in strict order.
57
60
 
58
61
  ```ruby
59
62
  # Examples: [A,B,C], [x,A,B,C,x], etc.
@@ -65,7 +68,9 @@ expect_sequence do
65
68
  end
66
69
  ```
67
70
 
68
- * **Strict sequence with jumps**. Use `ignore N` to indicate that there are N lines between 2 elements of the sequence.
71
+ ### Strict sequence with jumps
72
+
73
+ Use `ignore N` to indicate that there are N lines between 2 elements of the sequence.
69
74
 
70
75
  ```ruby
71
76
  # Examples: [A,B,s,s,C], [x,A,B,s,s,C,x], etc.
@@ -11,7 +11,7 @@ You know the classic sequence `target/run/expect`, but sometimes you need to run
11
11
 
12
12
  > Example files at [examples/27-run_file](../../examples/27-run_script)
13
13
 
14
- ## Example scripts
14
+ ## Example files
15
15
 
16
16
  Suppose we have the following files:
17
17
  ```
@@ -29,11 +29,13 @@ echo $MESSAGE
29
29
  exit 0
30
30
  ```
31
31
 
32
- ## Usage examples
32
+ ## Usage
33
33
 
34
34
  `run_script` is the DSL keyword in charge of uploading the script to the remote computer and executing it. When invoking run_script we have two styles: compact or separate components. Let's see
35
35
 
36
- **Compact invocation**: The "command" to execute contains the interpreter, the script, and the arguments.
36
+ ### Compact invocation
37
+
38
+ The "command" string executed contains the interpreter, the script, and the arguments. Example: `"bash show.sh Hello"`.
37
39
 
38
40
  ```ruby
39
41
  target "Mode 1: Upload script and execute on remote host"
@@ -41,7 +43,9 @@ run_script "bash show.sh Hello", on: :host1
41
43
  expect "Hello"
42
44
  ```
43
45
 
44
- **Separate components**: pass the name of the script, the interpreter in charge of processing it and its arguments through separate parameters.
46
+ ### Separate components
47
+
48
+ Pass the script name, interpreter, and its arguments using separate parameters.
45
49
 
46
50
  ```ruby
47
51
  target "Mode 2: Upload script and execute on remote host"
@@ -49,12 +53,14 @@ run_script "show.sh", shell: "bash", args: "Hello", on: :host1
49
53
  expect "Hello"
50
54
  ```
51
55
 
56
+ ### Separate components and defaut shell
57
+
52
58
  Or setting shell default value:
53
59
 
54
60
  ```ruby
55
61
  set(:shell, "bash")
56
62
 
57
- target "Mode 2: Upload script and execute on remote host"
63
+ target "Mode 3: Upload script and execute on remote host"
58
64
  run_script "show.sh", args: "Hello", on: :host1
59
65
  expect "Hello"
60
66
  ```