ruby-pwsh 0.10.3 → 0.11.0.rc.1
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/.rubocop.yml +16 -38
- data/lib/puppet/provider/dsc_base_provider/dsc_base_provider.rb +20 -20
- data/lib/pwsh/version.rb +1 -1
- data/lib/pwsh/windows_powershell.rb +2 -2
- data/lib/pwsh.rb +31 -34
- data/spec/acceptance/dsc/basic.rb +4 -0
- data/spec/acceptance/dsc/cim_instances.rb +3 -4
- data/spec/acceptance/dsc/class.rb +3 -3
- data/spec/acceptance/dsc/complex.rb +2 -2
- data/spec/acceptance/support/setup_winrm.ps1 +6 -0
- data/spec/unit/puppet/provider/dsc_base_provider/dsc_base_provider_spec.rb +171 -113
- data/spec/unit/pwsh/util_spec.rb +100 -93
- data/spec/unit/pwsh/version_spec.rb +2 -2
- data/spec/unit/pwsh/windows_powershell_spec.rb +18 -13
- data/spec/unit/pwsh_spec.rb +61 -63
- metadata +6 -5
data/spec/unit/pwsh_spec.rb
CHANGED
@@ -37,17 +37,21 @@ RSpec.shared_examples 'a PowerShellCodeManager' do |ps_command, ps_args|
|
|
37
37
|
|
38
38
|
def is_osx?
|
39
39
|
# Note this test fails if running in JRuby, but because the unit tests are MRI only, this is ok
|
40
|
-
!RUBY_PLATFORM.
|
40
|
+
!RUBY_PLATFORM.include?('darwin').nil?
|
41
41
|
end
|
42
42
|
|
43
|
-
let(:manager) {
|
43
|
+
let(:manager) { described_class.instance(ps_command, ps_args) }
|
44
|
+
|
45
|
+
let(:powershell_incompleteparseexception_error) { '$ErrorActionPreference = "Stop";if (1 -eq 2) { ' }
|
46
|
+
let(:powershell_parseexception_error) { '$ErrorActionPreference = "Stop";if (1 -badoperator 2) { Exit 1 }' }
|
47
|
+
let(:powershell_runtime_error) { '$ErrorActionPreference = "Stop";$test = 1/0' }
|
44
48
|
|
45
49
|
describe 'when managing the powershell process' do
|
46
50
|
describe 'the Manager::instance method' do
|
47
51
|
it 'returns the same manager instance / process given the same cmd line and options' do
|
48
52
|
first_pid = manager.execute('[Diagnostics.Process]::GetCurrentProcess().Id')[:stdout]
|
49
53
|
|
50
|
-
manager_two =
|
54
|
+
manager_two = described_class.instance(ps_command, ps_args)
|
51
55
|
second_pid = manager_two.execute('[Diagnostics.Process]::GetCurrentProcess().Id')[:stdout]
|
52
56
|
|
53
57
|
expect(manager_two).to eq(manager)
|
@@ -57,7 +61,7 @@ RSpec.shared_examples 'a PowerShellCodeManager' do |ps_command, ps_args|
|
|
57
61
|
it 'returns different manager instances / processes given the same cmd line and different options' do
|
58
62
|
first_pid = manager.execute('[Diagnostics.Process]::GetCurrentProcess().Id')[:stdout]
|
59
63
|
|
60
|
-
manager_two =
|
64
|
+
manager_two = described_class.instance(ps_command, ps_args, { some_option: 'foo' })
|
61
65
|
second_pid = manager_two.execute('[Diagnostics.Process]::GetCurrentProcess().Id')[:stdout]
|
62
66
|
|
63
67
|
expect(manager_two).not_to eq(manager)
|
@@ -65,7 +69,7 @@ RSpec.shared_examples 'a PowerShellCodeManager' do |ps_command, ps_args|
|
|
65
69
|
end
|
66
70
|
|
67
71
|
it 'fails if the manger is created with a short timeout' do
|
68
|
-
expect {
|
72
|
+
expect { described_class.new(ps_command, ps_args, debug: false, pipe_timeout: 0.01) }.to raise_error do |e|
|
69
73
|
expect(e).to be_a(RuntimeError)
|
70
74
|
expected_error = /Failure waiting for PowerShell process (\d+) to start pipe server/
|
71
75
|
expect(e.message).to match expected_error
|
@@ -86,14 +90,14 @@ RSpec.shared_examples 'a PowerShellCodeManager' do |ps_command, ps_args|
|
|
86
90
|
# <Errno::EBADF: Bad file descriptor @ io_fillbuf - fd:10 >
|
87
91
|
@bad_file_descriptor_regex ||= begin
|
88
92
|
ebadf = Errno::EBADF.new
|
89
|
-
"^#{Regexp.escape("
|
93
|
+
"^#{Regexp.escape("#<#{ebadf.class}: #{ebadf.message}")}"
|
90
94
|
end
|
91
95
|
end
|
92
96
|
|
93
97
|
def pipe_error_regex
|
94
98
|
@pipe_error_regex ||= begin
|
95
99
|
epipe = Errno::EPIPE.new
|
96
|
-
"^#{Regexp.escape("
|
100
|
+
"^#{Regexp.escape("#<#{epipe.class}: #{epipe.message}")}"
|
97
101
|
end
|
98
102
|
end
|
99
103
|
|
@@ -118,7 +122,7 @@ RSpec.shared_examples 'a PowerShellCodeManager' do |ps_command, ps_args|
|
|
118
122
|
end
|
119
123
|
|
120
124
|
# and the manager no longer considers itself alive
|
121
|
-
expect(manager.alive?).to
|
125
|
+
expect(manager.alive?).to be(false)
|
122
126
|
end
|
123
127
|
|
124
128
|
def expect_different_manager_returned_than(manager, pid)
|
@@ -126,11 +130,11 @@ RSpec.shared_examples 'a PowerShellCodeManager' do |ps_command, ps_args|
|
|
126
130
|
new_manager = Pwsh::Manager.instance(manager.powershell_command, manager.powershell_arguments, debug: true)
|
127
131
|
|
128
132
|
# which should be different than the one passed in
|
129
|
-
expect(new_manager).
|
133
|
+
expect(new_manager).not_to eq(manager)
|
130
134
|
|
131
135
|
# with a different PID
|
132
136
|
second_pid = new_manager.execute('[Diagnostics.Process]::GetCurrentProcess().Id')[:stdout]
|
133
|
-
expect(pid).
|
137
|
+
expect(pid).not_to eq(second_pid)
|
134
138
|
end
|
135
139
|
|
136
140
|
def close_stream(stream, style = :inprocess)
|
@@ -264,17 +268,13 @@ RSpec.shared_examples 'a PowerShellCodeManager' do |ps_command, ps_args|
|
|
264
268
|
end
|
265
269
|
end
|
266
270
|
|
267
|
-
let(:powershell_runtime_error) { '$ErrorActionPreference = "Stop";$test = 1/0' }
|
268
|
-
let(:powershell_parseexception_error) { '$ErrorActionPreference = "Stop";if (1 -badoperator 2) { Exit 1 }' }
|
269
|
-
let(:powershell_incompleteparseexception_error) { '$ErrorActionPreference = "Stop";if (1 -eq 2) { ' }
|
270
|
-
|
271
271
|
describe 'when provided powershell commands' do
|
272
272
|
it 'shows ps version' do
|
273
273
|
result = manager.execute('$psversiontable')
|
274
274
|
puts result[:stdout]
|
275
275
|
end
|
276
276
|
|
277
|
-
it '
|
277
|
+
it 'returns simple output' do
|
278
278
|
result = manager.execute('write-output foo')
|
279
279
|
|
280
280
|
expect(result[:stdout]).to eq("foo#{line_end}")
|
@@ -291,7 +291,7 @@ RSpec.shared_examples 'a PowerShellCodeManager' do |ps_command, ps_args|
|
|
291
291
|
it 'returns the exitcode 1 when exception is thrown' do
|
292
292
|
result = manager.execute('throw "foo"')
|
293
293
|
|
294
|
-
expect(result[:stdout]).to
|
294
|
+
expect(result[:stdout]).to be_nil
|
295
295
|
expect(result[:exitcode]).to eq(1)
|
296
296
|
end
|
297
297
|
|
@@ -310,7 +310,7 @@ RSpec.shared_examples 'a PowerShellCodeManager' do |ps_command, ps_args|
|
|
310
310
|
fixture_path = File.expand_path("#{File.dirname(__FILE__)}/../exit-27.ps1")
|
311
311
|
result = manager.execute("& #{fixture_path}")
|
312
312
|
|
313
|
-
expect(result[:stdout]).to
|
313
|
+
expect(result[:stdout]).to be_nil
|
314
314
|
expect(result[:exitcode]).to eq(27)
|
315
315
|
end
|
316
316
|
|
@@ -329,24 +329,21 @@ RSpec.shared_examples 'a PowerShellCodeManager' do |ps_command, ps_args|
|
|
329
329
|
manager.execute('/bin/sh -c "echo bar 1>&2 && foo.exe"')
|
330
330
|
end
|
331
331
|
|
332
|
-
expect(result[:stdout]).to
|
332
|
+
expect(result[:stdout]).to be_nil
|
333
333
|
if Pwsh::Util.on_windows?
|
334
334
|
expect(result[:stderr]).to eq(["'foo.exe' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n"])
|
335
|
-
elsif is_osx?
|
336
|
-
expect(result[:stderr][0]).to match(/foo\.exe: command not found/)
|
337
|
-
expect(result[:stderr][0]).to match(/bar/)
|
338
335
|
else
|
339
|
-
expect(result[:stderr][0]).to match(/foo\.exe:
|
336
|
+
expect(result[:stderr][0]).to match(/foo\.exe:(?:.*)not found/)
|
340
337
|
expect(result[:stderr][0]).to match(/bar/)
|
341
338
|
end
|
342
|
-
expect(result[:exitcode]).
|
339
|
+
expect(result[:exitcode]).not_to eq(0)
|
343
340
|
end
|
344
341
|
|
345
342
|
it 'handles writting to stdout (cmdlet) and stderr' do
|
346
343
|
result = manager.execute('Write-Host "powershell";[System.Console]::Error.WriteLine("foo")')
|
347
344
|
|
348
|
-
expect(result[:stdout]).not_to
|
349
|
-
expect(result[:native_stdout]).to
|
345
|
+
expect(result[:stdout]).not_to be_nil
|
346
|
+
expect(result[:native_stdout]).to be_nil
|
350
347
|
expect(result[:stderr]).to eq(["foo#{line_end}"])
|
351
348
|
expect(result[:exitcode]).to eq(0)
|
352
349
|
end
|
@@ -358,8 +355,8 @@ RSpec.shared_examples 'a PowerShellCodeManager' do |ps_command, ps_args|
|
|
358
355
|
manager.execute('/bin/sh -c "echo powershell";[System.Console]::Error.WriteLine("foo")')
|
359
356
|
end
|
360
357
|
|
361
|
-
expect(result[:stdout]).to
|
362
|
-
expect(result[:native_stdout]).not_to
|
358
|
+
expect(result[:stdout]).to be_nil
|
359
|
+
expect(result[:native_stdout]).not_to be_nil
|
363
360
|
expect(result[:stderr]).to eq(["foo#{line_end}"])
|
364
361
|
expect(result[:exitcode]).to eq(0)
|
365
362
|
end
|
@@ -368,7 +365,7 @@ RSpec.shared_examples 'a PowerShellCodeManager' do |ps_command, ps_args|
|
|
368
365
|
result = manager.execute('[System.Console]::Out.WriteLine("foo")')
|
369
366
|
|
370
367
|
expect(result[:stdout]).to eq("foo#{line_end}")
|
371
|
-
expect(result[:native_stdout]).to
|
368
|
+
expect(result[:native_stdout]).to be_nil
|
372
369
|
expect(result[:stderr]).to eq([])
|
373
370
|
expect(result[:exitcode]).to eq(0)
|
374
371
|
end
|
@@ -385,7 +382,7 @@ RSpec.shared_examples 'a PowerShellCodeManager' do |ps_command, ps_args|
|
|
385
382
|
result = manager.execute('Write-Host "powershell";[System.Console]::Out.WriteLine("foo")')
|
386
383
|
|
387
384
|
expect(result[:stdout]).not_to eq("foo#{line_end}")
|
388
|
-
expect(result[:native_stdout]).to
|
385
|
+
expect(result[:native_stdout]).to be_nil
|
389
386
|
expect(result[:stderr]).to eq([])
|
390
387
|
expect(result[:exitcode]).to eq(0)
|
391
388
|
end
|
@@ -394,7 +391,7 @@ RSpec.shared_examples 'a PowerShellCodeManager' do |ps_command, ps_args|
|
|
394
391
|
result = manager.execute('Write-Host "powershell";[System.Console]::Out.WriteLine("foo");[System.Console]::Error.WriteLine("bar")')
|
395
392
|
|
396
393
|
expect(result[:stdout]).not_to eq("foo#{line_end}")
|
397
|
-
expect(result[:native_stdout]).to
|
394
|
+
expect(result[:native_stdout]).to be_nil
|
398
395
|
expect(result[:stderr]).to eq(["bar#{line_end}"])
|
399
396
|
expect(result[:exitcode]).to eq(0)
|
400
397
|
end
|
@@ -406,6 +403,7 @@ RSpec.shared_examples 'a PowerShellCodeManager' do |ps_command, ps_args|
|
|
406
403
|
# 3-byte ᚠ - http://www.fileformat.info/info/unicode/char/16A0/index.htm - 0xE1 0x9A 0xA0 / 225 154 160
|
407
404
|
# 4-byte 𠜎 - http://www.fileformat.info/info/unicode/char/2070E/index.htm - 0xF0 0xA0 0x9C 0x8E / 240 160 156 142
|
408
405
|
let(:mixed_utf8) { "A\u06FF\u16A0\u{2070E}" } # Aۿᚠ𠜎
|
406
|
+
|
409
407
|
it 'when writing basic text' do
|
410
408
|
code = "Write-Output '#{mixed_utf8}'"
|
411
409
|
result = manager.execute(code)
|
@@ -426,14 +424,14 @@ RSpec.shared_examples 'a PowerShellCodeManager' do |ps_command, ps_args|
|
|
426
424
|
it 'executes cmdlets' do
|
427
425
|
result = manager.execute('Get-Verb')
|
428
426
|
|
429
|
-
expect(result[:stdout]).not_to
|
427
|
+
expect(result[:stdout]).not_to be_nil
|
430
428
|
expect(result[:exitcode]).to eq(0)
|
431
429
|
end
|
432
430
|
|
433
431
|
it 'executes cmdlets with pipes' do
|
434
432
|
result = manager.execute('Get-Process | ? { $_.PID -ne $PID }')
|
435
433
|
|
436
|
-
expect(result[:stdout]).not_to
|
434
|
+
expect(result[:stdout]).not_to be_nil
|
437
435
|
expect(result[:exitcode]).to eq(0)
|
438
436
|
end
|
439
437
|
|
@@ -445,7 +443,7 @@ RSpec.shared_examples 'a PowerShellCodeManager' do |ps_command, ps_args|
|
|
445
443
|
CODE
|
446
444
|
)
|
447
445
|
|
448
|
-
expect(result[:stdout]).not_to
|
446
|
+
expect(result[:stdout]).not_to be_nil
|
449
447
|
expect(result[:exitcode]).to eq(0)
|
450
448
|
end
|
451
449
|
|
@@ -461,7 +459,7 @@ RSpec.shared_examples 'a PowerShellCodeManager' do |ps_command, ps_args|
|
|
461
459
|
CODE
|
462
460
|
)
|
463
461
|
|
464
|
-
expect(result[:stdout]).not_to
|
462
|
+
expect(result[:stdout]).not_to be_nil
|
465
463
|
expect(result[:exitcode]).to eq(0)
|
466
464
|
end
|
467
465
|
|
@@ -476,7 +474,7 @@ RSpec.shared_examples 'a PowerShellCodeManager' do |ps_command, ps_args|
|
|
476
474
|
CODE
|
477
475
|
)
|
478
476
|
|
479
|
-
expect(result[:stdout]).to
|
477
|
+
expect(result[:stdout]).to be_nil
|
480
478
|
# using an explicit exit code ensures we've really executed correct block
|
481
479
|
expect(result[:exitcode]).to eq(400)
|
482
480
|
end
|
@@ -492,7 +490,7 @@ RSpec.shared_examples 'a PowerShellCodeManager' do |ps_command, ps_args|
|
|
492
490
|
CODE
|
493
491
|
)
|
494
492
|
|
495
|
-
expect(result[:stdout]).to
|
493
|
+
expect(result[:stdout]).to be_nil
|
496
494
|
# using an explicit exit code ensures we've really executed correct block
|
497
495
|
expect(result[:exitcode]).to eq(500)
|
498
496
|
end
|
@@ -508,7 +506,7 @@ RSpec.shared_examples 'a PowerShellCodeManager' do |ps_command, ps_args|
|
|
508
506
|
manager.execute('$foo = "bar"')
|
509
507
|
result = manager.execute('$foo')
|
510
508
|
|
511
|
-
expect(result[:stdout]).to
|
509
|
+
expect(result[:stdout]).to be_nil
|
512
510
|
end
|
513
511
|
|
514
512
|
it 'removes env variables between runs' do
|
@@ -528,13 +526,13 @@ RSpec.shared_examples 'a PowerShellCodeManager' do |ps_command, ps_args|
|
|
528
526
|
manager.execute('Write-Output $ENV:foo', nil, nil, ['foo=bar'])
|
529
527
|
result = manager.execute('Write-Output $ENV:foo', nil, nil, [])
|
530
528
|
|
531
|
-
expect(result[:stdout]).to
|
529
|
+
expect(result[:stdout]).to be_nil
|
532
530
|
end
|
533
531
|
|
534
532
|
it 'ignores malformed custom environment variable' do
|
535
533
|
result = manager.execute('Write-Output $ENV:foo', nil, nil, ['=foo', 'foo', 'foo='])
|
536
534
|
|
537
|
-
expect(result[:stdout]).to
|
535
|
+
expect(result[:stdout]).to be_nil
|
538
536
|
end
|
539
537
|
|
540
538
|
it 'uses last definition for duplicate custom environment variable' do
|
@@ -546,11 +544,11 @@ RSpec.shared_examples 'a PowerShellCodeManager' do |ps_command, ps_args|
|
|
546
544
|
def current_powershell_major_version(ps_command, ps_args)
|
547
545
|
# As this is only used to detect old PS versions we can
|
548
546
|
# short circuit detecting the version for PowerShell Core
|
549
|
-
return 6 if ps_command.end_with?('pwsh'
|
547
|
+
return 6 if ps_command.end_with?('pwsh', 'pwsh.exe')
|
550
548
|
|
551
549
|
begin
|
552
550
|
version = `#{ps_command} #{ps_args.join(' ')} -Command \"$PSVersionTable.PSVersion.Major.ToString()\"`.chomp!.to_i
|
553
|
-
rescue
|
551
|
+
rescue StandardError
|
554
552
|
puts 'Unable to determine PowerShell version'
|
555
553
|
version = -1
|
556
554
|
end
|
@@ -575,7 +573,7 @@ RSpec.shared_examples 'a PowerShellCodeManager' do |ps_command, ps_args|
|
|
575
573
|
CODE
|
576
574
|
)
|
577
575
|
|
578
|
-
expect(result[:errormessage]).to
|
576
|
+
expect(result[:errormessage]).to be_nil
|
579
577
|
expect(result[:exitcode]).to eq(0)
|
580
578
|
expect(result[:stdout].length).to eq("#{buffer_string_96k}#{line_end}".length)
|
581
579
|
expect(result[:stdout]).to eq("#{buffer_string_96k}#{line_end}")
|
@@ -589,9 +587,9 @@ RSpec.shared_examples 'a PowerShellCodeManager' do |ps_command, ps_args|
|
|
589
587
|
CODE
|
590
588
|
)
|
591
589
|
|
592
|
-
expect(result[:errormessage]).to
|
590
|
+
expect(result[:errormessage]).to be_nil
|
593
591
|
expect(result[:exitcode]).to eq(0)
|
594
|
-
expected = "\x0" * (1024 * 64 + 11) + line_end
|
592
|
+
expected = ("\x0" * ((1024 * 64) + 11)) + line_end
|
595
593
|
expect(result[:stdout].length).to eq(expected.length)
|
596
594
|
expect(result[:stdout]).to eq(expected)
|
597
595
|
end
|
@@ -651,14 +649,14 @@ RSpec.shared_examples 'a PowerShellCodeManager' do |ps_command, ps_args|
|
|
651
649
|
|
652
650
|
result = manager.execute('(Get-Location).Path', nil, work_dir)
|
653
651
|
|
654
|
-
expect(result[:exitcode]).
|
652
|
+
expect(result[:exitcode]).not_to eq(0)
|
655
653
|
expect(result[:errormessage]).to match(/Working directory .+ does not exist/)
|
656
654
|
end
|
657
655
|
|
658
656
|
it 'allows forward slashes in working directory', if: Pwsh::Util.on_windows? do
|
659
657
|
# Backslashes only apply on Windows filesystems
|
660
|
-
work_dir = ENV
|
661
|
-
forward_work_dir = work_dir.
|
658
|
+
work_dir = ENV.fetch('WINDIR', nil)
|
659
|
+
forward_work_dir = work_dir.tr('\\', '/')
|
662
660
|
|
663
661
|
result = manager.execute('(Get-Location).Path', nil, forward_work_dir)[:stdout]
|
664
662
|
|
@@ -666,7 +664,7 @@ RSpec.shared_examples 'a PowerShellCodeManager' do |ps_command, ps_args|
|
|
666
664
|
end
|
667
665
|
|
668
666
|
it 'uses a specific working directory if set' do
|
669
|
-
work_dir = Pwsh::Util.on_windows? ? ENV
|
667
|
+
work_dir = Pwsh::Util.on_windows? ? ENV.fetch('WINDIR', nil) : Dir.home
|
670
668
|
|
671
669
|
result = manager.execute('(Get-Location).Path', nil, work_dir)[:stdout]
|
672
670
|
|
@@ -674,7 +672,7 @@ RSpec.shared_examples 'a PowerShellCodeManager' do |ps_command, ps_args|
|
|
674
672
|
end
|
675
673
|
|
676
674
|
it 'does not reuse the same working directory between runs' do
|
677
|
-
work_dir = Pwsh::Util.on_windows? ? ENV
|
675
|
+
work_dir = Pwsh::Util.on_windows? ? ENV.fetch('WINDIR', nil) : Dir.home
|
678
676
|
current_work_dir = Pwsh::Util.on_windows? ? Dir.getwd.tr('/', '\\') : Dir.getwd
|
679
677
|
|
680
678
|
first_cwd = manager.execute('(Get-Location).Path', nil, work_dir)[:stdout]
|
@@ -739,7 +737,7 @@ RSpec.shared_examples 'a PowerShellCodeManager' do |ps_command, ps_args|
|
|
739
737
|
|
740
738
|
describe 'when output is written to a PowerShell Stream' do
|
741
739
|
it 'collects anything written to verbose stream' do
|
742
|
-
msg = SecureRandom.uuid.to_s.
|
740
|
+
msg = SecureRandom.uuid.to_s.delete('-')
|
743
741
|
result = manager.execute("$VerbosePreference = 'Continue';Write-Verbose '#{msg}'")
|
744
742
|
|
745
743
|
expect(result[:stdout]).to match(/^VERBOSE: #{msg}/)
|
@@ -747,7 +745,7 @@ RSpec.shared_examples 'a PowerShellCodeManager' do |ps_command, ps_args|
|
|
747
745
|
end
|
748
746
|
|
749
747
|
it 'collects anything written to debug stream' do
|
750
|
-
msg = SecureRandom.uuid.to_s.
|
748
|
+
msg = SecureRandom.uuid.to_s.delete('-')
|
751
749
|
result = manager.execute("$debugPreference = 'Continue';Write-debug '#{msg}'")
|
752
750
|
|
753
751
|
expect(result[:stdout]).to match(/^DEBUG: #{msg}/)
|
@@ -755,7 +753,7 @@ RSpec.shared_examples 'a PowerShellCodeManager' do |ps_command, ps_args|
|
|
755
753
|
end
|
756
754
|
|
757
755
|
it 'collects anything written to Warning stream' do
|
758
|
-
msg = SecureRandom.uuid.to_s.
|
756
|
+
msg = SecureRandom.uuid.to_s.delete('-')
|
759
757
|
result = manager.execute("Write-Warning '#{msg}'")
|
760
758
|
|
761
759
|
expect(result[:stdout]).to match(/^WARNING: #{msg}/)
|
@@ -763,7 +761,7 @@ RSpec.shared_examples 'a PowerShellCodeManager' do |ps_command, ps_args|
|
|
763
761
|
end
|
764
762
|
|
765
763
|
it 'collects anything written to Error stream' do
|
766
|
-
msg = SecureRandom.uuid.to_s.
|
764
|
+
msg = SecureRandom.uuid.to_s.delete('-')
|
767
765
|
result = manager.execute("$ErrorView = 'NormalView' ; Write-Error '#{msg}'")
|
768
766
|
|
769
767
|
expect(result[:stdout]).to match(/Write-Error '#{msg}' : #{msg}/)
|
@@ -773,7 +771,7 @@ RSpec.shared_examples 'a PowerShellCodeManager' do |ps_command, ps_args|
|
|
773
771
|
it 'handles a Write-Error in the middle of code' do
|
774
772
|
result = manager.execute('Write-Host "one" ;Write-Error "Hello"; Write-Host "two"')
|
775
773
|
|
776
|
-
expect(result[:stdout]).not_to
|
774
|
+
expect(result[:stdout]).not_to be_nil
|
777
775
|
expect(result[:exitcode]).to eq(0)
|
778
776
|
end
|
779
777
|
|
@@ -787,14 +785,14 @@ RSpec.shared_examples 'a PowerShellCodeManager' do |ps_command, ps_args|
|
|
787
785
|
it 'handles lots of output from user code' do
|
788
786
|
result = manager.execute('1..1000 | %{ (65..90) + (97..122) | Get-Random -Count 5 | % {[char]$_} }')
|
789
787
|
|
790
|
-
expect(result[:stdout]).not_to
|
788
|
+
expect(result[:stdout]).not_to be_nil
|
791
789
|
expect(result[:exitcode]).to eq(0)
|
792
790
|
end
|
793
791
|
|
794
792
|
it 'handles a larger return of output from user code' do
|
795
793
|
result = manager.execute('1..1000 | %{ (65..90) + (97..122) | Get-Random -Count 5 | % {[char]$_} } | %{ $f="" } { $f+=$_ } {$f }')
|
796
794
|
|
797
|
-
expect(result[:stdout]).not_to
|
795
|
+
expect(result[:stdout]).not_to be_nil
|
798
796
|
expect(result[:exitcode]).to eq(0)
|
799
797
|
end
|
800
798
|
|
@@ -803,7 +801,7 @@ RSpec.shared_examples 'a PowerShellCodeManager' do |ps_command, ps_args|
|
|
803
801
|
# the opposite of this test shows the same thing
|
804
802
|
result = manager.execute('function test-error{ ps;write-error \'foo\' }; test-error 2>&1')
|
805
803
|
|
806
|
-
expect(result[:stdout]).not_to
|
804
|
+
expect(result[:stdout]).not_to be_nil
|
807
805
|
expect(result[:exitcode]).to eq(0)
|
808
806
|
end
|
809
807
|
end
|
@@ -811,13 +809,13 @@ RSpec.shared_examples 'a PowerShellCodeManager' do |ps_command, ps_args|
|
|
811
809
|
end
|
812
810
|
|
813
811
|
RSpec.describe 'On Windows PowerShell', if: Pwsh::Util.on_windows? && Pwsh::Manager.windows_powershell_supported? do
|
814
|
-
|
815
|
-
|
816
|
-
|
812
|
+
it_behaves_like 'a PowerShellCodeManager',
|
813
|
+
Pwsh::Manager.powershell_path,
|
814
|
+
Pwsh::Manager.powershell_args
|
817
815
|
end
|
818
816
|
|
819
817
|
RSpec.describe 'On PowerShell Core', if: Pwsh::Manager.pwsh_supported? do
|
820
|
-
|
821
|
-
|
822
|
-
|
818
|
+
it_behaves_like 'a PowerShellCodeManager',
|
819
|
+
Pwsh::Manager.pwsh_path,
|
820
|
+
Pwsh::Manager.pwsh_args
|
823
821
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-pwsh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0.rc.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: PowerShell code manager for ruby.
|
14
14
|
email:
|
@@ -35,6 +35,7 @@ files:
|
|
35
35
|
- spec/acceptance/dsc/cim_instances.rb
|
36
36
|
- spec/acceptance/dsc/class.rb
|
37
37
|
- spec/acceptance/dsc/complex.rb
|
38
|
+
- spec/acceptance/support/setup_winrm.ps1
|
38
39
|
- spec/exit-27.ps1
|
39
40
|
- spec/spec_helper.rb
|
40
41
|
- spec/unit/puppet/provider/dsc_base_provider/dsc_base_provider_spec.rb
|
@@ -57,12 +58,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
57
58
|
requirements:
|
58
59
|
- - ">="
|
59
60
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
61
|
+
version: 2.7.0
|
61
62
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
63
|
requirements:
|
63
|
-
- - "
|
64
|
+
- - ">"
|
64
65
|
- !ruby/object:Gem::Version
|
65
|
-
version:
|
66
|
+
version: 1.3.1
|
66
67
|
requirements: []
|
67
68
|
rubygems_version: 3.1.6
|
68
69
|
signing_key:
|