diff --git a/Rakefile b/Rakefile index 0e26179..241715f 100644 --- a/Rakefile +++ b/Rakefile @@ -7,8 +7,9 @@ Rake::TestTask.new do |t| end task :build do - system "mkdir -p dist" + system "mkdir dist" system "gem build browserstack-local.gemspec" - system "mv browserstack-local-*.gem dist" + move_command = RbConfig::CONFIG['host_os'].match(/mswin|msys|mingw|cygwin|bccwin|wince|emc|win32/) ? "move" : "mv"; + system "#{move_command} browserstack-local-*.gem dist" system "gem install ./dist/browserstack-local-*.gem" end diff --git a/lib/browserstack/local.rb b/lib/browserstack/local.rb index db8814e..874f0b0 100644 --- a/lib/browserstack/local.rb +++ b/lib/browserstack/local.rb @@ -9,7 +9,8 @@ class Local def initialize(key = ENV["BROWSERSTACK_ACCESS_KEY"]) @key = key @logfile = File.join(Dir.pwd, "local.log") - @exec = RbConfig::CONFIG['host_os'].match(/mswin|msys|mingw|cygwin|bccwin|wince|emc/) ? "call" : "exec"; + @is_windows = RbConfig::CONFIG['host_os'].match(/mswin|msys|mingw|cygwin|bccwin|wince|emc|win32/) + @exec = @is_windows ? "call" : "exec"; end def add_args(key, value=nil) @@ -58,7 +59,12 @@ def start(options = {}) @binary_path end - system("echo '' > '#{@logfile}'") + if @is_windows + system("echo > #{@logfile}") + else + system("echo '' > '#{@logfile}'") + end + if defined? spawn @process = IO.popen(command_args) else @@ -98,8 +104,9 @@ def isRunning def stop return if @pid.nil? - Process.kill("TERM", @pid) + Process.kill("TERM", @pid) rescue Process.kill(9, @pid) @process.close + @pid = nil if @is_windows while self.isRunning sleep 1 end diff --git a/lib/browserstack/localbinary.rb b/lib/browserstack/localbinary.rb index 0c8ef74..ddd8c04 100644 --- a/lib/browserstack/localbinary.rb +++ b/lib/browserstack/localbinary.rb @@ -13,14 +13,14 @@ def initialize @http_path = case host_os when /mswin|msys|mingw|cygwin|bccwin|wince|emc/ @windows = true - "https://s3.amazonaws.com/bs-automate-prod/local/BrowserStackLocal-win32.exe" + "https://s3.amazonaws.com/browserStack/browserstack-local/BrowserStackLocal.exe" when /darwin|mac os/ - "https://s3.amazonaws.com/bs-automate-prod/local/BrowserStackLocal-darwin-x64" + "https://s3.amazonaws.com/browserStack/browserstack-local/BrowserStackLocal-darwin-x64" when /linux/ if 1.size == 8 - "https://s3.amazonaws.com/bs-automate-prod/local/BrowserStackLocal-linux-x64" + "https://s3.amazonaws.com/browserStack/browserstack-local/BrowserStackLocal-linux-x64" else - "https://s3.amazonaws.com/bs-automate-prod/local/BrowserStackLocal-linux-ia32" + "https://s3.amazonaws.com/browserStack/browserstack-local/BrowserStackLocal-linux-ia32" end end @@ -79,10 +79,10 @@ def make_path(path) begin FileUtils.mkdir_p path if !File.directory?(path) return true - rescue Exception => e + rescue Exception return false end end end -end \ No newline at end of file +end diff --git a/test/browserstack-local-test.rb b/test/browserstack-local-test.rb index 17bebd6..eb35c56 100644 --- a/test/browserstack-local-test.rb +++ b/test/browserstack-local-test.rb @@ -1,4 +1,5 @@ require 'rubygems' +require 'minitest' require 'minitest/autorun' require 'browserstack/local' @@ -20,9 +21,11 @@ def test_is_running def test_multiple_binary @bs_local.start bs_local_2 = BrowserStack::Local.new + second_log_file = File.join(Dir.pwd, 'local2.log') assert_raises BrowserStack::LocalException do - bs_local_2.start + bs_local_2.start({'logfile' => second_log_file}) end + File.delete(second_log_file) end def test_enable_verbose