lopata 0.1.28 → 0.1.29

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: 72851180980a23d7192519fecc8dd302ec9a792bf634b6b3a6b1903673c81730
4
- data.tar.gz: '0484aa838510d86c1cbb5a002113091aed5634ca866484909e60ed0a926abbb7'
3
+ metadata.gz: e277eccafc077953963f9f6d44543df7c7d7aac695d7871f1a3f3000cfe0685c
4
+ data.tar.gz: 30964380cf628255caa9be854b55809c2c7ac503127ec0791fd563660b8c7384
5
5
  SHA512:
6
- metadata.gz: 6e47235c9aa1b6221e408fb7f951a3cb9f609165a4304a9048bc3c3ad289720c8e26de38331ed8ef086819263bffc8825ee71236875f0e340bc510c515f3ee32
7
- data.tar.gz: a9e5c49e3c2675cac5b4b5d9b82d8cedd2bb44215362fbe32399a95bc6beef546bba2e5c6308c43421edd09a3a9a302ffd73230249a09ed3dd413bdb780c99a9
6
+ metadata.gz: a5716169ab5b7379c999bfeef4a45bf41df5ab7f3c9b3274352c6753fc5e1d0e218e6158a2c86e74704931f832b2ed5a7b49a3886afd3beb2104701beaa903b2
7
+ data.tar.gz: c1eb1c3a3396f3040f72a0133f530214ab49262f92b1c465f0d6f3ed8b0507be59f6eb252a614748ce995e16306f5fa53f4a7aaa5a8d4e3b1122e812e93958fd
@@ -7,7 +7,7 @@ module Lopata
7
7
  class ConsoleOutputObserver < BaseObserver
8
8
  extend Forwardable
9
9
  # @private
10
- attr_reader :output
10
+ attr_reader :output, :statuses
11
11
  # @private
12
12
  def_delegators :output, :puts, :flush
13
13
 
@@ -15,6 +15,10 @@ module Lopata
15
15
  @output = $stdout
16
16
  end
17
17
 
18
+ def started(world)
19
+ @statuses = {}
20
+ end
21
+
18
22
  # @see Lopata::Observers::BaseObserver#finished
19
23
  def finished(world)
20
24
  total = statuses.values.inject(0, &:+)
@@ -104,10 +108,6 @@ module Lopata
104
108
  def indent(cols, text)
105
109
  text.split("\n").map { |line| " " * cols + line }.join("\n")
106
110
  end
107
-
108
- def statuses
109
- @statuses ||= {}
110
- end
111
111
  end
112
112
  end
113
113
  end
@@ -115,6 +115,10 @@ module Lopata
115
115
  to_rerun + get_json("/projects/#{project_code}/builds/#{build_number}/failures.json")
116
116
  end
117
117
 
118
+ def need_run
119
+ get_json("/projects/#{project_code}/builds/#{build_number}/need_run.json")
120
+ end
121
+
118
122
  private
119
123
 
120
124
  def get_json(path)
@@ -159,4 +163,4 @@ module Lopata
159
163
  @backtrace_formatter ||= Lopata::Observers::BacktraceFormatter.new
160
164
  end
161
165
  end
162
- end
166
+ end
data/lib/lopata/runner.rb CHANGED
@@ -9,16 +9,19 @@ require_relative 'condition'
9
9
  module Lopata
10
10
  # @private
11
11
  class Runner < Thor
12
+ class_option :env, default: :qa, aliases: 'e'
13
+ class_option :keep, type: :boolean, aliases: 'k'
14
+
12
15
  desc 'test', 'Run tests'
13
- option :env, default: :qa, aliases: 'e'
14
16
  option :rerun, type: :boolean, aliases: 'r'
15
- option :keep, type: :boolean, aliases: 'k'
16
17
  option :text, aliases: 't'
17
18
  option :list, type: :boolean, aliases: 'l'
18
19
  option :init, type: :boolean, aliases: 'i'
19
20
  def test(*args)
20
21
  trap_interrupt
21
22
  configure_from_options
23
+ add_text_filter(options[:text]) if options[:text]
24
+ add_rerun_filter if options[:rerun]
22
25
  Lopata::Loader.load_shared_steps
23
26
  Lopata::Loader.load_scenarios(*args)
24
27
  if options[:list]
