Class: CemWinSpec::TestRunner
- Inherits:
-
Object
- Object
- CemWinSpec::TestRunner
show all
- Includes:
- Logging
- Defined in:
- lib/cem_win_spec/test_runner.rb
Overview
Class for running tests on a remote Windows host
Constant Summary
Constants included
from Logging
Logging::LEVEL_MAP
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Logging
#current_log_format, current_log_format, current_log_level, #current_log_level, included, log_setup!, #log_setup!, logger, #logger, new_log_formatter, #new_log_formatter, new_log_level, #new_log_level
Constructor Details
Returns a new instance of TestRunner.
Instance Attribute Details
#iap_tunnel ⇒ Object
Returns the value of attribute iap_tunnel.
17
18
19
|
# File 'lib/cem_win_spec/test_runner.rb', line 17
def iap_tunnel
@iap_tunnel
end
|
Instance Method Details
#clean_fixture_cache(**opts) ⇒ Object
111
112
113
114
115
|
# File 'lib/cem_win_spec/test_runner.rb', line 111
def clean_fixture_cache(**opts)
@clean_cache ||= new_command('Clean fixture cache', **opts) do
remote_run('bundle exec rake cem_win_spec:clean_fixture_cache')
end
end
|
#clean_up(working_dir) ⇒ Object
101
102
103
104
105
106
107
108
109
|
# File 'lib/cem_win_spec/test_runner.rb', line 101
def clean_up(working_dir)
@clean_up ||= new_command('Cleanup') do |working_dir|
if remote_available?
remote_run(cleanup_cmd, working_dir, quiet: true)
else
logger.warn 'Cleanup not available'
end
end
end
|
#create_working_dir(**opts) ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/cem_win_spec/test_runner.rb', line 43
def create_working_dir(**opts)
@create_working_dir ||= new_command('Create working directory', **opts) do
dir_name = if remote_conn_opts.user.nil?
"cem_windows_#{Time.now.to_i}"
else
"cem_windows_#{remote_conn_opts.user}_#{Time.now.to_i}"
end
work_dir = File.join(remote_temp_dir, dir_name.gsub(/[^0-9A-Za-z]/, '_')).gsub(%r{\/}, "\\")
remote_create_dir(work_dir)
work_dir
end
end
|
#enable_long_paths(**opts) ⇒ Object
31
32
33
34
35
|
# File 'lib/cem_win_spec/test_runner.rb', line 31
def enable_long_paths(**opts)
new_command('Enable long paths', **opts) do
remote_run('Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1')
end
end
|
#enable_symlinks(**opts) ⇒ Object
37
38
39
40
41
|
# File 'lib/cem_win_spec/test_runner.rb', line 37
def enable_symlinks(**opts)
@enable_symlinks ||= new_command('Enable symlinks', **opts) do
remote_run('fsutil behavior set SymlinkEvaluation L2L:1 R2R:1 L2R:1 R2L:1')
end
end
|
#inspect ⇒ Object
117
118
119
|
# File 'lib/cem_win_spec/test_runner.rb', line 117
def inspect
"#<#{self.class.name}:0x#{object_id.to_s(16)}>"
end
|
#retry? ⇒ Boolean
27
28
29
|
# File 'lib/cem_win_spec/test_runner.rb', line 27
def retry?
@retry
end
|
#rspec_prep(**opts) ⇒ Object
83
84
85
86
87
|
# File 'lib/cem_win_spec/test_runner.rb', line 83
def rspec_prep(**opts)
@rspec_prep ||= new_command('Prepare rspec tests', **opts) do
remote_run('bundle exec rake cem_win_spec:prep --trace')
end
end
|
#rspec_tests(**opts) ⇒ Object
89
90
91
92
93
|
# File 'lib/cem_win_spec/test_runner.rb', line 89
def rspec_tests(**opts)
@rspec_tests ||= new_command('Run rspec tests', **opts) do
remote_run(rspec_cmd_standalone('false', 'progress', 'true'))
end
end
|
#rspec_tests_parallel(**opts) ⇒ Object
95
96
97
98
99
|
# File 'lib/cem_win_spec/test_runner.rb', line 95
def rspec_tests_parallel(**opts)
@rspec_tests_parallel ||= new_command('Run rspec tests in parallel', **opts) do
remote_run('bundle exec rake cem_win_spec:parallel_spec')
end
end
|
#setup_ruby(**opts) ⇒ Object
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/cem_win_spec/test_runner.rb', line 69
def setup_ruby(**opts)
@setup_ruby ||= new_command('Set up ruby', **opts) do
remote_run(
[
'if (Test-Path .bundle) { Remove-Item -Recurse -Force .bundle }',
'if (Test-Path Gemfile.lock) { Remove-Item -Force Gemfile.lock }',
'bundle config disable_platform_warnings true',
'bundle config set --local without \'local_development\'',
'bundle install',
],
)
end
end
|
#upload_module(**opts) ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/cem_win_spec/test_runner.rb', line 56
def upload_module(**opts)
@upload_module ||= new_command('Upload module', **opts) do
raise 'No working directory or working directory is not full path' unless remote_working_dir.match?(%r{^[a-zA-Z]:.*})
module_archive_build { |a| remote_upload(a, remote_working_dir) }
module_dir = "#{remote_working_dir}\\#{File.basename(module_archive_path, '.tar.gz')}"
logger.debug "Module uploaded to #{module_dir}.tar.gz, extracting..."
remote_run("tar -C #{remote_working_dir} -xzf #{module_dir}.tar.gz")
logger.debug "Module extracted to #{module_dir}"
module_dir
end
end
|