lib/testlab.rb in testlab-1.15.1 vs lib/testlab.rb in testlab-1.16.0
- old
+ new
@@ -139,36 +139,43 @@
attr_accessor :config_dir
attr_accessor :repo_dir
attr_accessor :labfile_path
def initialize(options={})
- self.ui = (options[:ui] || ZTK::UI.new)
- self.class.ui = self.ui
+ self.ui = (options[:ui] || ZTK::UI.new)
+ self.class.ui = self.ui
- @repo_dir = File.expand_path(options[:repo_dir] || Dir.pwd)
+ _labfile_path = (options[:labfile_path] || ENV['LABFILE'] || 'Labfile')
+ @labfile_path = ZTK::Locator.find(_labfile_path)
- @config_dir = File.expand_path(options[:config_dir] || File.join(@repo_dir, ".testlab-#{TestLab.hostname}"))
+ @repo_dir = (options[:repo_dir] || File.dirname(@labfile_path))
+
+ @config_dir = (options[:config_dir] || File.join(@repo_dir, ".testlab-#{TestLab.hostname}"))
File.exists?(@config_dir) or FileUtils.mkdir_p(@config_dir)
- labfile_path = (options[:labfile_path] || File.join(@repo_dir, 'Labfile'))
- @labfile_path = File.expand_path(ZTK::Locator.find(labfile_path))
+ # @log_file = (options[:log_file] || File.join(@repo_dir, "testlab-#{TestLab.hostname}.log") || STDOUT)
+ # self.ui.logger = ZTK::Logger.new(@log_file)
end
# Boot TestLab
#
# Change to the defined repository directory and load the *Labfile*.
#
# @return [Boolean] True if successful.
def boot
+ TestLab::Utility.log_header(self).each { |line| self.ui.logger.info { line } }
# Raise how many files we can have open to the hard limit.
nofile_cur, nofile_max = Process.getrlimit(Process::RLIMIT_NOFILE)
if nofile_cur != nofile_max
- # OSX likes to indicate we can set the infinity value here; do so causes
- # an the following exception to throw:
- # Errno::EINVAL: Invalid argument - setrlimit
- # In the event this happens, use 4096 as the max value.
+ # OSX likes to indicate we can set the infinity value here.
+ #
+ # Doing so causes the following exception to throw:
+ # Errno::EINVAL: Invalid argument - setrlimit
+ #
+ # In the event infinity is returned as the max value, use 4096 as the max
+ # value.
if (nofile_max == Process::RLIM_INFINITY)
nofile_max = 4096
end
self.ui.logger.info { "Changing maximum open file descriptors from #{nofile_cur.inspect} to #{nofile_max.inspect}" }