@@ -30,9 +33,32 @@ module Lopata
30
33
  end
31
34
  end
32
35
 
36
+ desc 'suspect', 'Run suspect and not started tests'
37
+ option :skip, type: :numeric, default: 0, aliases: 's'
38
+ option :count, type: :numeric, default: 10, aliases: 'c'
39
+ def suspect(*args)
40
+ trap_interrupt
41
+ configure_from_options
42
+ Lopata::Loader.load_shared_steps
43
+ Lopata::Loader.load_scenarios(*args)
44
+ count = options[:count]
45
+ skip = options[:skip]
46
+ loop do
47
+ need_run = Lopata::Client.new.need_run
48
+ need_run = need_run[skip, count]
49
+ break if need_run.nil?
50
+ world = Lopata::World.new
51
+ world.scenarios.concat(Lopata.world.scenarios.select { |s| need_run.include?(s.title) })
52
+ break if world.scenarios.empty?
53
+ world.notify_observers(:started, world)
54
+ world.scenarios.each { |s| s.run }
55
+ world.notify_observers(:finished, world)
56
+ end
57
+ end
58
+
33
59
  default_task :test
34
60
 
35
- register Generators::App, :new, 'lopata new project-name', 'Init new lopata projects'
61
+ register Generators::App, :new, 'new [project-name]', 'Init new lopata projects'
36
62
 
37
63
  def self.exit_on_failure?
38
64
  true
@@ -46,8 +72,6 @@ module Lopata
46
72
  c.load_environment
47
73
  c.run_before_start_hooks
48
74
  end
49
- add_text_filter(options[:text]) if options[:text]
50
- add_rerun_filter if options[:rerun]
51
75
  end
52
76
 
53
77
  def add_text_filter(text)
@@ -63,12 +63,12 @@ class Lopata::Scenario
63
63
  # @private
64
64
  # Scenario execution and live-cycle information
65
65
  class Execution
66
- attr_reader :scenario, :current_step, :top
66
+ attr_reader :scenario, :current_step, :top, :title, :base_metadata
67
67
 
68
68
  def initialize(title, metadata = {})
69
- @scenario = Lopata::Scenario.new(self)
70
- @top = Lopata::GroupExecution.new(Lopata::TopStep.new(title, metadata: metadata), nil, steps: [])
71
- @current_step = @top
69
+ @title = title
70
+ @base_metadata = metadata
71
+ setup
72
72
  end
73
73
 
74
74
  # Provide a human-readable representation of this class
@@ -82,12 +82,19 @@ class Lopata::Scenario
82
82
  end
83
83
 
84
84
  def run
85
+ setup unless @scenario # for second run if need
85
86
  world.notify_observers(:scenario_started, self)
86
87
  run_step(top)
87
88
  world.notify_observers(:scenario_finished, self)
88
89
  cleanup
89
90
  end
90
91
 
92
+ def setup
93
+ @scenario = Lopata::Scenario.new(self)
94
+ @top = Lopata::GroupExecution.new(Lopata::TopStep.new(title, metadata: base_metadata), nil, steps: [])
95
+ @current_step = @top
96
+ end
97
+
91
98
  def run_step(step)
92
99
  @current_step = step
93
100
  return :skipped if step.skipped?
@@ -135,10 +142,6 @@ class Lopata::Scenario
135
142
  current_step.find_let_method(name)
136
143
  end
137
144
 
138
- def title
139
- top.title
140
- end
141
-
142
145
  def status
143
146
  top.status
144
147
  end
@@ -160,7 +163,6 @@ class Lopata::Scenario
160
163
  end
161
164
 
162
165
  def cleanup
163
- @title = nil
164
166
  @scenario = nil
165
167
  @top = nil
166
168
  @current_step = nil
@@ -1,6 +1,6 @@
1
1
  module Lopata
2
2
  # @private
3
3
  module Version
4
- STRING = '0.1.28'
4
+ STRING = '0.1.29'
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lopata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.28
4
+ version: 0.1.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexey Volochnev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-11 00:00:00.000000000 Z
11
+ date: 2024-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -138,5 +138,5 @@ requirements: []
138
138
  rubygems_version: 3.2.15
139
139
  signing_key:
140
140
  specification_version: 4
141
- summary: lopata-0.1.28
141
+ summary: lopata-0.1.29
142
142
  test_files: []