teuton 2.1.10 → 2.1.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 83d8d3b0d1a64b86f4a565eed4570dbf658d3257472623c2f62f17f22ee3b5f5
4
- data.tar.gz: e04f854b375a25f3ca221e425dc318cde2a37719f7569caa78355cb25874971b
3
+ metadata.gz: 44f3001566143676b26e8158eea1da85634bd99235f5bb2c3945b55be7196785
4
+ data.tar.gz: ab250c0be8fe812a5abd50907d5dc92480d8e17925655ddc69754d93ec8968ec
5
5
  SHA512:
6
- metadata.gz: 6169cd172479737fbb4e306ce4b9fe61c69245e5bdf4a757a21d1ab4c99921c364ec971458a59b19aa09a32587db98c99a07ad2650974d996cccf9926490de5e
7
- data.tar.gz: a4ff2da0ae22db62cbf2e4197f53ba4be346f36b535c341cc205f339c9906ed4b0e866048158793cc74395e19c922c0cc792330bd8afe73cfb9796750a314170
6
+ metadata.gz: 32a509c81ccdcdfb097cc20f7edabbecdc21508d1983715b9ba1281624b803c8adc543aa0684706a3a43ab833d6d3cbeb02a75bc01870dce26c5b03c63f3a578
7
+ data.tar.gz: 824cba77a3d8b82e43c74c3750247de3d86e831dfdd90a807145ce1ab4447f0c469a20aca84f632aaed2b1f47f638462c61a1efa7cc67072482f965599a4cdc5
@@ -1,22 +1,14 @@
1
1
  [<< back](../../README.md)
2
2
 
