Skip to content

Commit 4b1af5e

Browse files
authored
Merge pull request #2488 from puppetlabs/backport-2482-to-7.x
[Backport 7.x] Update stdout and stderr methods
2 parents 0f57aca + fa4a4e2 commit 4b1af5e

File tree

4 files changed

+22
-28
lines changed

4 files changed

+22
-28
lines changed

acceptance/tests/ensure_puppet-agent_paths.rb

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@ def config_options(agent)
1818
platform = agent[:platform]
1919
case platform
2020
when /windows/
21-
if platform =~ /2003/
22-
common_app_data = 'C:/Documents and Settings/All Users/Application Data'
23-
else
24-
common_app_data = 'C:/ProgramData'
25-
end
21+
common_app_data = 'C:/ProgramData'
2622
puppetlabs_data = "#{common_app_data}/PuppetLabs"
2723

2824
codedir = "#{puppetlabs_data}/code"
@@ -94,20 +90,18 @@ def config_options(agent)
9490

9591
step 'test configprint outputs'
9692
agents.each do |agent|
97-
on(agent, puppet_agent('--configprint all')) do
98-
output = stdout
93+
on(agent, puppet_agent('--configprint all')) do |result|
9994
config_options(agent).select {|v| !v[:not_puppet_config] }.each do |config_option|
100-
assert_match("#{config_option[:name]} = #{config_option[:expected]}", output)
95+
assert_match("#{config_option[:name]} = #{config_option[:expected]}", result.stdout)
10196
end
10297
end
10398
end
10499

105100
step 'test puppet genconfig entries'
106101
agents.each do |agent|
107-
on(agent, puppet_agent('--genconfig')) do
108-
output = stdout
102+
on(agent, puppet_agent('--genconfig')) do |result|
109103
config_options(agent).select {|v| !v[:not_puppet_config] }.each do |config_option|
110-
assert_match("#{config_option[:name]} = #{config_option[:expected]}", output)
104+
assert_match("#{config_option[:name]} = #{config_option[:expected]}", result.stdout)
111105
end
112106
end
113107
end

acceptance/tests/ensure_puppet_facts_can_use_facter.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,28 @@
44

55
agents.each do |agent|
66
step 'test puppet facts with correct facter version' do
7-
on agent, puppet('facts'), :acceptable_exit_codes => [0] do
8-
facter_major_version = Integer(JSON.parse(stdout)["facterversion"].split('.').first)
7+
on(agent, puppet('facts'), :acceptable_exit_codes => [0]) do |result|
8+
facter_major_version = Integer(JSON.parse(result.stdout)["facterversion"].split('.').first)
99
assert(4 >= facter_major_version, "wrong facter version")
1010
end
1111
end
1212

1313
step "test puppet facts with facter has all the dependencies installed" do
14-
on agent, puppet('facts --debug'), :acceptable_exit_codes => [0] do
14+
on(agent, puppet('facts --debug'), :acceptable_exit_codes => [0]) do |result|
1515
if agent['platform'] =~ /win/
1616
# exclude augeas as it is not provided on Windows
17-
unresolved_fact = stdout.match(/(resolving fact (?!augeas).+\, but)/)
17+
unresolved_fact = result.stdout.match(/(resolving fact (?!augeas).+\, but)/)
1818
else
19-
unresolved_fact = stdout.match(/(resolving fact .+\, but)/)
19+
unresolved_fact = result.stdout.match(/(resolving fact .+\, but)/)
2020
end
2121

2222
assert_nil(unresolved_fact, "missing dependency for facter from: #{unresolved_fact.inspect}")
2323
end
2424
end
2525

2626
step "test that stderr is empty on puppet facts'" do
27-
on agent, puppet('facts'), :acceptable_exit_codes => [0] do
28-
assert_empty(stderr, "Expected `puppet facts` stderr to be empty")
27+
on(agent, puppet('facts'), :acceptable_exit_codes => [0]) do |result|
28+
assert_empty(result.stderr, "Expected `puppet facts` stderr to be empty")
2929
end
3030
end
3131
end

acceptance/tests/test_manpage_clobber.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@
1010
agents.each do |agent|
1111
man_command = nil
1212

13-
step "test for man command" do
14-
on agent, "command -v man", :acceptable_exit_codes => [0, 1] do
15-
man_command = stdout.chomp
13+
step 'test for man command' do
14+
on(agent, 'command -v man', :acceptable_exit_codes => [0, 1]) do |result|
15+
man_command = result.stdout.chomp
1616
end
1717
end
1818

1919
skip_test "man command not found on #{agent.hostname} (#{agent.platform})" unless man_command
2020

21-
step "test if we have puppet manpages" do
22-
on agent, "#{man_command} puppet"
21+
step 'test if we have puppet manpages' do
22+
on(agent, "#{man_command} puppet")
2323
end
2424

25-
step "test if we have unix manpages" do
26-
on agent, "#{man_command} ls"
25+
step 'test if we have unix manpages' do
26+
on(agent, "#{man_command} ls")
2727
end
2828
end
2929
end

acceptance/tests/windows_eventlog.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
# generate an error, no master on windows boxes
2525
# we use `agent` because it creates an eventlog log destination by default,
2626
# whereas `apply` does not.
27-
on agent, puppet('agent', '--server', '127.0.0.1', '--test'), :acceptable_exit_codes => [1]
27+
on(agent, puppet('agent', '--server', '127.0.0.1', '--test'), :acceptable_exit_codes => [1])
2828

2929
# make sure there's a Puppet error message in the log
3030
# cygwin + ssh + wmic hangs trying to read stdin, so echo '' |
31-
on agent, "cmd /c echo '' | wmic ntevent where \"LogFile='Application' and SourceName='Puppet' and TimeWritten >= '#{now}'\" get Message,Type /format:csv" do
31+
on(agent, "cmd /c echo '' | wmic ntevent where \"LogFile='Application' and SourceName='Puppet' and TimeWritten >= '#{now}'\" get Message,Type /format:csv") do |result|
3232
fail_test "Event not found in Application event log" unless
33-
stdout.include?('target machine actively refused it. - connect(2) for "127.0.0.1"')
33+
result.stdout.include?('target machine actively refused it. - connect(2) for "127.0.0.1"')
3434
end
3535
end

0 commit comments

Comments
 (0)