Skip to content

Commit

Permalink
Use Appium to get iOS E2E logs
Browse files Browse the repository at this point in the history
  • Loading branch information
nickdowell committed Sep 13, 2022
1 parent 87dac64 commit 157c839
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,6 @@ def skip_below(os, version)
Maze.config.captured_invalid_requests = Set[:errors, :sessions, :builds, :uploads, :sourcemaps]

$started_at = Time.now

if Maze.config.os == 'ios' && Maze.config.farm == :local
begin
$logger_pid = Process.spawn(
'idevicesyslog', '-u', Maze.config.device_id, '-m', 'iOSTestApp',
%i[err out] => File.open('device.log', 'w')
)
rescue Errno::ENOENT
p 'Install libimobiledevice to capture iOS device logs'
end
end
end

Maze.hooks.after do |scenario|
Expand All @@ -113,7 +102,7 @@ def skip_below(os, version)

FileUtils.makedirs(path)

case Maze.config.os
case Maze::Helper.get_current_platform
when 'macos'
if $fixture_pid # will be nil if scenario was skipped
Process.kill 'KILL', $fixture_pid
Expand All @@ -130,17 +119,17 @@ def skip_below(os, version)
FileUtils.mv '/tmp/kscrash.log', path
end
when 'ios'
if $logger_pid
Process.kill 'TERM', $logger_pid
Process.waitpid $logger_pid
$logger_pid = nil
FileUtils.mv 'device.log', path
# get_log can be slow (1 or 2 seconds) on device farms
if scenario.failed || Maze.config.farm == :local
File.open(File.join(path, 'syslog.log'), 'wb') do |file|
Maze.driver.get_log('syslog').each { |entry| file.puts entry.message }
end
end
begin
data = Maze.driver.pull_file '@com.bugsnag.iOSTestApp/Documents/kscrash.log'
File.open(File.join(path, 'kscrash.log'), 'wb') { |file| file << data }
rescue StandardError
p "Maze.driver.pull_file failed: #{$ERROR_INFO}"
puts "Maze.driver.pull_file failed: #{$ERROR_INFO}"
end
end
end

0 comments on commit 157c839

Please sign in to comment.