Skip to content
Closed
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ bs_local_args = { "key" => "<browserstack-accesskey>" , "v" => "true", "logfile"

To build gem, `rake build`.

To run the test suite run, `rake test`.
To run the test suite run, `BROWSERSTACK_ACCESS_KEY=<your_access_key> rake test`.

### Reporting bugs

Expand Down
14 changes: 10 additions & 4 deletions lib/browserstack/local.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ def start(options = {})
end

def isRunning
return true if (!@pid.nil? && Process.kill(0, @pid)) rescue false
begin
(!@pid.nil? && Process.kill(0, @pid)) ? true : false
rescue
false
end
end

def stop
Expand Down Expand Up @@ -150,12 +154,14 @@ def start_command_args
end

def stop_command
"#{@binary_path} -d stop #{@local_identifier_flag}".strip
cmd = "#{@binary_path} -d stop"
cmd += " -localIdentifier #{@local_identifier_flag}" if @local_identifier_flag
cmd.strip
end

def stop_command_args
args = ["#{@binary_path}", "-d", "stop", "#{@local_identifier_flag}"]
args = args.select {|a| a.to_s != "" }
args = ["#{@binary_path}", "-d", "stop"]
args += ["-localIdentifier", @local_identifier_flag] if @local_identifier_flag
args.push(:err => [:child, :out])
args
end
Expand Down
22 changes: 22 additions & 0 deletions test/browserstack-local-test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,28 @@ def test_multiple_binary
File.delete(second_log_file)
end

def test_localId_independence
@bs_local.start
bs_local_by_ID = BrowserStack::Local.new
bs_local_by_ID.start({'localIdentifier' => "uniqueID"})
assert_equal true, @bs_local.isRunning
assert_equal true, bs_local_by_ID.isRunning
bs_local_by_ID.stop
assert_equal true, @bs_local.isRunning
assert_equal false, bs_local_by_ID.isRunning
end

def test_isRunning_stopped
@bs_local.instance_variable_set(:@pid,nil)
assert_equal false, @bs_local.isRunning
end

def test_isRunning_crashed
@bs_local.instance_variable_set(:@pid,1000000000) # probably non-existant pid
assert_equal false, @bs_local.isRunning
@bs_local.instance_variable_set(:@pid,nil)
end

def test_enable_verbose
@bs_local.add_args('v')
assert_match /\-v/, @bs_local.command
Expand Down