cem_win_spec 0.1.3 → 0.1.5

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: c59006dbfceccc0e0581630b0091722aa31a5644440bb906572c8429a654c37a
4
- data.tar.gz: 91d3e8e17c961d90e90dd5895376418279062ace8ee3b3327d24a511b7287a98
3
+ metadata.gz: 155b49bb4366a1b2fca4237d9da909e05093d907a5e7ff326f4d7a9c4e75f375
4
+ data.tar.gz: f374c915ab3afcf1636315c02b869fdd4690291070f8429418108d292a922cce
5
5
  SHA512:
6
- metadata.gz: cddc71efc46c8a5a0872ee5670b6bdcff1b77904190e18e87f3fa728f2bdb8c533bef7382e8df918337b87811fc21ac04a4b0bd0f358774911a78279f9709968
7
- data.tar.gz: d52050dd876973fadb74a801b198e88f56341ee125a96a6407594376d6155a3a02a7037576ec10f775346660a7d5fd34ee75e26966ef7011889c45ad968a9e02
6
+ metadata.gz: 5709e80190d88d38826deae83c379a948d5e7de72202891db48b00521801ef56e9718a64c681b17ccc7eb82a275af72c955737fef9ee2ab62a8c1fbdccb0aa51
7
+ data.tar.gz: 3ec1282194e8a3afe8df90e3e13e7bd80428bf9d2a70f7d7b8fe6aea0437460bc3b35e8f7e19e8d3a55ded60076b489b078ba80b551b25aa917ccb9cdc0526d0
data/Gemfile.lock CHANGED
@@ -1,10 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cem_win_spec (0.1.3)
4
+ cem_win_spec (0.1.5)
5
5
  parallel_tests (~> 3.4)
6
6
  puppet_forge (~> 4.1)
7
- tty-spinner (~> 0.9)
8
7
  winrm (~> 2.3)
9
8
  winrm-fs (~> 1.3)
10
9
 
@@ -16,7 +15,7 @@ GEM
16
15
  coderay (1.1.3)
17
16
  diff-lcs (1.5.0)
18
17
  erubi (1.12.0)
19
- faraday (2.7.5)
18
+ faraday (2.7.10)
20
19
  faraday-net_http (>= 2.0, < 3.1)
21
20
  ruby2_keywords (>= 0.0.4)
22
21
  faraday-follow_redirects (0.3.0)
@@ -83,9 +82,6 @@ GEM
83
82
  rubyntlm (0.6.3)
84
83
  rubyzip (2.3.2)
85
84
  semantic_puppet (1.1.0)
86
- tty-cursor (0.7.1)
87
- tty-spinner (0.9.3)
88
- tty-cursor (~> 0.7)
89
85
  unicode-display_width (2.1.0)
90
86
  winrm (2.3.6)
91
87
  builder (>= 2.1.2)
@@ -103,6 +99,7 @@ GEM
103
99
  winrm (~> 2.0)
104
100
 
105
101
  PLATFORMS
102
+ arm64-darwin-22
106
103
  x86_64-darwin-19
107
104
  x86_64-darwin-20
108
105
 
data/cem_win_spec.gemspec CHANGED
@@ -30,7 +30,6 @@ Gem::Specification.new do |spec|
30
30
 
31
31
  spec.add_dependency "winrm", "~> 2.3"
32
32
  spec.add_dependency "winrm-fs", "~> 1.3"
33
- spec.add_dependency "tty-spinner", "~> 0.9"
34
33
  spec.add_dependency "puppet_forge", "~> 4.1"
35
34
  spec.add_dependency "parallel_tests", "~> 3.4"
36
35
  spec.add_development_dependency "pry"
data/exe/cem-win-spec CHANGED
File without changes
@@ -44,7 +44,7 @@ module CemWinSpec
44
44
 
45
45
  def enable_symlinks(**opts)
46
46
  @enable_symlinks ||= new_command('Enable symlinks', **opts) do
47
- remote_exec('fsutil behavior set SymlinkEvaluation L2L:1 R2R:1 L2R:1 R2L:1')
47
+ remote_run('fsutil behavior set SymlinkEvaluation L2L:1 R2R:1 L2R:1 R2L:1')
48
48
  end
49
49
  end
50
50
 
@@ -76,8 +76,13 @@ module CemWinSpec
76
76
 
77
77
  def setup_ruby(**opts)
78
78
  @setup_ruby ||= new_command('Set up ruby', **opts) do
79
- remote_run('bundle config disable_platform_warnings true')
80
- remote_run('bundle install')
79
+ remote_run(
80
+ [
81
+ 'bundle config disable_platform_warnings true',
82
+ 'bundle config set --local without \'local_development\'',
83
+ 'bundle install',
84
+ ],
85
+ )
81
86
  end
