1

Context

I have a Mac Mini running Xcode, and a series of Cucumber tests ran with Calabash.

Issue

They fail because the simulator takes very long (possibly 50 seconds) to get up and running. I've tried to pass timeout launch options (by passing them in front of my call as per the documentation) but I'm still failing, and I haven't either understood yet how to use launch options in calabash-ios console mode.

I'm reading through the source in the hope of finding something not documented here.

I actually get no progress from this question:

calabash-ios console
> Running irb...
> irb(main):001:0> start_test_server_in_background(:timeout => 6000)
> RunLoop::Xcrun::TimeoutError: Xcrun timed out after 30.30 seconds executing
> xcrun instruments -s templates
> with a timeout of 30

Can I disable the launch timeout entirely, and how would I do that (save editing the calabash source...)?

Community
  • 1
  • 1
Kheldar
  • 5,361
  • 3
  • 34
  • 63
  • I believe this is a duplicate of http://stackoverflow.com/questions/24075107/how-to-pass-in-timeout-for-cucumber-command-as-in-start-test-server-in-backgroun As for adding launch options, you put them in front like this "DEVICE_TARGET='iPhone 6 (9.1)' DEBUG=1 calabash-ios console". That also took me some time and help to figure out. – Lasse Mar 03 '16 at 11:21

2 Answers2

3

It's not quite obvious, but there is a way. From xcrun.rb (which is actually in the run_loop gem),

# You can override these values if they do not work in your environment.
#
# For cucumber users, the best place to override would be in your
# features/support/env.rb.
#
# For example:
#
# RunLoop::Xcrun::DEFAULT_OPTIONS[:timeout] = 60

Let me know if that doesn't work for you.

As far as disabling it altogether, I think it's easier to just use a huge value for the timeout. Keep in mind though, the timeouts are there for a reason. If your simulator is actually stuck and unable to launch for some reason, it's reasonable to have some timeout to bail.

  • It's really not stuck but unbearably slow (the machine is making me go insane launching the simulator manually, I'm waiting for my company to order a new machine...). You are right about using huge values, I'll try your technique and report back! – Kheldar Mar 04 '16 at 09:49
  • 1
    @Kheldar the answer to 'Can I disable the launch timeout entirely [without modifying calabash source]' is no. See https://github.com/calabash/run_loop/blob/ef787180a27903ea55c50467e7b90821d0c7a3a2/lib/run_loop/device.rb#L405 I don't think it would be too hard to modify if you were up for making a fork of the repo, but in general a large timeout would be easier. – Christopher Fuentes Nov 28 '16 at 00:29
2

unbearably slow

You have to update to a new machine. I recommend a SSD drive - it will really speed up your simulator tests.

In addition to RunLoop::Xcrun::DEFAULT_OPTIONS[:timeout] see RunLoop::CoreSimulator::DEFAULT_OPTIONS.

  # These options control various aspects of an app's life cycle on the iOS
  # Simulator.
  #
  # You can override these values if they do not work in your environment.
  #
  # For cucumber users, the best place to override would be in your
  # features/support/env.rb.
  #
  # For example:
  #
  # RunLoop::CoreSimulator::DEFAULT_OPTIONS[:install_app_timeout] = 60
  DEFAULT_OPTIONS = {
    # In most cases 30 seconds is a reasonable amount of time to wait for an
    # install.  When testing larger apps, on slow machines, or in CI, this
    # value may need to be higher.  120 is the default for CI.
    :install_app_timeout => RunLoop::Environment.ci? ? 120 : 30,
    :uninstall_app_timeout => RunLoop::Environment.ci? ? 120 : 30,
    :launch_app_timeout => RunLoop::Environment.ci? ? 120 : 30,
    :wait_for_state_timeout => RunLoop::Environment.ci? ? 120 : 30
  }
jmoody
  • 2,480
  • 1
  • 16
  • 22
  • [Yes, I agree, I do need a new machine. Waiting for the proper department to provide.] Right now, I'm trying to find out how to send xcodebuild a -project option, because my team would like to run tests on several projects and platforms in a unified build system. Is that possible? – Kheldar Mar 04 '16 at 12:16
  • Using xcodebuild is a separate question. Please don't ask questions about other topics in comments - ask a new question. Look at the Makefile and bin/make scripts in these projects https://github.com/calabash/ios-smoke-test-app/tree/master/CalSmokeApp | https://github.com/calabash/Permissions 100% possible. 100% recommended. – jmoody Mar 04 '16 at 13:23