diff options
author | Ryan Davis <ryand-ruby@zenspider.com> | 2020-03-06 17:45:23 -0800 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-03-16 11:56:35 -0700 |
commit | 49ad29e0b7607103e32853fc8e3cf67c6d308b90 (patch) | |
tree | a4da5fb9e5266023c43c03146068cd18f515c8a1 | |
parent | f07e44418af0f6e577ba43baec8579ae840446ce (diff) | |
download | chef-49ad29e0b7607103e32853fc8e3cf67c6d308b90.tar.gz |
Guard against windows loading on non-windows platforms.
Signed-off-by: Ryan Davis <zenspider@chef.io>
-rw-r--r-- | spec/support/platforms/win32/spec_service.rb | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/spec/support/platforms/win32/spec_service.rb b/spec/support/platforms/win32/spec_service.rb index 2cc4e40298..f43e4a15fb 100644 --- a/spec/support/platforms/win32/spec_service.rb +++ b/spec/support/platforms/win32/spec_service.rb @@ -16,40 +16,42 @@ # limitations under the License. # -require "win32/daemon" +if ChefUtils.windows? + require "win32/daemon" -class SpecService < ::Win32::Daemon - def service_init - @test_service_file = "#{ENV["TMP"]}/spec_service_file" - end + class SpecService < ::Win32::Daemon + def service_init + @test_service_file = "#{ENV["TMP"]}/spec_service_file" + end - def service_main(*startup_parameters) - while running? - unless File.exists?(@test_service_file) - File.open(@test_service_file, "wb") do |f| - f.write("This file is created by SpecService") + def service_main(*startup_parameters) + while running? + unless File.exists?(@test_service_file) + File.open(@test_service_file, "wb") do |f| + f.write("This file is created by SpecService") + end end - end - sleep 1 + sleep 1 + end end - end - ################################################################################ - # Control Signal Callback Methods - ################################################################################ + ################################################################################ + # Control Signal Callback Methods + ################################################################################ - def service_stop; end + def service_stop; end - def service_pause; end + def service_pause; end - def service_resume; end + def service_resume; end - def service_shutdown; end -end + def service_shutdown; end + end -# To run this file as a service, it must be called as a script from within -# the Windows Service framework. In that case, kick off the main loop! -if __FILE__ == $0 - SpecService.mainloop + # To run this file as a service, it must be called as a script from within + # the Windows Service framework. In that case, kick off the main loop! + if __FILE__ == $0 + SpecService.mainloop + end end |