82
87
  end
83
88
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CemWinSpec
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.5"
5
5
  end
@@ -22,12 +22,16 @@ module CemWinSpec
22
22
  end
23
23
 
24
24
  def run(cmd, *_args, **_kwargs)
25
+ cmd = cmd.join('; ') if cmd.is_a?(Array)
25
26
  log_command(cmd)
26
27
  shell = nil
27
28
  output = nil
28
29
  begin
29
30
  shell = conn.shell(:powershell)
30
- output = shell.run(command(cmd))
31
+ output = shell.run(command(cmd)) do |stdout, stderr|
32
+ logger << stdout unless stdout.nil? || stdout.empty?
33
+ logger << stderr unless stderr.nil? || stderr.empty?
34
+ end
31
35
  rescue WinRM::WinRMAuthorizationError => e
32
36
  @available = false
33
37
  raise e
@@ -25,7 +25,6 @@ module CemWinSpec
25
25
  add_command_block(&block) unless block.nil?
26
26
  @reuse_tunnel = true
27
27
  @ignore_exitcode = false
28
- @spinner = nil
29
28
  @result = nil
30
29
  end
31
30
 
@@ -96,12 +95,6 @@ module CemWinSpec
96
95
  false
97
96
  end
98
97
 
99
- def spinner=(value)
100
- raise ArgumentError, 'spinner must implement #auto_spin and #stop methods' unless value.respond_to?(:auto_spin) && value.respond_to?(:stop)
101
-
102
- @spinner = value
103
- end
104
-
105
98
  # Proxy method calls for methods that don't exist here to various other objects.
106
99
  # This allows doing things like: `win_exec.remote_exec('Get-Process')` and
107
100
  # calling the `exec` method on the `winrm_exec` object. This is done by
@@ -157,13 +150,10 @@ module CemWinSpec
157
150
  def run(*args, **kwargs)
158
151
  validate_instance_variables
159
152
  logger.info "Running #{@title}"
160
- @spinner&.auto_spin
161
153
  result = run_with_tunnel { run_in_current_scope(*args, **kwargs) }
162
- @spinner&.stop
163
154
  @result = Output.new(result)
164
155
  return if @result.pending_threaded?
165
156
 
166
- @result.puts_combined
167
157
  unless @result.success? || ignore_exitcode?
168
158
  raise "Command failed with exit code #{@result.exitcode}: #{@result.stdout}\n#{@result.stderr}"
169
159
  end
@@ -201,13 +191,6 @@ module CemWinSpec
201
191
  def run_in_current_scope(*args, **kwargs)
202
192
  instance_exec(*args, **kwargs, &@block) # self is the "instance"
203
193
  end
204
-
205
- def wrap_spinner
206
- @spinner.auto_spin if @spinner
207
- yield if block_given?
208
- ensure
209
- @spinner.stop if @spinner
210
- end
211
194
  end
212
195
  end
213
196
  end
@@ -47,7 +47,6 @@ module CemWinSpec
47
47
  wexec.add_command_block(&block)
48
48
  wexec.reuse_tunnel = opts[:reuse_tunnel] if opts.key?(:reuse_tunnel)
49
49
  wexec.ignore_exitcode = opts[:ignore_exitcode] if opts.key?(:ignore_exitcode)
50
- wexec.spinner = opts[:spinner] if opts.key?(:spinner)
51
50
  logger.debug 'Created Wexec'
52
51
  wexec
53
52
  end
data/lib/cem_win_spec.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'tty-spinner'
4
3
  require_relative 'cem_win_spec/logging'
5
4
  require_relative 'cem_win_spec/test_runner'
6
5
 
@@ -39,32 +38,53 @@ module CemWinSpec
39
38
  logger.debug "Created TestRunner: #{runner}"
40
39
  signal_handler(runner)
41
40
  logger.debug 'Set up signal handler'
42
- spinner = TTY::Spinner.new(format: :classic, interval: 1, hide_cursor: true, clear: true)
43
41
  begin
44
- sre_out = setup_remote_environment(runner, spinner)
42
+ sre_out = setup_remote_environment(runner)
45
43
  check_output!(sre_out, runner)
46
44
  module_dir = sre_out.stdout.chomp
47
45
  logger.debug "Module dir: #{module_dir}"
48
- srr_out = setup_remote_ruby(runner, module_dir, spinner, **options)
46
+ srr_out = setup_remote_ruby(runner, module_dir, **options)
49
47
  check_output!(srr_out, runner)
50
48
  case operation
51
49
  when :spec
52
- spec_out = run_spec(runner, module_dir, spinner, **options)
50
+ spec_out = run_spec(runner, module_dir, **options)
53
51
  check_output!(spec_out, runner)
