Skip to content

Update paths #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 10 additions & 3 deletions lib/browserstack/local.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions lib/browserstack/localbinary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
end
5 changes: 4 additions & 1 deletion test/browserstack-local-test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'rubygems'
require 'minitest'
require 'minitest/autorun'
require 'browserstack/local'

Expand All @@ -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
Expand Down