cem_win_spec 0.1.19 → 0.1.28
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +73 -54
- data/cem_win_spec.gemspec +36 -0
- data/exe/cem-win-spec +2 -2
- data/lib/cem_win_spec/test_runner.rb +100 -2
- data/lib/cem_win_spec/version.rb +1 -1
- data/lib/cem_win_spec/win_exec/cmd/base_cmd.rb +23 -5
- data/lib/cem_win_spec/win_exec/cmd/winrm_cmd.rb +8 -4
- data/lib/cem_win_spec.rb +22 -17
- metadata +10 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2a9b52a3032c3ca651889405916fb2b27f4bc2e86c538ddaa42cf6e64615774d
|
|
4
|
+
data.tar.gz: ee885b3f953416c796c1a823b62faf6904791987469a590443fd36487965f8b2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 787a6f356b0f1c06a3982d4ebce0f4097b37a2df3cbc94a7f75464af4fc4f9e38470d2c9763e47bc538127b78dc41fa252f3b5d521f52857276dd0ac0ed14187
|
|
7
|
+
data.tar.gz: dfc6abaacddbfbd783e4abe200ce04f64831ea889bd0d93c72fbad5ea0d5c29430dd566aa72ec7f4bce05d39d7d97cbcb96af0fc14443c3d389bae28cd1f8de7
|
data/Gemfile.lock
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
cem_win_spec (0.1.
|
|
4
|
+
cem_win_spec (0.1.28)
|
|
5
5
|
parallel_tests (~> 3.4)
|
|
6
6
|
puppet_forge (~> 6.1)
|
|
7
7
|
winrm (~> 2.3)
|
|
8
|
-
winrm-fs (~> 1.3)
|
|
8
|
+
winrm-fs (~> 1.3, >= 1.3.6)
|
|
9
9
|
|
|
10
10
|
GEM
|
|
11
11
|
remote: https://rubygems.org/
|
|
12
12
|
specs:
|
|
13
|
-
ast (2.4.
|
|
14
|
-
base64 (0.
|
|
15
|
-
|
|
13
|
+
ast (2.4.3)
|
|
14
|
+
base64 (0.3.0)
|
|
15
|
+
benchmark (0.5.0)
|
|
16
|
+
bigdecimal (4.1.3)
|
|
16
17
|
builder (3.3.0)
|
|
17
18
|
coderay (1.1.3)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
csv (3.3.6)
|
|
20
|
+
diff-lcs (1.6.2)
|
|
21
|
+
erubi (1.13.1)
|
|
22
|
+
faraday (2.14.4)
|
|
21
23
|
faraday-net_http (>= 2.0, < 3.5)
|
|
22
24
|
json
|
|
23
25
|
logger
|
|
@@ -25,89 +27,106 @@ GEM
|
|
|
25
27
|
faraday (>= 1, < 3)
|
|
26
28
|
faraday-net_http (3.4.4)
|
|
27
29
|
net-http (~> 0.5)
|
|
28
|
-
ffi (1.
|
|
30
|
+
ffi (1.17.4-arm64-darwin)
|
|
31
|
+
ffi (1.17.4-x86_64-darwin)
|
|
32
|
+
ffi (1.17.4-x86_64-linux-gnu)
|
|
29
33
|
gssapi (1.3.1)
|
|
30
34
|
ffi (>= 1.0.1)
|
|
31
35
|
gyoku (1.4.0)
|
|
32
36
|
builder (>= 2.1.2)
|
|
33
37
|
rexml (~> 3.0)
|
|
34
|
-
httpclient (2.
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
httpclient (2.9.0)
|
|
39
|
+
mutex_m
|
|
40
|
+
io-console (0.9.3)
|
|
41
|
+
json (3.0.2)
|
|
42
|
+
language_server-protocol (3.17.0.6)
|
|
43
|
+
lint_roller (1.1.0)
|
|
37
44
|
logger (1.7.0)
|
|
38
|
-
|
|
39
|
-
little-plugger (~> 1.1)
|
|
40
|
-
multi_json (~> 1.14)
|
|
41
|
-
method_source (1.0.0)
|
|
45
|
+
method_source (1.1.0)
|
|
42
46
|
minitar (1.1.0)
|
|
43
|
-
|
|
47
|
+
mutex_m (0.3.0)
|
|
44
48
|
net-http (0.9.1)
|
|
45
49
|
uri (>= 0.11.1)
|
|
46
|
-
nori (2.
|
|
50
|
+
nori (2.9.1)
|
|
47
51
|
bigdecimal
|
|
48
|
-
|
|
52
|
+
stringio
|
|
53
|
+
parallel (1.28.0)
|
|
49
54
|
parallel_tests (3.13.0)
|
|
50
55
|
parallel
|
|
51
|
-
parser (3.
|
|
56
|
+
parser (3.3.12.0)
|
|
52
57
|
ast (~> 2.4.1)
|
|
53
|
-
|
|
58
|
+
racc
|
|
59
|
+
prism (1.9.0)
|
|
60
|
+
pry (0.16.0)
|
|
54
61
|
coderay (~> 1.1)
|
|
55
62
|
method_source (~> 1.0)
|
|
63
|
+
reline (>= 0.6.0)
|
|
56
64
|
puppet_forge (6.2.0)
|
|
57
65
|
base64 (>= 0.2.0, < 0.4.0)
|
|
58
66
|
faraday (~> 2.0)
|
|
59
67
|
faraday-follow_redirects (>= 0.3, < 0.6)
|
|
60
68
|
minitar (~> 1.0, >= 1.0.2)
|
|
61
69
|
semantic_puppet (~> 1.0)
|
|
70
|
+
racc (1.8.1)
|
|
62
71
|
rainbow (3.1.1)
|
|
63
|
-
rake (13.
|
|
64
|
-
regexp_parser (2.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
rspec-
|
|
70
|
-
|
|
71
|
-
rspec-
|
|
72
|
-
rspec-
|
|
72
|
+
rake (13.4.2)
|
|
73
|
+
regexp_parser (2.12.0)
|
|
74
|
+
reline (0.7.0)
|
|
75
|
+
io-console (~> 0.5)
|
|
76
|
+
rexml (3.4.4)
|
|
77
|
+
rspec (3.13.2)
|
|
78
|
+
rspec-core (~> 3.13.0)
|
|
79
|
+
rspec-expectations (~> 3.13.0)
|
|
80
|
+
rspec-mocks (~> 3.13.0)
|
|
81
|
+
rspec-core (3.13.6)
|
|
82
|
+
rspec-support (~> 3.13.0)
|
|
83
|
+
rspec-expectations (3.13.5)
|
|
73
84
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
74
|
-
rspec-support (~> 3.
|
|
75
|
-
rspec-mocks (3.
|
|
85
|
+
rspec-support (~> 3.13.0)
|
|
86
|
+
rspec-mocks (3.13.8)
|
|
76
87
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
77
|
-
rspec-support (~> 3.
|
|
78
|
-
rspec-support (3.
|
|
79
|
-
rubocop (1.
|
|
80
|
-
|
|
81
|
-
|
|
88
|
+
rspec-support (~> 3.13.0)
|
|
89
|
+
rspec-support (3.13.7)
|
|
90
|
+
rubocop (1.91.0)
|
|
91
|
+
json (>= 2.3)
|
|
92
|
+
language_server-protocol (~> 3.17.0.2)
|
|
93
|
+
lint_roller (~> 1.1.0)
|
|
94
|
+
parallel (>= 1.10)
|
|
95
|
+
parser (>= 3.3.0.2)
|
|
82
96
|
rainbow (>= 2.2.2, < 4.0)
|
|
83
|
-
regexp_parser (>=
|
|
84
|
-
|
|
85
|
-
rubocop-ast (>= 1.18.0, < 2.0)
|
|
97
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
98
|
+
rubocop-ast (>= 1.49.0, < 2.0)
|
|
86
99
|
ruby-progressbar (~> 1.7)
|
|
87
|
-
unicode-display_width (>=
|
|
88
|
-
rubocop-ast (1.
|
|
89
|
-
parser (>= 3.
|
|
90
|
-
|
|
91
|
-
|
|
100
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
101
|
+
rubocop-ast (1.50.0)
|
|
102
|
+
parser (>= 3.3.7.2)
|
|
103
|
+
prism (~> 1.7)
|
|
104
|
+
ruby-progressbar (1.13.0)
|
|
105
|
+
rubyntlm (0.6.8)
|
|
92
106
|
base64
|
|
93
|
-
rubyzip (
|
|
107
|
+
rubyzip (3.6.0)
|
|
94
108
|
semantic_puppet (1.1.1)
|
|
95
|
-
|
|
109
|
+
stringio (3.2.0)
|
|
110
|
+
unicode-display_width (3.2.0)
|
|
111
|
+
unicode-emoji (~> 4.1)
|
|
112
|
+
unicode-emoji (4.2.0)
|
|
96
113
|
uri (1.1.1)
|
|
97
|
-
winrm (2.
|
|
114
|
+
winrm (2.4.1)
|
|
115
|
+
base64 (~> 0.2)
|
|
98
116
|
builder (>= 2.1.2)
|
|
99
117
|
erubi (~> 1.8)
|
|
100
118
|
gssapi (~> 1.2)
|
|
101
119
|
gyoku (~> 1.0)
|
|
102
120
|
httpclient (~> 2.2, >= 2.2.0.2)
|
|
103
|
-
|
|
121
|
+
logger (~> 1.6)
|
|
104
122
|
nori (~> 2.0, >= 2.7.1)
|
|
105
123
|
rexml (~> 3.0)
|
|
106
124
|
rubyntlm (~> 0.6.0, >= 0.6.3)
|
|
107
|
-
winrm-fs (1.3.
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
125
|
+
winrm-fs (1.3.7)
|
|
126
|
+
benchmark
|
|
127
|
+
csv (~> 3.3)
|
|
128
|
+
logger
|
|
129
|
+
rubyzip (~> 3.4)
|
|
111
130
|
winrm (~> 2.0)
|
|
112
131
|
|
|
113
132
|
PLATFORMS
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "lib/cem_win_spec/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "cem_win_spec"
|
|
7
|
+
spec.version = CemWinSpec::VERSION
|
|
8
|
+
spec.authors = ["Heston Snodgrass"]
|
|
9
|
+
spec.email = ["hsnodgrass@users.noreply.github.com"]
|
|
10
|
+
|
|
11
|
+
spec.summary = "Write a short summary, because RubyGems requires one."
|
|
12
|
+
spec.description = "Write a longer description or delete this line."
|
|
13
|
+
spec.homepage = "https://github.com/hsnodgrass/cem_win_spec"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
spec.required_ruby_version = ">= 2.7.0"
|
|
16
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
17
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
|
18
|
+
spec.metadata["changelog_uri"] = "#{spec.homepage}/CHANGELOG.md"
|
|
19
|
+
|
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
22
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
23
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
|
24
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
spec.bindir = "exe"
|
|
28
|
+
spec.executables = ["cem-win-spec"]
|
|
29
|
+
spec.require_paths = ["lib"]
|
|
30
|
+
|
|
31
|
+
spec.add_dependency "winrm", "~> 2.3"
|
|
32
|
+
spec.add_dependency "winrm-fs", "~> 1.3", ">= 1.3.6"
|
|
33
|
+
spec.add_dependency "puppet_forge", "~> 6.1"
|
|
34
|
+
spec.add_dependency "parallel_tests", "~> 3.4"
|
|
35
|
+
spec.add_development_dependency "pry"
|
|
36
|
+
end
|
data/exe/cem-win-spec
CHANGED
|
@@ -39,8 +39,8 @@ parser = OptionParser.new do |opts|
|
|
|
39
39
|
options[:ruby_version] = version
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
-
opts.on('-o', '--operation [OPERATION]', 'Operation to perform (spec, clean_fixture_cache)') do |operation|
|
|
43
|
-
unless %w[spec clean_fixture_cache].include?(operation)
|
|
42
|
+
opts.on('-o', '--operation [OPERATION]', 'Operation to perform (spec, install_ruby, clean_fixture_cache)') do |operation|
|
|
43
|
+
unless %w[spec install_ruby clean_fixture_cache].include?(operation)
|
|
44
44
|
warn "Unknown operation: #{operation}"
|
|
45
45
|
puts opts
|
|
46
46
|
exit 1
|
|
@@ -79,7 +79,102 @@ module CemWinSpec
|
|
|
79
79
|
]
|
|
80
80
|
if installer_url
|
|
81
81
|
installer_filename = File.basename(installer_url)
|
|
82
|
-
cmds <<
|
|
82
|
+
cmds << <<~PWSH
|
|
83
|
+
if (-not (Test-Path "$rubyBin")) {
|
|
84
|
+
$ErrorActionPreference = 'Stop'
|
|
85
|
+
try {
|
|
86
|
+
& {
|
|
87
|
+
$ErrorActionPreference = 'Continue'
|
|
88
|
+
Get-Process -Name 'rubyinstaller-*' -ErrorAction SilentlyContinue | ForEach-Object {
|
|
89
|
+
Write-Host "===== install_ruby: killing lingering process $($_.Name) (PID $($_.Id)) and children ====="
|
|
90
|
+
& taskkill.exe /F /T /PID $_.Id 2>&1 | Out-Null
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
Start-Sleep -Seconds 2
|
|
94
|
+
$tmp = "$env:TEMP\\rubyinstaller-#{ruby_ver}.download"
|
|
95
|
+
$inst = "$env:TEMP\\#{installer_filename}"
|
|
96
|
+
$log = "$env:TEMP\\rubyinstaller-#{ruby_ver}.log"
|
|
97
|
+
if (Test-Path $tmp) { Remove-Item $tmp -Force }
|
|
98
|
+
if (Test-Path $inst) { Remove-Item $inst -Force }
|
|
99
|
+
$downloaded = $false
|
|
100
|
+
if (Get-Command curl.exe -ErrorAction SilentlyContinue) {
|
|
101
|
+
Write-Host "===== install_ruby: downloading via curl.exe -> $tmp ====="
|
|
102
|
+
curl.exe -sSL --retry 3 --max-time 300 -o $tmp '#{installer_url}'
|
|
103
|
+
if ($LASTEXITCODE -eq 0) {
|
|
104
|
+
$downloaded = $true
|
|
105
|
+
} else {
|
|
106
|
+
Write-Host "===== install_ruby: curl.exe failed (exit $LASTEXITCODE), falling back to Invoke-WebRequest ====="
|
|
107
|
+
if (Test-Path $tmp) { Remove-Item $tmp -Force }
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (-not $downloaded) {
|
|
111
|
+
Write-Host "===== install_ruby: downloading via Invoke-WebRequest -> $tmp ====="
|
|
112
|
+
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
|
113
|
+
Invoke-WebRequest -Uri '#{installer_url}' -OutFile $tmp -UseBasicParsing -TimeoutSec 300
|
|
114
|
+
}
|
|
115
|
+
if (Test-Path $log) { Remove-Item $log -Force }
|
|
116
|
+
Move-Item $tmp $inst -Force
|
|
117
|
+
Write-Host "===== install_ruby: download complete ($((Get-Item $inst).Length) bytes) ====="
|
|
118
|
+
|
|
119
|
+
# WinRM sessions run with a UAC-filtered token even for local
|
|
120
|
+
# admins, so a silent installer that requires admin hangs
|
|
121
|
+
# invisibly on the UAC consent dialog. Run the installer via a
|
|
122
|
+
# scheduled task as SYSTEM to bypass UAC entirely.
|
|
123
|
+
$taskName = 'CemInstallRuby'
|
|
124
|
+
& {
|
|
125
|
+
$ErrorActionPreference = 'Continue'
|
|
126
|
+
Unregister-ScheduledTask -TaskName $taskName -Confirm:$false -ErrorAction SilentlyContinue | Out-Null
|
|
127
|
+
}
|
|
128
|
+
$installArgs = '/verysilent /suppressmsgboxes /dir=#{tool_dir} /tasks="" /norestart /log="' + $log + '"'
|
|
129
|
+
Write-Host "===== install_ruby: registering scheduled task '$taskName' as SYSTEM ====="
|
|
130
|
+
Write-Host " Execute: $inst"
|
|
131
|
+
Write-Host " Argument: $installArgs"
|
|
132
|
+
$action = New-ScheduledTaskAction -Execute $inst -Argument $installArgs
|
|
133
|
+
$principal = New-ScheduledTaskPrincipal -UserId 'SYSTEM' -LogonType ServiceAccount -RunLevel Highest
|
|
134
|
+
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -StartWhenAvailable -ExecutionTimeLimit (New-TimeSpan -Minutes 15)
|
|
135
|
+
Register-ScheduledTask -TaskName $taskName -Action $action -Principal $principal -Settings $settings -Force | Out-Null
|
|
136
|
+
|
|
137
|
+
Write-Host "===== install_ruby: starting task (600s wall-clock timeout, log: $log) ====="
|
|
138
|
+
Start-ScheduledTask -TaskName $taskName
|
|
139
|
+
$deadline = (Get-Date).AddSeconds(600)
|
|
140
|
+
$state = 'Running'
|
|
141
|
+
while ($state -eq 'Running' -and (Get-Date) -lt $deadline) {
|
|
142
|
+
Start-Sleep -Seconds 5
|
|
143
|
+
$state = (Get-ScheduledTask -TaskName $taskName).State
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if ($state -eq 'Running') {
|
|
147
|
+
Write-Host "===== install_ruby: TIMEOUT after 600s — stopping task and reaping installer ====="
|
|
148
|
+
& {
|
|
149
|
+
$ErrorActionPreference = 'Continue'
|
|
150
|
+
Stop-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue | Out-Null
|
|
151
|
+
Get-Process -Name 'rubyinstaller-*' -ErrorAction SilentlyContinue | ForEach-Object {
|
|
152
|
+
& taskkill.exe /F /T /PID $_.Id 2>&1 | Out-Null
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (Test-Path $log) { Write-Host "----- log tail ($log):"; Get-Content $log -Tail 100 | Out-Host } else { Write-Host " (log file $log does not exist)" }
|
|
156
|
+
& { $ErrorActionPreference = 'Continue'; Unregister-ScheduledTask -TaskName $taskName -Confirm:$false -ErrorAction SilentlyContinue | Out-Null }
|
|
157
|
+
throw "Ruby installer timed out after 600s"
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
$exitCode = (Get-ScheduledTaskInfo -TaskName $taskName).LastTaskResult
|
|
161
|
+
Write-Host "===== install_ruby: task finished (state=$state, LastTaskResult=$exitCode) ====="
|
|
162
|
+
& { $ErrorActionPreference = 'Continue'; Unregister-ScheduledTask -TaskName $taskName -Confirm:$false -ErrorAction SilentlyContinue | Out-Null }
|
|
163
|
+
if ($exitCode -ne 0) {
|
|
164
|
+
if (Test-Path $log) { Write-Host "----- log:"; Get-Content $log | Out-Host } else { Write-Host " (log file $log does not exist)" }
|
|
165
|
+
throw "Ruby installer failed with LastTaskResult=$exitCode"
|
|
166
|
+
}
|
|
167
|
+
Remove-Item $inst -Force
|
|
168
|
+
} catch {
|
|
169
|
+
Write-Host "===== install_ruby: FATAL — $_ ====="
|
|
170
|
+
exit 1
|
|
171
|
+
} finally {
|
|
172
|
+
$ErrorActionPreference = 'Continue'
|
|
173
|
+
}
|
|
174
|
+
} else {
|
|
175
|
+
Write-Host "===== install_ruby: Ruby already present at $rubyBin — skipping ====="
|
|
176
|
+
}
|
|
177
|
+
PWSH
|
|
83
178
|
end
|
|
84
179
|
cmds << "if ($uList -notmatch '#{ruby_ver}') { uru admin add \"$rubyBin\" }"
|
|
85
180
|
|
|
@@ -93,9 +188,12 @@ module CemWinSpec
|
|
|
93
188
|
[
|
|
94
189
|
'if (Test-Path .bundle) { Remove-Item -Recurse -Force .bundle }',
|
|
95
190
|
'if (Test-Path Gemfile.lock) { Remove-Item -Force Gemfile.lock }',
|
|
96
|
-
'bundle config disable_platform_warnings true',
|
|
191
|
+
'bundle config set disable_platform_warnings true',
|
|
192
|
+
'bundle config set --local path "$env:GEM_HOME"',
|
|
97
193
|
'bundle config set --local without \'local_development\'',
|
|
194
|
+
'$global:LASTEXITCODE = 0',
|
|
98
195
|
'bundle install',
|
|
196
|
+
'exit $LASTEXITCODE',
|
|
99
197
|
],
|
|
100
198
|
)
|
|
101
199
|
end
|
data/lib/cem_win_spec/version.rb
CHANGED
|
@@ -49,6 +49,20 @@ module CemWinSpec
|
|
|
49
49
|
@puppet_version = ver
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
+
FORWARDED_ENV_VARS = %w[
|
|
53
|
+
FORGE_API_KEY
|
|
54
|
+
SCE_COVERAGE
|
|
55
|
+
COVERAGE
|
|
56
|
+
PUPPET_AUTH_TOKEN
|
|
57
|
+
].freeze
|
|
58
|
+
|
|
59
|
+
REDACTED_ENV_VARS = %w[
|
|
60
|
+
password
|
|
61
|
+
FORGE_API_KEY
|
|
62
|
+
PUPPET_AUTH_TOKEN
|
|
63
|
+
BUNDLE_RUBYGEMS___PUPPETCORE__PUPPET__COM
|
|
64
|
+
].freeze
|
|
65
|
+
|
|
52
66
|
# Sets the environment variables that will be used to execute the command
|
|
53
67
|
# @param value [Hash] the environment variables
|
|
54
68
|
def env_vars=(value)
|
|
@@ -56,9 +70,10 @@ module CemWinSpec
|
|
|
56
70
|
|
|
57
71
|
value['PUPPET_GEM_VERSION'] = "~> #{puppet_version}" if puppet_version
|
|
58
72
|
value['FACTER_GEM_VERSION'] = 'https://github.com/puppetlabs/facter#main' if puppet_version
|
|
59
|
-
value[
|
|
60
|
-
|
|
61
|
-
|
|
73
|
+
FORWARDED_ENV_VARS.each { |k| value[k] = ENV[k] if ENV[k] }
|
|
74
|
+
if ENV['PUPPET_AUTH_TOKEN'] && !ENV['BUNDLE_RUBYGEMS___PUPPETCORE__PUPPET__COM']
|
|
75
|
+
value['BUNDLE_RUBYGEMS___PUPPETCORE__PUPPET__COM'] = "forge-key:#{ENV['PUPPET_AUTH_TOKEN']}"
|
|
76
|
+
end
|
|
62
77
|
value.delete('password') if value.key?('password')
|
|
63
78
|
@env_vars = value
|
|
64
79
|
end
|
|
@@ -111,8 +126,11 @@ module CemWinSpec
|
|
|
111
126
|
private
|
|
112
127
|
|
|
113
128
|
def log_command(cmd)
|
|
114
|
-
|
|
115
|
-
|
|
129
|
+
redacted = cmd.dup
|
|
130
|
+
REDACTED_ENV_VARS.each do |key|
|
|
131
|
+
redacted.gsub!(/\$env:#{Regexp.escape(key)} = "[^"]+"/, %($env:#{key} = [REDACTED]))
|
|
132
|
+
end
|
|
133
|
+
logger.debug "Executing command:\n#{redacted.split(%r{\n|\r\n|;\s*}).map { |c| " #> #{c}" }.join("\n")}"
|
|
116
134
|
end
|
|
117
135
|
|
|
118
136
|
# Commands that, when ran, will change the ruby version. This will also set the local bundle config path
|
|
@@ -94,10 +94,14 @@ module CemWinSpec
|
|
|
94
94
|
end
|
|
95
95
|
|
|
96
96
|
def new_conn_logger
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
level = if ENV['WINRM_DEBUG'] == 'true'
|
|
98
|
+
Logger::DEBUG
|
|
99
|
+
elsif @quiet
|
|
100
|
+
Logger::ERROR
|
|
101
|
+
else
|
|
102
|
+
Logger::WARN
|
|
103
|
+
end
|
|
104
|
+
conn_logger = ::Logger.new($stdout, level: level, progname: 'WinRM')
|
|
101
105
|
logger.debug "WinRM connection logger level set to #{conn_logger.level}"
|
|
102
106
|
conn_logger
|
|
103
107
|
end
|
data/lib/cem_win_spec.rb
CHANGED
|
@@ -48,25 +48,30 @@ module CemWinSpec
|
|
|
48
48
|
logger.debug 'Set up signal handler'
|
|
49
49
|
working_dir = nil
|
|
50
50
|
begin
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
logger.debug "Working dir: #{working_dir}"
|
|
54
|
-
install_ruby(runner, **options)
|
|
55
|
-
upload_out = upload_module(runner, working_dir)
|
|
56
|
-
module_dir = upload_out.stdout.chomp
|
|
57
|
-
logger.debug "Module dir: #{module_dir}"
|
|
58
|
-
setup_remote_ruby(runner, module_dir, **options)
|
|
59
|
-
case operation
|
|
60
|
-
when :spec
|
|
61
|
-
run_spec(runner, module_dir, **options)
|
|
62
|
-
# We set this to 0 if the tests pass because this can be set to 1 earlier by commands that fail and retry.
|
|
63
|
-
self.exit_code = 0
|
|
64
|
-
when :clean_fixture_cache
|
|
65
|
-
clean_fixture_cache(runner, module_dir, **options)
|
|
66
|
-
# We set this to 0 if the tests pass because this can be set to 1 earlier by commands that fail and retry.
|
|
51
|
+
if operation == :install_ruby
|
|
52
|
+
install_ruby(runner, **options)
|
|
67
53
|
self.exit_code = 0
|
|
68
54
|
else
|
|
69
|
-
|
|
55
|
+
sre_out = setup_remote_environment(runner)
|
|
56
|
+
working_dir = sre_out.stdout.chomp
|
|
57
|
+
logger.debug "Working dir: #{working_dir}"
|
|
58
|
+
install_ruby(runner, **options)
|
|
59
|
+
upload_out = upload_module(runner, working_dir)
|
|
60
|
+
module_dir = upload_out.stdout.chomp
|
|
61
|
+
logger.debug "Module dir: #{module_dir}"
|
|
62
|
+
setup_remote_ruby(runner, module_dir, **options)
|
|
63
|
+
case operation
|
|
64
|
+
when :spec
|
|
65
|
+
run_spec(runner, module_dir, **options)
|
|
66
|
+
# We set this to 0 if the tests pass because this can be set to 1 earlier by commands that fail and retry.
|
|
67
|
+
self.exit_code = 0
|
|
68
|
+
when :clean_fixture_cache
|
|
69
|
+
clean_fixture_cache(runner, module_dir, **options)
|
|
70
|
+
# We set this to 0 if the tests pass because this can be set to 1 earlier by commands that fail and retry.
|
|
71
|
+
self.exit_code = 0
|
|
72
|
+
else
|
|
73
|
+
raise ArgumentError, "Unknown operation: #{operation}"
|
|
74
|
+
end
|
|
70
75
|
end
|
|
71
76
|
rescue StandardError => e
|
|
72
77
|
if operation == :spec && runner.retry?
|
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.
|
|
4
|
+
version: 0.1.28
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Heston Snodgrass
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-09-
|
|
11
|
+
date: 2026-09-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: winrm
|
|
@@ -31,6 +31,9 @@ dependencies:
|
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
33
|
version: '1.3'
|
|
34
|
+
- - ">="
|
|
35
|
+
- !ruby/object:Gem::Version
|
|
36
|
+
version: 1.3.6
|
|
34
37
|
type: :runtime
|
|
35
38
|
prerelease: false
|
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -38,6 +41,9 @@ dependencies:
|
|
|
38
41
|
- - "~>"
|
|
39
42
|
- !ruby/object:Gem::Version
|
|
40
43
|
version: '1.3'
|
|
44
|
+
- - ">="
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: 1.3.6
|
|
41
47
|
- !ruby/object:Gem::Dependency
|
|
42
48
|
name: puppet_forge
|
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -96,6 +102,7 @@ files:
|
|
|
96
102
|
- LICENSE.txt
|
|
97
103
|
- README.md
|
|
98
104
|
- Rakefile
|
|
105
|
+
- cem_win_spec.gemspec
|
|
99
106
|
- exe/cem-win-spec
|
|
100
107
|
- lib/cem_win_spec.rb
|
|
101
108
|
- lib/cem_win_spec/fixture_cache.rb
|
|
@@ -138,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
138
145
|
- !ruby/object:Gem::Version
|
|
139
146
|
version: '0'
|
|
140
147
|
requirements: []
|
|
141
|
-
rubygems_version: 3.
|
|
148
|
+
rubygems_version: 3.5.22
|
|
142
149
|
signing_key:
|
|
143
150
|
specification_version: 4
|
|
144
151
|
summary: Write a short summary, because RubyGems requires one.
|