54
52
  when :clean_fixture_cache
55
- clean_fixture_cache_out = clean_fixture_cache(runner, module_dir, spinner, **options)
53
+ clean_fixture_cache_out = clean_fixture_cache(runner, module_dir, **options)
56
54
  check_output!(clean_fixture_cache_out, runner)
57
55
  else
58
56
  raise ArgumentError, "Unknown operation: #{operation}"
59
57
  end
60
58
  rescue StandardError => e
61
- logger.fatal "Error: #{e.message}"
62
- logger.debug e.backtrace.join("\n")
63
- exit 1
59
+ if operation == :spec
60
+ begin
61
+ logger.warn "Error running spec: #{e.message}"
62
+ logger.debug e.backtrace.join("\n")
63
+ retry_spec_on_error(runner, module_dir, **options)
64
+ rescue StandardError => err
65
+ handle_run_error(err)
66
+ end
67
+ else
68
+ handle_run_error(e)
69
+ end
64
70
  end
65
71
  end
66
72
 
67
- def self.setup_remote_environment(runner, spinner)
73
+ def self.handle_run_error(err)
74
+ logger.fatal "Error: #{err.message}"
75
+ logger.debug err.backtrace.join("\n")
76
+ exit 1
77
+ end
78
+
79
+ def self.retry_spec_on_error(runner, module_dir, **options)
80
+ logger.info 'Cleaning cache and trying again...'
81
+ clean_fixture_cache_out = clean_fixture_cache(runner, module_dir, **options)
82
+ check_output!(clean_fixture_cache_out, runner)
83
+ spec_out = run_spec(runner, module_dir, **options)
84
+ check_output!(spec_out, runner)
85
+ end
86
+
87
+ def self.setup_remote_environment(runner)
68
88
  runner.enable_long_paths.run
69
89
  runner.enable_symlinks.run
70
90
  runner.enable_symlinks.run
@@ -74,38 +94,34 @@ module CemWinSpec
74
94
  runner.upload_module(operation_timeout: 300, receive_timeout: 310, working_dir: working_dir).run
75
95
  end
76
96
 
77
- def self.setup_remote_ruby(runner, module_dir, spinner, **opts)
97
+ def self.setup_remote_ruby(runner, module_dir, **opts)
78
98
  runner.setup_ruby(operation_timeout: 300,
79
99
  receive_timeout: 310,
80
100
  working_dir: module_dir,
81
101
  reuse_tunnel: false,
82
- spinner: spinner,
83
102
  **opts).run
84
103
  end
85
104
 
86
105
  # Runs RSpec tests
87
- def self.run_spec(runner, module_dir, spinner, **opts)
88
- #runner.rspec_prep(working_dir: module_dir, reuse_tunnel: false, spinner: spinner).run
106
+ def self.run_spec(runner, module_dir, **opts)
89
107
  runner.rspec_tests_parallel(operation_timeout: 300,
90
108
  receive_timeout: 310,
91
109
  working_dir: module_dir,
92
110
  ignore_exitcode: true,
93
111
  reuse_tunnel: false,
94
- spinner: spinner,
95
112
  **opts).run
96
113
  end
97
114
 
98
115
  # Clean the remote fixture cache
99
116
  # @param options [Hash] Options for the test runner
100
- def self.clean_fixture_cache(runner, module_dir, spinner, **opts)
101
- runner.clean_fixture_cache(working_dir: module_dir, spinner: spinner, **opts).run
117
+ def self.clean_fixture_cache(runner, module_dir, **opts)
118
+ runner.clean_fixture_cache(working_dir: module_dir, **opts).run
102
119
  end
103
120
 
104
121
  def self.check_output!(output, runner = nil)
105
122
  unless output.success?
106
123
  runner&.iap_tunnel&.stop(wait: false, log: false)
107
- logger.fatal "Command failed with exit code #{output.exitcode}"
108
- exit output.exitcode
124
+ raise "Command failed with exit code #{output.exitcode}"
109
125
  end
110
126
  end
111
127
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cem_win_spec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Heston Snodgrass
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-06 00:00:00.000000000 Z
11
+ date: 2023-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: winrm
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.3'
41
- - !ruby/object:Gem::Dependency
42
- name: tty-spinner
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '0.9'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '0.9'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: puppet_forge
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -153,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
139
  - !ruby/object:Gem::Version
154
140
  version: '0'
155
141
  requirements: []
156
- rubygems_version: 3.4.6
142
+ rubygems_version: 3.4.18
157
143
  signing_key:
158
144
  specification_version: 4
159
145
  summary: Write a short summary, because RubyGems requires one.