Code cleaning.
Merge pull request #320 from facebook/nekto/code_cleaning

Code cleaning.
Use __CFPREFERENCES_AVOID_DAEMON = YES to fix pref clobbering

From @fpotter:

The problem is that preference values are causing SenTestinkgKit + XCTest to prematurely run tests... when all we wanted to do was query the tests in the bundle.

Here's what happens ...

    otest-query loads the test bundle.
    the test bundle links SenTestingKit, so dyld goes a ahead and loads SenTestingKit.
    SenTestingKit has an initialization function (i.e. marked with __attribute__((constructor))), so dyld runs that.
    The initialization function checks to see if the SenTest preference value is set. If so, it starts running tests immediately. (At this point, we haven't even gotten back to otest-query yet - it's still waiting for the bundle to finish loading).
    As soon as SenTestingKit has finished running the tests, it exits. We never return to otest-query.

So, the idea here was to clear the value of the SenTest preference before loading the test bundle. That should work... but it seems to fail intermittently, and I think I now know why.

You would assume the prefs values are read/written from ~/Library/Preferences/<app name>.plist. You would also think that prefs values are never synchronized until you explicitly call /synchronize/. That's what I thought, anyway.

As it turns out, there's actually a system service called cfprefsd that manages preferences and reading/writing them from the Preferences directory. It also caches preference values. If we're running otest-query processes in parallel, and they're each reading/writing via this daemon... it'd be expected for them to eventually stomp on each other.

But, there seems to be a way to disable the daemon usage, so I think we should do that. If you set __CFPREFERENCES_AVOID_DAEMON=YES in the environment before running otest-query, we'll be guaranteed that it won't read data from cfprefsd. That should give us more deterministic behavior. Also, I bet this makes it so that defaults are only synchronized when we explicitly call synchronize.
Merge pull request #321 from LegNeato/master

Use __CFPREFERENCES_AVOID_DAEMON = YES to fix pref clobbering
Fixed parsing for analyze targets
Merge pull request #327 from donaldkwong/master

Fixed parsing for analyze targets
[TextReporter] Print oc unit errors in the failures section

When oc unit error occurs (unable to read build settings for target, fails to query the list of test cases in the test bundle, test bundle contained no tests) the error details are printed only in the stream but aren't then repeated in the failures section. That results in the simple messages like '** TEST FAILED: N passed, 0 failed, 0 errored, N total **' without summarizing failures.
This commit fixes such situations.
on Xcode 5.1, setting env variables is changed from setenv to export
use DTiPhoneSimulatorRemoteClient instead of iPhoneSimulatorRemoteClient

This is working towards the fix for `iPhoneSimulatorRemoteClient` not
working on iOS 7.1 / Xcode 5.1 DP.

It's going to let us pass a lot more info to the iPhone Simulator,
including device name and architecture.
Make xctool compatible with Xcode 5.1

- Respect `-destination` option when running iOS tests.
- Support running test without `-destination` option specified.
- Validate `-destination` option value before running any actions:
1) check whether device with provided `name` exists,
2) check whether iOS sdk with provided `os` version exists,
3) check whether provided device supports provided sdk (only if both os version and device name are provided).
- Add `-destination-timeout` option support.
- Don't update valid `-sdk` flags

Details:
1) Validation of `-destination` option is done using `SimulatorHost.framework`. This frameworks gives us reference to all available sdks and devices.
2) Moved destination option parsing into `XCToolUtil`.
add test for “on Xcode 5.1, setting env variables is changed from setenv to export”
add test for "on Xcode 5.1, setting env variables is changed from setenv to export"
Merge pull request #336 from facebook/nekto/add_xcode51_support

Make xctool compatible with Xcode 5.1
Merge pull request #338 from facebook/nekto/print_ocunit_failures

[TextReporter] Print oc unit errors in the failures section
Merge pull request #341 from yuichi-hamasaki/master

on Xcode 5.1, setting env variables is changed from setenv to export
Improve iPhone simulator system root sdk selection. Code cleaning.

If sdk version is, for example, `7.0.3` and available system root sdk is `7.0` then `[DTiPhoneSimulatorSystemRoot rootWithSDKVersion:sdkVersion];` returns `nil`. To fix that we are now additionally looping through all sdks in `[[ISHDeviceVersions sharedInstance] allSDKs]` and comparing `shortVersionString` with sdk version.

Also removed useless imports and class definitions in `ISH*` headers and fixed import order and spaces usage in some other files.
Merge pull request #345 from facebook/nekto/fix_sdk_system_root

Improve iPhone simulator system root sdk selection. Code cleaning.
Fix for missing @class directives in SimulatorHost classes
Set the same environment values for iOS App and Logic Test Query. Clean main.m of otest-query-ios.

We have found that sometimes we couldn't query tests because 'SenTest' or 'XCTest' frameworks start running them. When it happens we can see errors like this:

  Failed to query the list of test cases in the test bundle: Error while parsing JSON: The data has been corrupted.: {
      stderr = "2014-03-26 11:08:27.405 sim[8792:707] /Applications/xcode_5.0.2.app/Contents/Developer/Platforms/iPhoneSimulator.platform/usr/bin/sim: Simulator does not seem to be running, or may be running an old SDK.\nTest Suite 'All tests' started at 2014-03-26 18:08:28 +0000\nTest Suite 'All tests' finished at 2014-03-26 18:08:28 +0000.\nExecuted 0 tests, with 0 failures (0 unexpected) in 0.000 (0.002) seconds\n";
      stdout = "";
  }

Before we were trying to load the same code in otest-query-ios[osx] and otest-query-lib-ios[osx] but in some cases (especially when testing large code base) xctool wasn't able to query logic tests. It was found that by clearing main.m and not loading OtestQuery in it but dynamically loading otest-query-lib-ios[osx] as we are doing in case of application tests xctool could successfully query tests.
Count ocunit failures as errors in overall test results

We are printing ocunit failures in Failures section but are not counting them as errors in overall test results which could lead to such kind of messages:

  ** RUN-TESTS FAILED: 466 passed, 0 failed, 0 errored, 466 total **

To improve the message we are now counting ocunit failures as errors:

  ** RUN-TESTS FAILED: 466 passed, 0 failed, 30 errored, 496 total **