Capturing logcat on scenario fail

35 views
Skip to first unread message

Brad Thompson

unread,
May 1, 2015, 7:47:17 PM5/1/15
to calabash...@googlegroups.com
Hey everyone,

So I'm trying to capture logs from android device on fail.  To do this I have the following:

After do |scenario|
  if scenario.failed?
     adb logcat -t 500 > Feature_name_Scenario_name.txt
  end
end

-----------------

So this seems like a good idea but what I'm finding is Ruby's memory is going crazy when I run this.  Specifically I run our tests through Jenkins.  I believe this is causing memory on the jenkins slave to go wild.

Has anyone tried grabbing logcat files on failure?

Any ideas around this?

Thanks,
Brad

Brad Thompson

unread,
May 1, 2015, 7:58:26 PM5/1/15
to calabash...@googlegroups.com
I see in the operations.rb file we have a method:

      def get_logcat_cmd(tag)
        # returns raw logcat output for our tag
        # filtering out everthing else

        "#{adb_command} logcat -d -v raw #{tag}:* *:S"
      end

can this be used? what is tag?

Brad Thompson

unread,
May 4, 2015, 8:09:55 PM5/4/15
to calabash...@googlegroups.com
I got this to work so if anyone else wants to do this.

In the After Scenario hook put:

run_adb_command("logcat -t 3000 > #{logcat_output_filename}")

then I have a method:

def run_adb_command(cmd)
  full_cmd = "#{default_device.adb_command} #{cmd}"
  raise "failed to run #{full_cmd}" unless system(full_cmd)
end
Reply all
Reply to author
Forward
0 new messages