facebook/xctool — pull request #136 by fpotter (2013-08-29 02:02:30+00:00)
Title: make otest-query work with iOS application tests + better error reporting when otest-query fails.

This is from issue #135.

Test bundles for application tests are funky in that they might depend
on symbols provided by the test host / bundle loader application. In
that case, the regular otest-query-ios will fail with `dyld` errors
about symbols it can't find.

Unfortunately we can't just dlopen() the test host to get its symbols,
too. By default, simulator apps are not built as position-independent
code and cannot by dynamically loaded.

The workaround is to...

1) Launch the test host executable so we get its symbols. We make it
load a new library called `otest-query-ios-dylib` which will run
immediately on load (via DYLD_INSERT_LIBRARIES).

2) `otest-query-ios-dylib` will look at the "OtestQueryBundlePath"
environment variable to get the test bundle path, then it dynamically
loads that via dlopen().

3) Then, dump all the test cases just like otest-query normally does.

4) Exit before the test host app can do anything.