3
3
  1. [Description](#description)
4
- 2. [Usage](#usage)
5
- 3. [Example](#example)
6
- 4. [Formats](#formats)
4
+ 2. [Example](#example)
5
+ 3. [Options](#options)
6
+ 4. [Usage](#usage)
7
7
 
8
8
  ## Description
9
9
 
10
10
  Create reports and save then into `var/TEST-NAME` folder.
11
11
 
12
- ## Usage
13
-
14
- ```ruby
15
- play do
16
- export
17
- end
18
- ```
19
-
20
12
  ## Example
21
13
 
22
14
  Run export and build reports using txt output format by default:
@@ -35,13 +27,28 @@ play do
35
27
  end
36
28
  ```
37
29
 
38
- ## Formats
30
+ ## Options
31
+
32
+ 1. **format**: txt, html, yaml. json, colored_text (txt with colors).
33
+ 2. **preserve**: true, false.
34
+
35
+ ## Usage
39
36
 
40
- | Command | Description |
41
- | ------------------------ | ----------- |
42
- | `export` | Export report files using default ouput format |
43
- | `export :format => :txt` | Export file using TXT ouput format |
44
- | `export :format => :html` | Export file using HTML ouput format |
45
- | `export :format => :yaml` | Export file using YAML ouput format |
46
- | `export :format => :json` | Export file using JSON ouput format |
47
- | `export :format => :colored_text` | Export file using colored TXT ouput format |
37
+ | | Command | Description |
38
+ | -- | ------------------------ | ----------- |
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 |
@@ -14,8 +14,8 @@ Learn how to use Teuton language to write your own tests:
14
14
  - [Example 04 - Use](example-04-use.md)
15
15
  - [Example 05 - Debug](example-05-debug.md)
16
16
  - [Example 06 - Log](example-06-log.md)
17
- - Example 07 - Preserve
18
- - Example 08 - Readme
17
+ - [Example 07 - Readme](example-07-readme.md)
18
+ - [Example 08 - Preserve](example-08-preserve.md)
19
19
  - Example 09 - Macros
20
20
  - Example 10 - Alias
21
21
  - [Example 11 - Create your first test](example-11-first-test.md)
@@ -0,0 +1,59 @@
1
+ [<< back](README.md)
2
+
3
+ 1. [Definition section](#definition-section)
4
+ 2. [Execute command](#execute-command)
5
+ 3. [Result](#result)
6
+
7
+ # Example: learn-07-readme
8
+
9
+ Create README files (with test instructions) from our test definition.
10
+
11
+ > This example is on GitHub repository at `examples/learn-07-readme/`.
12
+
13
+ ## Definition section
14
+
15
+ Take a look at our test definition section (Group):
16
+ ```ruby
17
+ group "Customize readme output" do
18
+ readme "This is our example 07."
19
+ readme "And here we'll see how to use readme keyword"
20
+
21
+ target "Create user david."
22
+ readme "Help: you can use 'useradd' command to create users."
23
+ readme "Remember: Only root is permitted to create new users."
24
+
25
+ run "id david"
26
+ expect "david"
27
+
28
+ end
29
+ ```
30
+
31
+ > In this example, localhost's OS must be GNU/Linux (any other compatible OS) because the command used is `id david`.
32
+
33
+ There exists some `readme` instructions after `group` and `target` lines.
34
+
35
+ ## Execute command
36
+
37
+ To generate automatically a README file from previous test, execute this:
38
+
39
+ ```
40
+ teuton readme example/learn-07-readme > example/learn-07-readme/README.md
41
+ ```
42
+
43
+ ## Result
44
+
45
+ **Let's see the output**: Content of `example/learn-07-readme/README.md` file.
46
+
47
+ ---
48
+ # learn-07-readme
49
+
50
+ ## Customize readme output
51
+
52
+ This is our example 07.
53
+ And here we'll see how to use readme keyword
54
+
55
+ Go to [LOCALHOST](#required-hosts) host, and do next:
56
+ * Create user david.
57
+ * Help: you can use 'useradd' command to create users.
58
+ * Remember: Only root is permitted to create new users.
59
+ ---
@@ -0,0 +1,41 @@
1
+ [<< back](README.md)
2
+
3
+ 1. [Execution section](#execution-section)
4
+ 2. [Result](#result)
5
+
6
+ # Example: learn-08-preserve
7
+
8
+ Older output report files are overwritten with new reports, every time we run teuton test. With `preserve` option we keep copies.
9
+
10
+ > This example is on GitHub repository at `examples/learn-08-preserve/`.
11
+
12
+ ## Execution section
13
+
14
+ Take a look at our test execution section (Play):
15
+ ```ruby
16
+ play do
17
+ show
18
+ export preserve: true
19
+ end
20
+ ```
21
+
22
+ > More information about [export](../dsl/execution/export.md) keyword.
23
+ ## Result
24
+
25
+ Example, executing `teuton run example/learn-08-preserve` twice:
26
+
27
+ ```
28
+ var
29
+ └── learn-08-preserve
30
+ ├── 20200519-113035
31
+ │   ├── case-01.txt
32
+ │   ├── moodle.csv
33
+ │   └── resume.txt
34
+ ├── 20200520-113039
35
+ │   ├── case-01.txt
36
+ │   ├── moodle.csv
37
+ │   └── resume.txt
38
+ ├── case-01.txt
39
+ ├── moodle.csv
40
+ └── resume.txt
41
+ ```
@@ -6,7 +6,7 @@ require 'singleton'
6
6
  class Application
7
7
  include Singleton
8
8
 
9
- VERSION = '2.1.10' # Application version
9
+ VERSION = '2.1.11' # Application version
10
10
  NAME = 'teuton' # Application name
11
11
 
12
12
  attr_reader :letter
@@ -1,24 +1,8 @@
1
1
 
2
- require_relative 'package'
3
- require_relative 'service'
4
- require_relative 'user'
2
+ require_relative 'teuton_host'
5
3
 
6
4
  class Case
7
- def package(param)
8
- @package = @package || Package.new(self)
9
- @package.param = param
10
- @package
11
- end
12
-
13
- def service(param)
14
- @service = @service || Service.new(self)
15
- @service.param = param
16
- @service
17
- end
18
-
19
- def user(param)
20
- @user = @user || User.new(self)
21
- @user.param = param
22
- @user
5
+ def host(host = 'localhost')
6
+ TeutonHost.new(self, host)
23
7
  end
24
8
  end
@@ -1,20 +1,21 @@
1
1
 
2
2
  class Package
3
- attr_accessor :param
4
-
5
- def initialize(parent)
6
- @parent = parent
3
+ def initialize(teuton_host, param)
4
+ @teuton_host = teuton_host
5
+ @parent = teuton_host.parent
6
+ @host = teuton_host.host
7
+ @param = param
7
8
  end
8
9
 
9
10
  def installed?
10
11
  @parent.target("Package #{@param} installed?")
11
- @parent.run "whereis #{@param}"
12
+ @parent.run "whereis #{@param}", on: @host
12
13
  @parent.expect_one [ 'bin', @param ]
13
14
  end
14
15
 
15
16
  def not_installed?
16
17
  @parent.target("Package #{@param} not installed?")
17
- @parent.run "whereis #{@param}"
18
+ @parent.run "whereis #{@param}", on: @host
18
19
  @parent.expect_none [ 'bin' , @param ]
19
20
  end
20
21
  end
@@ -1,32 +1,33 @@
1
1
 
2
2
  class Service
3
- attr_accessor :param
4
-
5
- def initialize(parent)
6
- @parent = parent
3
+ def initialize(teuton_host, param)
4
+ @teuton_host = teuton_host
5
+ @parent = teuton_host.parent
6
+ @host = teuton_host.host
7
+ @param = param
7
8
  end
8
9
 
9
10
  def is_running?
10
11
  @parent.target("Service #{@param} is running?")
11
- @parent.run "systemctl status #{@param}"
12
+ @parent.run "systemctl status #{@param}", on: @host
12
13
  @parent.expect_one ['Active:', 'running' ]
13
14
  end
14
15
 
15
16
  def is_inactive?
16
17
  @parent.target("Service #{@param} is inactive?")
17
- @parent.run "systemctl status #{@param}"
18
+ @parent.run "systemctl status #{@param}", on: @host
18
19
  @parent.expect_one ['Active:', 'inactive' ]
19
20
  end
20
21
 
21
22
  def is_enable?
22
23
  @parent.target("Service #{@param} is enable?")
23
- @parent.run "systemctl status #{@param}"
24
+ @parent.run "systemctl status #{@param}", on: @host
24
25
  @parent.expect_one ['Loaded:', 'enable' ]
25
26
  end
26
27
 
27
28
  def is_disable?
28
29
  @parent.target("Service #{@param} is disable?")
29
- @parent.run "systemctl status #{@param}"
30
+ @parent.run "systemctl status #{@param}", on: @host
30
31
  @parent.expect_one ['Loaded:', 'disable' ]
31
32
  end
32
33
  end
@@ -0,0 +1,28 @@
1
+
2
+ class TeutonFile
3
+ def initialize(teuton_host, param)
4
+ @teuton_host = teuton_host
5
+ @parent = teuton_host.parent
6
+ @result = @parent.result
7
+ @host = teuton_host.host
8
+ @param = param
9
+ end
10
+
11
+ def exist?
12
+ @parent.target("File #{@param} exists?")
13
+ @parent.run "file #{@param}", on: @host
14
+ @parent.expect @result.grep_v('cannot open').grep(@param).count.eq 1
15
+ end
16
+
17
+ def directory?
18
+ @parent.target("File #{@param} is directory?")
19
+ @parent.run "file #{@param}", on: @host
20
+ @parent.expect @result.grep_v('cannot open').grep(@param).grep('directory').count.eq 1
21
+ end
22
+
23
+ def regular?
24
+ @parent.target("File #{@param} is regular?")
25
+ @parent.run "file #{@param}", on: @host
26
+ @parent.expect @result.grep(@param).grep('directory').count.eq 0
27
+ end
28
+ end
@@ -0,0 +1,31 @@
1
+
2
+ require_relative 'teuton_file'
3
+ require_relative 'package'
4
+ require_relative 'service'
5
+ require_relative 'user'
6
+
7
+ class TeutonHost
8
+ attr_reader :parent
9
+ attr_reader :host
10
+
11
+ def initialize(parent, host = 'localhost')
12
+ @parent = parent
13
+ @host = host
14
+ end
15
+
16
+ def file(param)
17
+ TeutonFile.new(self, param)
18
+ end
19
+
20
+ def package(param)
21
+ Package.new(self, param)
22
+ end
23
+
24
+ def service(param)
25
+ Service.new(self, param)
26
+ end
27
+
28
+ def user(param)
29
+ User.new(self, param)
30
+ end
31
+ end
@@ -1,20 +1,21 @@
1
1
 
2
2
  class User
3
- attr_accessor :param
4
-
5
- def initialize(parent)
6
- @parent = parent
3
+ def initialize(teuton_host, param)
4
+ @teuton_host = teuton_host
5
+ @parent = teuton_host.parent
6
+ @host = teuton_host.host
7
+ @param = param
7
8
  end
8
9
 
9
10
  def exists?
10
11
  @parent.target("User #{@param} exists?")
11
- @parent.run "id #{@param}"
12
- @parent.expect_one @param
12
+ @parent.run "id #{@param}", on: @host
13
+ @parent.expect_one [ 'uid=', @param ]
13
14
  end
14
15
 
15
16
  def is_member_of?(groupname)
16
17
  @parent.target("User #{@param} is member of #{groupname}?")
17
- @parent.run "id #{@param}"
18
+ @parent.run "id #{@param}", on: @host
18
19
  @parent.expect_one [@param, groupname]
19
20
  end
20
21
  end
@@ -115,7 +115,7 @@ class Case
115
115
  alias skip? skip
116
116
 
117
117
  ##
118
- # Show case
118
+ # Show case report data on screen
119
119
  def show
120
120
  @report.show
121
121
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  ##
4
- # Case class -> DSL module : log function
4
+ # Define DSL#log function
5
5
  module DSL
6
6
  ##
7
7
  # Record log message
@@ -31,7 +31,9 @@ module DSL
31
31
  # * Invoke macro (assert)
32
32
  def method_missing(method, args = {})
33
33
  a = method.to_s
34
- return instance_eval("get(:#{a[0, a.size - 1]})") if a[a.size - 1] == '?'
34
+ if a.start_with?('_') && a.end_with?('_')
35
+ return instance_eval("get(:#{a[1, a.size - 2]})")
36
+ end
35
37
  return macro a[6, a.size], args if a[0,6]=='macro_'
36
38
  macro a, args
37
39
  end
@@ -1,6 +1,8 @@
1
1
  require_relative '../application'
2
2
  require_relative 'case_manager'
3
3
 
4
+ # Define filename to be used into our test
5
+ # @param filename (String) Filename to be required
4
6
  def use(filename)
5
7
  filename += '.rb'
6
8
  app = Application.instance
@@ -12,17 +14,25 @@ def use(filename)
12
14
  app.uses << File.basename(findfiles.first)
13
15
  end
14
16
 
17
+ # Define macro. That's a name to predefined target-run-expect evaluation.
18
+ # @param name (String) macro name
19
+ # @param block (Block) macro code
15
20
  def define_macro(name, *args, &block)
16
21
  Application.instance.macros[name] = { args: args, block: block }
17
22
  end
18
23
  alias def_macro define_macro
19
24
  alias defmacro define_macro
20
25
 
26
+ # Define a group of tests
27
+ # @param name (String) Group name
28
+ # @param block (Block) Tests code
21
29
  def group(name, &block)
22
30
  Application.instance.groups << { name: name, block: block }
23
31
  end
24
32
  alias task group
25
33
 
34
+ # Start test
35
+ # @param block (Block) Extra code executed at the end.
26
36
  def play(&block)
27
37
  CaseManager.instance.play(&block)
28
38
  end
@@ -9,9 +9,18 @@ module ExportManager
9
9
  # Run export function
10
10
  # @param main_report (Report)
11
11
  # @param cases (Array)
12
- # @param args (Hash) Selected export options
12
+ # @param input (Hash) Selected export options
13
13
  # rubocop: disable Metrics/AbcSize
14
- def self.run(main_report, cases, args)
14
+ def self.run(main_report, cases, input)
15
+ args = {}
16
+ input.each_pair do |key, value|
17
+ if value.class == String
18
+ args[key] = value.to_sym
19
+ else
20
+ args[key] = value
21
+ end
22
+ end
23
+
15
24
  # default :mode=>:all, :format=>:txt
16
25
  format = args[:format] || Application.instance.default[:format]
17
26
  mode = args[:mode] || :all
@@ -31,6 +31,7 @@ module Skeleton
31
31
  items = [
32
32
  { source: 'files/config.yaml', target: 'config.yaml' },
33
33
  { source: 'files/start.rb', target: 'start.rb' }
34
+ # { source: 'files/gitignore', target: '.gitignore' }
34
35
  ]
35
36
  items.each do |item|
36
37
  source = File.join(source_basedir, item[:source])
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teuton
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.10
4
+ version: 2.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Vargas Ruiz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-10 00:00:00.000000000 Z
11
+ date: 2020-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json_pure
@@ -154,11 +154,13 @@ extra_rdoc_files:
154
154
  - README.md
155
155
  - LICENSE
156
156
  - docs/learn/example-03-remote-hosts.md
157
+ - docs/learn/example-07-readme.md
157
158
  - docs/learn/example-05-debug.md
158
159
  - docs/learn/example-02-config.md
159
160
  - docs/learn/example-11-first-test.md
160
161
  - docs/learn/videos.md
161
162
  - docs/learn/example-06-log.md
163
+ - docs/learn/example-08-preserve.md
162
164
  - docs/learn/example-04-use.md
163
165
  - docs/learn/example-01-target.md
164
166
  - docs/learn/README.md
@@ -228,6 +230,8 @@ files:
228
230
  - docs/learn/example-04-use.md
229
231
  - docs/learn/example-05-debug.md
230
232
  - docs/learn/example-06-log.md
233
+ - docs/learn/example-07-readme.md
234
+ - docs/learn/example-08-preserve.md
231
235
  - docs/learn/example-11-first-test.md
232
236
  - docs/learn/videos.md
233
237
  - lib/teuton.rb
@@ -235,11 +239,12 @@ files:
235
239
  - lib/teuton/case_manager/case/builtin/main.rb
236
240
  - lib/teuton/case_manager/case/builtin/package.rb
237
241
  - lib/teuton/case_manager/case/builtin/service.rb
242
+ - lib/teuton/case_manager/case/builtin/teuton_file.rb
243
+ - lib/teuton/case_manager/case/builtin/teuton_host.rb
238
244
  - lib/teuton/case_manager/case/builtin/user.rb
239
245
  - lib/teuton/case_manager/case/case.rb
240
246
  - lib/teuton/case_manager/case/close.rb
241
247
  - lib/teuton/case_manager/case/config.rb
242
- - lib/teuton/case_manager/case/dsl/deprecated.rb
243
248
  - lib/teuton/case_manager/case/dsl/expect.rb
244
249
  - lib/teuton/case_manager/case/dsl/getset.rb
245
250
  - lib/teuton/case_manager/case/dsl/goto.rb
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # DSL#request, DSL#target2
4
- module DSL
5
- def request(text)
6
- raise "Deprecated request #{text}"
7
- # do nothing by now
8
- end
9
-
10
- def command(p_command, args = {})
11
- @action[:command] = p_command
12
- tempfile(args[:tempfile]) if args[:tempfile]
13
- end
14
- end