Giter VIP home page Giter VIP logo

xctool's Introduction

xctool

xctool is an extension for Apple's xcodebuild which makes it easier to test iOS and Mac products. It's especially helpful for continuous integration.

Build Status

[ FeaturesRequirementsUsageContinuous IntegrationReportersConfigurationContributingKnown Issues & TipsLicense ]

Features

xctool is drop-in replacement for xcodebuild test that adds a few extra features:

  • Faster, parallelized test runs.

    xctool can optionally run all of your test bundles in parallel, speeding up your test runs significantly. At Facebook, we've seen 2x and 3x speed ups by parallelizing our runs.

    Use the -parallelize option with run-tests or test to enable. See Parallelizing Test Runs for more info.

  • Structured output of test results.

    xctool captures all test results as structured JSON objects. If you're building a continuous integration system, this means you don't have to regex parse xcodebuild output anymore.

    Try one of the Reporters to customize the output or get the full event stream with the -reporter json-stream option.

  • Human-friendly, ANSI-colored output.

    xcodebuild is incredibly verbose, printing the full compile command and output for every source file. By default, xctool is only verbose if something goes wrong, making it much easier to identify where the problems are.

    Example:

    pretty output

  • Written in Objective-C.

    xctool is written in Objective-C. Mac OS X and iOS developers can easily submit new features and fix any bugs they may encounter without learning a new language. We very much welcome pull requests!

Note: Support for building projects with xctool is deprecated and will not be updated to support future versions of Xcode. We suggest moving to xcodebuild (with xcpretty) for simple needs, or xcbuild for more involved requirements. xctool will continue to support testing (see above).

Requirements

  • Xcode 7 or higher
  • You'll need Xcode's Command Line Tools installed. From Xcode, install via Xcode → Preferences → Downloads.

Installation

xctool can be installed from homebrew via

brew install xctool

or can be downloaded and run via the xctool.sh command.

Usage

xctool's commands and options are mostly a superset of xcodebuild's. In most cases, you can just swap xcodebuild with xctool and things will run as expected but with more attractive output.

You can always get help and a full list of options with:

path/to/xctool.sh -help

Testing

xctool has a run-tests action which knows how to run the tests in your scheme. You can optionally limit what tests are run or change the SDK they're run against.

To run all tests in your scheme, you would use:

path/to/xctool.sh \
  -workspace YourWorkspace.xcworkspace \
  -scheme YourScheme \
  run-tests

To run just the tests in a specific target, use the -only option:

path/to/xctool.sh \
  -workspace YourWorkspace.xcworkspace \
  -scheme YourScheme \
  run-tests -only SomeTestTarget

You can go further and just run a specific test class:

path/to/xctool.sh \
  -workspace YourWorkspace.xcworkspace \
  -scheme YourScheme \
  run-tests -only SomeTestTarget:SomeTestClass

Or, even further and run just a single test method:

path/to/xctool.sh \
  -workspace YourWorkspace.xcworkspace \
  -scheme YourScheme \
  run-tests -only SomeTestTarget:SomeTestClass/testSomeMethod

You can also specify prefix matching for classes or test methods:

path/to/xctool.sh \
  -workspace YourWorkspace.xcworkspace \
  -scheme YourScheme \
  run-tests -only SomeTestTarget:SomeTestClassPrefix*,SomeTestClass/testSomeMethodPrefix*

Alternatively, you can omit a specific item by prefix matching for classes or test methods:

path/to/xctool.sh \
  -workspace YourWorkspace.xcworkspace \
  -scheme YourScheme \
  run-tests -omit SomeTestTarget:SomeTestClass/testSomeMethodPrefix*

You can also run tests against a different SDK:

path/to/xctool.sh \
  -workspace YourWorkspace.xcworkspace \
  -scheme YourScheme \
  run-tests -test-sdk iphonesimulator5.1

Optionally you can specify -testTimeout when running tests. When an individual test hits this timeout, it is considered a failure rather than waiting indefinitely. This can prevent your test run from deadlocking forever due to misbehaving tests.

By default application tests will wait at most 30 seconds for the simulator to launch. If you need to change this timeout, use the -launch-timeout option.

Building Tests

Before running tests you need to build them. You can use xcodebuild, xcbuild or Buck to do that.

For example:

xcodebuild \
  -workspace YourWorkspace.xcworkspace \
  -scheme YourScheme \
  build-for-testing
Xcode 7

If you are using Xcode 7 for building you can continue using xctool to build tests using build-tests or just use test actions to run tests.

For example:

path/to/xctool.sh \
  -workspace YourWorkspace.xcworkspace \
  -scheme YourScheme \
  build-tests

You can optionally just build a single test target with the -only option:

path/to/xctool.sh \
  -workspace YourWorkspace.xcworkspace \
  -scheme YourScheme \
  build-tests -only SomeTestTarget

Parallelizing Test Runs

xctool can optionally run unit tests in parallel, making better use of otherwise idle CPU cores. At Facebook, we've seen 2x and 3x gains by parallelizing our test runs.

To allow test bundles to run concurrently, use the -parallelize option:

path/to/xctool.sh \
  -workspace YourWorkspace.xcworkspace \
  -scheme YourScheme \
  run-tests -parallelize

The above gives you parallelism, but you're bounded by your slowest test bundle. For example, if you had two test bundles ('A' and 'B'), but 'B' took 10 times as long to run because it contained 10 times as many tests, then the above parallelism won't help much.

You can get further gains by breaking your test execution into buckets using the -logicTestBucketSize option:

path/to/xctool.sh \
  -workspace YourWorkspace.xcworkspace \
  -scheme YourScheme \
  run-tests -parallelize -logicTestBucketSize 20

The above will break your test execution into buckets of 20 test cases each, and those bundles will be run concurrently. If some of your test bundles are much larger than others, this will help even things out and speed up the overall test run.

Building (Xcode 7 only)

Note: Support for building projects with xctool is deprecated and isn't supported in Xcode 8 and later. We suggest moving to xcodebuild (with xcpretty) for simple needs, or xcbuild for more involved requirements. Alternatively, you can use Buck.

Building products with xctool is the same as building them with xcodebuild.

If you use workspaces and schemes:

path/to/xctool.sh \
  -workspace YourWorkspace.xcworkspace \
  -scheme YourScheme \
  build

If you use projects and schemes:

path/to/xctool.sh \
  -project YourProject.xcodeproj \
  -scheme YourScheme \
  build

All of the common options like -configuration, -sdk, -arch work just as they do with xcodebuild.

NOTE: xctool doesn't support directly building targets using -target; you must use schemes.

Continuous Integration

xctool is an excellent choice for running your tests under a continuous integration server such as Travis CI or Jenkins. To run tests within a continuous integration environment, you must create Shared Schemes for your application target and ensure that all dependencies (such as CocoaPods) are added explicitly to the Scheme. To do so:

  1. Open up the Manage Schemes sheet by selecting the Product menu > Schemes > Manage Schemes...
  2. Locate your application target in the list. Ensure that the Shared checkbox in far right hand column of the sheet is checked.
  3. If your application or test targets include cross-project dependencies such as CocoaPods, then you will need to ensure that they have been configured as explicit dependencies. To do so:
    1. Highlight your application target and hit the Edit... button to open the Scheme editing sheet.
    2. Click the Build tab in the left-hand panel of the Scheme editor.
    3. Click the + button and add each dependency to the project. CocoaPods will appear as a static library named Pods.
    4. Drag the dependency above your application target so that it is built first.

You will now have a new file in the xcshareddata/xcschemes directory underneath your Xcode project. This is the shared Scheme that you just configured. Check this file into your repository and xctool will be able to find and execute your tests on the next CI build.

Example Travis CI Configuration

Travis CI is a very popular continuous integration system offered for free to Open Source projects. It integrates well with Github, and it now uses xctool as the default build and test tool for Objective-C projects. Once you have set up your shared Scheme for use with xctool, you will need to configure a .travis.yml file.

If you're using workspaces, your .travis.yml might be:

language: objective-c
xcode_workspace: path/to/YourApp.xcworkspace
xcode_scheme: YourApp

If you're using projects, your .travis.yml might be:

language: objective-c
xcode_project: path/to/YourApp.xcodeproj
xcode_scheme: YourApp

For more flexibility, you can also control how Travis installs and invokes xctool:

language: objective-c
before_install:
    - brew update
    - brew install xctool
script: xctool -workspace MyApp.xcworkspace -scheme MyApp test

You can learn more about the Travis CI environment for iOS and OS X application by referring to the About OS X Travis CI Environment document and find in-depth documentation for configuring your project by consulting the Getting Started page.

Reporters

xctool has reporters that output build and test results in different formats. If you do not specify any reporters yourself, xctool uses the pretty and user-notifications reporters by default. xctool also has these special rules:

  • Overwrite is disabled on the pretty reporter when xctool does not detect a TTY. This can be overridden by setting XCTOOL_FORCE_TTY in the environment.
  • The user-notifications reporter will not be used if xctool detects that the build is being run by Travis CI, CircleCI, TeamCity, or Jenkins (i.e. TRAVIS=true, CIRCLECI=true, TEAMCITY_VERSION, or JENKINS_URL in the environment).

You can choose your own reporters with the -reporter option:

path/to/xctool.sh \
  -workspace YourWorkspace.xcworkspace \
  -scheme YourScheme \
  -reporter plain \
  build

By default, reporters output to standard out, but you can also direct the output to a file by adding :OUTPUT_PATH after the reporter name:

path/to/xctool.sh \
  -workspace YourWorkspace.xcworkspace \
  -scheme YourScheme \
  -reporter plain:/path/to/plain-output.txt \
  build

You can use as many reporters as you like; just use the -reporter option multiple times.

Included Reporters

  • pretty: a text-based reporter that uses ANSI colors and unicode symbols for pretty output (the default).
  • plain: like pretty, but with no colors or unicode.
  • phabricator: outputs a JSON array of build/test results which can be fed into the Phabricator code-review tool.
  • junit: produces a JUnit/xUnit compatible XML file with test results.
  • json-stream: a stream of build/test events as JSON dictionaries, one per line (example output).
  • json-compilation-database: outputs a JSON Compilation Database of build events which can be used by Clang Tooling based tools, e.g. OCLint.
  • user-notifications: sends notification to Notification Center when action is completed (example notifications).
  • teamcity: sends service messages to TeamCity Continuous Integration Server

Implementing Your Own Reporters

You can also implement your own reporters using whatever language you like. Reporters in xctool are separate executables that read JSON objects from STDIN and write formatted results to STDOUT.

You can invoke reporters by passing their full path via the -reporter option:

path/to/xctool.sh \
  -workspace YourWorkspace.xcworkspace \
  -scheme YourScheme \
  -reporter /path/to/your/reporter \
  test

For example, here's a simple reporter in Python that outputs a period for every passing test and an exclamation mark for every failing test:

#!/usr/bin/python

import fileinput
import json
import sys

for line in fileinput.input():
    obj = json.loads(line)

    if obj['event'] == 'end-test':
        if obj['succeeded']:
            sys.stdout.write('.')
        else:
            sys.stdout.write('!')

sys.stdout.write('\n')

If you're writing a reporter in Objective-C, you'll find the Reporter class helpful - see Reporter.h.

Configuration (.xctool-args)

If you routinely need to pass many arguments to xctool on the command-line, you can use an .xctool-args file to speed up your workflow. If xctool finds an .xctool-args file in the current directory, it will automatically pre-populate its arguments from there.

The format is just a JSON array of arguments:

[
  "-workspace", "YourWorkspace.xcworkspace",
  "-scheme", "YourScheme",
  "-configuration", "Debug",
  "-sdk", "iphonesimulator",
  "-arch", "i386"
]

Any extra arguments you pass on the command-line will take precedence over those in the .xctool-args file.

Contributing

Bug fixes, improvements, and especially new Reporter implementations are welcome. Before submitting a pull request, please be sure to sign the Facebook Contributor License Agreement. We can't accept pull requests unless it's been signed.

Workflow

  1. Fork.
  2. Make a feature branch: git checkout -b my-feature
  3. Make your feature. Keep things tidy so you have one commit per self-contained change (squashing can help).
  4. Push your branch to your fork: git push -u origin my-feature
  5. Open GitHub, under "Your recently pushed branches", click Pull Request for my-feature.

Be sure to use a separate feature branch and pull request for every self-contained feature. If you need to make changes from feedback, make the changes in place rather than layering on commits (use interactive rebase to edit your earlier commits). Then use git push --force origin my-feature to update your pull request.

Workflow (for Facebook people, other committers)

Mostly the same, but use branches in the main xctool repo if you prefer. It's a nice way to keep things together.

  1. Make a feature branch: git checkout -b myusername/my-feature
  2. Push your branch: git push -u origin myusername/my-feature
  3. Open GitHub to facebook/xctool, under "Your recently pushed branches", click Pull Request for myusername/my-feature.

Known Issues & Tips

  • Use shared schemes and disable the Autocreate Schemes feature.

    Xcode has two kinds of schemes: shared, and user. User schemes are the default, and they're stored under a folder called USERNAME.xcuserdatad, which most people correctly add to their .gitignore.

    Use shared schemes instead, and commit them to your repo. This way everyone on your team (and your build server) are working from the same information, and are building in the same way.

    example

  • Make sure simulators run in a GUI context.

    If you are running xctool in continuous integration, the user account calling xctool must have an active GUI context. If not, the simulator will fail to start with cryptic warnings like:

    Tried to install the test host app 'com.myapp.test' but failed.
    Preparing test environment failed.
    -[TEST_BUNDLE FAILED_TO_START] 
    There was a problem starting the test bundle: Simulator 'iPhone 6' was not prepared: Failed for unknown reason.
    Test did not run: Simulator 'iPhone 6' was not prepared: Failed for unknown reason.
    2015-01-21 12:02:19.296 xcodebuild[35135:875297]  iPhoneSimulator: Timed out waiting 120 seconds for simulator to boot, current state is 1.
    Testing failed:
    Test target MyProjectTests encountered an error (Timed out waiting 120 seconds for simulator to boot, current state is 1.  
    

    Note that the same holds true with xcodebuild...this is not xctool specific.

    For more information, see this post by Jason Jarrett.

License

Copyright 2014-present Facebook

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or at:

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

xctool's People

Contributors

alanzeino avatar bhamiltoncx avatar carsonmcdonald avatar cpeterso87 avatar cysp avatar extrememan avatar facebook-github-bot avatar fpotter avatar ghvg1313 avatar gomazaba avatar grp avatar jesboat avatar jmattdavenport avatar jmkk avatar jonnyyu avatar jspahrsummers avatar kcoons avatar legneato avatar lqi avatar ma2bd avatar mattjgalloway avatar msch avatar ndfred avatar pavelkatunin avatar plu avatar ryanrhee avatar sameenai avatar swolchok avatar yiding avatar zlandau avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xctool's Issues

iOS project with unit tests + xctool + Jenkins => issue

When running the command below from the terminal

xctool/xctool.sh -project SampleWithTest.xcodeproj -scheme SampleWithTest -reporter junit:test-reports/junit-report.xml clean test

It works fine, I can see the iOS simulator launching and displayed on screen and its opening the app for a fraction of second , executing the tests and the report xml is then generated.

However, when I run the exact same command from Jenkins using the Build -> Execute Shell script under the Job Configuration then
I can see the iOS Simulator launching in the Dock but its never displayed on screen. The script then seems to timeout for an unknown reason and the report xml is not generated.
There isn't any errors in the console log in Jenkins. I'm a bit out of ideas here.

xctool can't build workspaces that have projects targeting different SDKs.

Before it starts building, it picks a single SDK for building all projects in a workspace. This is fine most of the time as most workspaces only contain iOS projects or Mac projects. If a workspace has both, though, some projects will get built with the wrong SDK.

This bug is also the reason why xctool can't build itself :-(

junit reporter generates invalid XML

If a Mac OS X workspace contains multiple projects with multiple test targets, the junit reporter creates XML processing header instructions within an ongoing XML file. It looks like this:

bildschirmfoto 2013-05-31 um 17 24 31

Attempt to mutate an immutable string

-[TestConsoleReported endTest:] line 71, we pull out NSMutableString *details = event[kReporter_EndTest_OutputKey]; and call -appendFormat:

Ran into this:

2013-06-23 15:49:39.675 xctool[57294:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Attempt to mutate immutable object with appendFormat:'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff8e6aeb06 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff90a9a3f0 objc_exception_throw + 43
2 CoreFoundation 0x00007fff8e6ae8dc +[NSException raise:format:] + 204
3 CoreFoundation 0x00007fff8e70c91e mutateError + 110
4 CoreFoundation 0x00007fff8e6d68b8 -[__NSCFString appendFormat:] + 136
5 xctool 0x000000010e94270a -[TestConsoleReporter endTest:] + 298
6 xctool 0x000000010e92ce19 -[Reporter handleEvent:] + 736
7 xctool 0x000000010e9416bb -[BufferedReporter flush] + 193
8 xctool 0x000000010e935ecd __125-[RunTestsAction blockForTestable:reporters:objRoot:symRoot:sharedPrecompsDir:xcodeArguments:senTestList:senTestInvertScope:]_block_invoke + 2828
9 xctool 0x000000010e936744 -[RunTestsAction runTestables:options:xcodeSubjectInfo:] + 869
10 xctool 0x000000010e9345aa -[RunTestsAction performActionWithOptions:xcodeSubjectInfo:] + 897
11 xctool 0x000000010e927f69 -[XCTool run] + 1840
12 xctool 0x000000010e927250 main + 244
13 xctool 0x000000010e927154 start + 52
14 ??? 0x000000000000001f 0x0 + 31
)

It's better practice to -mutableCopy the string we pull out the dictionary. In addition we should make a real class to formalize the object we pass around, rather than throwing anything in a dictionary.

Tests for static libraries

It seems that tests for static libraries aren't supported. xctool currently outputs

/Applications/Xcode.app/Contents/Developer/Tools/RunUnitTests:68: note: RunUnitTests exited without running tests because TEST_AFTER_BUILD was set to NO.

If you pass TEST_AFTER_BUILD=1 you get

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Tools/Tools/RunPlatformUnitTests:81: warning: Skipping tests; the iPhoneSimulator platform does not currently support application-hosted tests (TEST_HOST set).

I currently work around this issue by modifying the "Run Script" phase of the test target in the following way:

set -e
if [ "$RUN_UNIT_TEST_WITH_IOS_SIM" = "YES" ]; then
test_bundle_path="$BUILT_PRODUCTS_DIR/$PRODUCT_NAME.$WRAPPER_EXTENSION"
SOURCE_DIRECTORY=$SRCROOT
echo sim --sdk=6.1  $SDKROOT/Developer/usr/bin/otest -NSTreatUnknownArgumentsAsOpen NO -ApplePersistenceIgnoreState YES -SenTest Self $CODESIGNING_FOLDER_PATH
sim --sdk=6.1  $SDKROOT/Developer/usr/bin/otest -NSTreatUnknownArgumentsAsOpen NO -ApplePersistenceIgnoreState YES -SenTest Self $CODESIGNING_FOLDER_PATH
else
"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests"
fi

and then passing the argument RUN_TESTS_WITH_IOS_SIM=YES.

Note that this workaround uses several completely undocumented SDK tools. I have reverse-engineered them enough to find the correct arguments, but I have no idea how stable this is for future SDKs.

xctool fails to build when a configuration file is specified

When running:

xctool -xcconfig Frank/frankify.xcconfig build -workspace "xcworkspace" \
-scheme "scheme" -arch i386  -sdk iphonesimulator

xctool returns:

Assertion failed: (settings.count == 1), function -[XcodeSubjectInfo populate], \
file /tmp/xctool-wqex/xctool-0.1.2/xctool/xctool/XcodeSubjectInfo.m, line 596.
Abort trap: 6

XCToolUtil.m:BuildSettingsFromOutput appears to skip past the command line build settings, but doesn't try and skip past any build settings specified from a configuration file. It fails when 'Build settings for action build and target' isn't at the current scan location as expected and 'Build settings from configuration file 'Frank/frankify.xcconfig':' is instead. Of course, just skipping past the configuration file settings is only safe if those settings are somehow taken into account elsewhere.

The relevant portion of -showBuildSettings:

Build settings from command line:
    ARCHS = i386
    SDKROOT = iphonesimulator6.1

Build settings from configuration file 'Frank/frankify.xcconfig':
    FRANK_LDFLAGS = -all_load -ObjC -framework CFNetwork -framework Security -lShelley -lFrank -lShelley -lCocoaAsyncSocket -lCocoaHTTPServer -lFrank
    FRANK_MAC_LDFLAGS = -all_load -ObjC -framework CFNetwork -framework Security -lShelleyMac -lFrankMac -lCocoaAsyncSocketMac -lCocoaHTTPServerMac -lFrankMac
    GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = FRANKIFIED
    INSTALL_PATH = /./
    RUN_CLANG_STATIC_ANALYZER = NO

Build settings for action build and target "Target":
    ACTION = build
    ALTERNATE_GROUP = staff
    ...
    YACC = yacc

The issue is also present when not passing build settings from the command line, when running:

xctool -xcconfig Frank/frankify.xcconfig build -workspace "xcworkspace" \
-scheme "scheme"

In which case -showBuildSettings is:

Build settings from configuration file 'Frank/frankify.xcconfig':
    FRANK_LDFLAGS = -all_load -ObjC -framework CFNetwork -framework Security -lShelley -lFrank -lShelley -lCocoaAsyncSocket -lCocoaHTTPServer -lFrank
    FRANK_MAC_LDFLAGS = -all_load -ObjC -framework CFNetwork -framework Security -lShelleyMac -lFrankMac -lCocoaAsyncSocketMac -lCocoaHTTPServerMac -lFrankMac
    GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = FRANKIFIED
    INSTALL_PATH = /./
    RUN_CLANG_STATIC_ANALYZER = NO

Build settings for action build and target "Target":
    ACTION = build
    ALTERNATE_GROUP = staff
    ...
    YACC = yacc

EDIT: I should mention that the above applies to the 0.1.2 release.

ld: library not found for -lPods

First of all: thanks for the great tool! I'm really exited about it! :)

Just found a problem with compiling/linking when using Cocoapods.

Given

Project FooBar with two targets FooBar and FooBarTests. I'm using Cocoapods and have some pods specified exclusively for FooBarTests target. Here is a Podfile:

platform :ios

pod 'MTDates'

target :FooBarTests, :exclusive => true do
  pod 'Kiwi'
end

There is a scheme called FooBar. It was created by Xcode automatically and it supports Test action.

Steps

  1. Open FooBar.xcworkspace
  2. Do Clean ("Product" => "Clean" in Xcode)
  3. Run tests from command line with command:
    ../xctool/xctool.sh -workspace FooBar.xcworkspace -scheme FooBar test

Expected

Tests run successfully.

Result

      ✗ Link FooBar (14 ms)
━━━━━━━━━━━
Ld /Users/yas/Library/Developer/Xcode/DerivedData/FooBar-ajkeysuvkvwfhjgmubnbplcrxzfl/Build/Products/Debug-iphonesimulator/FooBar.app/FooBar normal i386
    cd /Users/yas/code/FooBar
    setenv IPHONEOS_DEPLOYMENT_TARGET 6.1
    setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk -L/Users/yas/Library/Developer/Xcode/DerivedData/FooBar-ajkeysuvkvwfhjgmubnbplcrxzfl/Build/Products/Debug-iphonesimulator -F/Users/yas/Library/Developer/Xcode/DerivedData/FooBar-ajkeysuvkvwfhjgmubnbplcrxzfl/Build/Products/Debug-iphonesimulator -filelist /Users/yas/Library/Developer/Xcode/DerivedData/FooBar-ajkeysuvkvwfhjgmubnbplcrxzfl/Build/Intermediates/FooBar.build/Debug-iphonesimulator/FooBar.build/Objects-normal/i386/FooBar.LinkFileList -Xlinker -objc_abi_version -Xlinker 2 -ObjC -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=6.1 -framework UIKit -framework Foundation -framework CoreGraphics -lPods -o /Users/yas/Library/Developer/Xcode/DerivedData/FooBar-ajkeysuvkvwfhjgmubnbplcrxzfl/Build/Products/Debug-iphonesimulator/FooBar.app/FooBar

ld: library not found for -lPods
clang: error: linker command failed with exit code 1 (use -v to see invocation)

See full log

Workaround

Run tests from Xcode once. It will compile libPods and libPods-FooBarTests. After that you can run tests from command line.

Conclusion

Here is a screencast Before I run tests first time with xctool is was already run from Xcode (cmd+u) and the libs were compiled. Then I've did "Clean" and after that xctool fails :(

Here is a test project It's a git repo. So you can see the steps I did to create the project.

Any chance to get it fixed? Thanks in advance! =)
I would be happy to help more. Just let me know how! (I don't know hot to fix it :) )

/cc @alloy @krzysztofzablocki

Using more than one reporter at once?

Is it possible to tell xctool to use more than one reporter at once? I understand it was possible based on this sentence on the readme (although it's kind of cryptic):

You can change or add reporters with the -reporter option:

I tried doing both:

$ xctool -reporter pretty:output.txt -reporter json-stream:~/Desktop/test.json -reporter junit:tests.xml

and

$ xctool -reporter pretty:output.txt json-stream:~/Desktop/test.json junit:tests.xml

and it seems to only read the first one? I think this would be a nice thing to have. e.g.: outputing to the std output and also creating some json/xml files for your CI tool to parse.

after updating to xctool 0.1.4 clean stage fails without any error

System: MacOS X 10.8.3, 10.8.4, XCode 4.6.2, XCode 4.6.3

After upgrading xctool from 0.1.2 to 0.1.4 clean stage fails without any errors - all green checkmarks. But build stage works OK.

so

xctool -workspace $workspace -scheme UITests -sdk $1 DEPLOYMENT_LOCATION=YES ONLY_ACTIVE_ARCH=NO DSTROOT=build TARGETED_DEVICE_FAMILY=1 clean build ==> fails on clean stage

xctool -workspace $workspace -scheme UITests -sdk $1 DEPLOYMENT_LOCATION=YES ONLY_ACTIVE_ARCH=NO DSTROOT=build TARGETED_DEVICE_FAMILY=1 build => works

How can I provide additional logging?

xctool somehow missed dependencies that xcodebuild got

I haven't dug into this at all, but I had the following situation (names changed for generalization):

I had a project with a simple Podfile:

target :Tests do
  pod 'Kiwi'
  pod 'Expecta'
end

Even with the Tests target adding the Pods-Tests target as an explicit dependency the following kept failing on Travis with a fresh clone:

$ pod install
$ xctool -workspace Tests.xcworkspace -scheme Tests test

whereas the following succeeds

$ pod install
$ xcodebuild -workspace Tests.xcworkspace -scheme Tests test

The former would somehow refuse to build the Pods target, though potentially interestingly the following:

$ pod install
$ xctool -workspace Tests.xcworkspace -scheme Tests clean test

Shows the Pods target as being cleaned, but it doesn't appear in the build before a linking error causes it to crap out.

Anyone have any ideas what's going on?

Running into assertion failure

I try to build a complex project with the following command:

xctool -workspace MyWorkspace.xcworkspace -scheme MyScheme

I am getting the following output:

Assertion failed: (settings.count == 1), function -[XcodeSubjectInfo populate], file /Users/frank/Downloads/xctool-master/xctool/xctool/XcodeSubjectInfo.m, line 596.
Abort trap: 6

xctool should print status messages around expensive operations.

xctool does some things (like calling -showBuildSettings) which take a long time, but which aren't surfaced to reporters or logs.

e.g., it'd be nice if you could see info like...

=== BUILD ===
  Gathering build settings (1035 ms) <-- WANT THIS

  xcodebuild build build
    OSXLibrary / OSXLibrary (Debug)
      ✓ Check dependencies (41 ms)
      ✓ Precompile OSXLibrary-Prefix.pch (616 ms)

There are other places we want this, too - like launching simulator tests.

Run test specifying class file will blocks forever, if the supplied class do not exists

I have a project having some tests. I tried to run one of them by supply class name.

If i specify a class name that do not exists, I expect the command failed with message like class not found. But instead xctool blocks and never returned.

xctool test -only MyTests:TestClassThatDoNotExists
=== TEST ===
...
  run-test MyTests.octest (iphonesimulator6.1, logic-test, GC OFF)
... (blocks forever)

xctool doesn't accept xcodebuild's -destination option

-arch i386 VALID_ARCHS="i386" \
PLATFORM_NAME="iphonesimulator" \
OBJROOT="${BUILD_DIR}/Intermediates" \
SYMROOT="${BUILD_DIR}/Products" \
SHARED_PRECOMPS_DIR="${BUILD_DIR}/Intermediates/PrecompiledHeaders" \
-destination OS=5.0,name=iPhone \
clean build test
ERROR: Unexpected action: -destination

OCUnit Test Produces "Abort Trap: 6"

Running xctool with the following .xctool-args:

[
  "-find-target", "UnitTests",
  "-configuration", "Debug",
  "-sdk", "iphonesimulator",
  "-arch", "i386"
]

with this command:

$ /ourxctoolpath/xctool.sh test

produces results:

[Info] Found target UnitTests. Using project path OurProject.xcodeproj, scheme UnitTests. (997 ms)

=== TEST ===

[Info] Collecting build settings ... (635 ms)
Assertion failed: (settings.count == 1), function -[XcodeSubjectInfo populate], file /ourxctoolpath/xctool/xctool/XcodeSubjectInfo.m, line 774.
/ourxctoolpath/xctool.sh: line 54: 10074 Abort trap: 6          "$XCTOOL_DIR"/build/$REVISION/Products/Release/xctool "$@"

add 'analyze' action that emits structured output from the clang static analyzer

I think the -[IDEActivityLogSection messages] method might contain some nicely structured analyzer info.

See --
https://github.com/facebook/xctool/blob/b081ed900de59b504002ebd1a676de102b0b37b9/xcodebuild-shim/xcodebuild-shim/xcodebuild_shim.m#L67

When I looked last, it seemed to include an item for everything that gets shown in the "Issue Navigator" thingy on the left hand side. (That pane that lets you jump to build warnings/errors).

Add Versioning

I created a formula for Homebrew that helps installing the script.

For it to be accepted xctool needs to be versioned, which is generally a good idea :)

Please see Homebrew/legacy-homebrew#19590

Thanks for your effort in this!

JUnit reporter writing a 0 byte XML

I'm currently doing:

$ xctool -sdk iphonesimulator -workspace ${WORKSPACE} -scheme "$scheme" -configuration "$config" -reporter junit:tests.xml

Tests run, it creates a tests.xml file, but it's empty. I understand this doesn't give a ton of info, what other info can I give you to help you figure out what's going on here?

FWIW other reporters are working fine.

Add ability to fail xctool build on static analyzer warnings

I saw recently in #78 that xctool now has the ability to run the static analyzer as part of the build, with a new analyze action. This would be a great addition to the existing functionality.

I haven't been able to figure out how to actually fail the build if there are static analyzer warnings. Looking at AnalyzeAction, it seems to return successfully even if there are analyzer warnings to emit.

Could AnalyzeAction fail if it detected warnings? (possibly needs to be optional for projects that don't fix all of the analyzer warnings)

Compatibility with Travis-CI

I am currently experienced unstable behavior when attempting to run tests from Travis-CI. xctool consistently throws the following NSInternalInconsistencyException:

Failed getting contents of directory: Error Domain=NSCocoaErrorDomain Code=260 "The folder “DiagnosticReports” doesn’t exist."
[...]

See full Travis build log and the project for which I attempt to run tests.

As a test I commented the assertion in OCUnitTestRunner.m:70 to omit the exception. This allows my tests to be run properly for now, but is probably not the way to go.

clean failing because of a sub-project's scheme named Tests

I'm not completely sure why this doesn't work.

xctool -project "StatusBoard.xcodeproj" -configuration "Debug" -scheme "StatusBoard" clean  ONLY_ACTIVE_ARCH=NO ARCHS="armv7 armv7s" SYMROOT="/Users/james/Developer/statusboard/build" OTHER_CODE_SIGN_FLAGS="--keychain=/Users/james/Library/Keychains/buildbot.keychain"

it cleans everything and then i get this

  [Info] Collecting build settings ... (3074 ms)
  xcodebuild build clean
-
Failed to build workspace Tests with scheme Tests.
    Reason: Scheme "Tests" is not configured for running.
-

The Statusboard project doesn't contain a scheme named Tests but one if it's dependent projects does. It's not clear to me why it's trying to do anything with a scheme named 'Tests' when I specified the scheme named 'StatusBoard' in the command.

Using the build command succeeds with the same arguments.

'NSInternalInconsistencyException' reason: 'Unexpected SDK: (null)' thrown when attempting to run Application Tests

I'm seeing the following exception when I try and run my Application Tests.

I run it from command line with the following arguments:
[
"-workspace", "MyWorkspace.xcworkspace",
"-scheme", "MyScheme",
"-configuration", "Debug",
"-sdk", "iphonesimulator",
"-arch", "i386"
]

=== RUN-TESTS ===

2013-05-06 23:45:10.309 xctool[86174:707] *** Assertion failure in -[RunTestsAction runTestable:reproters:objRoot:symRoot:sharedPrecompsDir:xcodeArguments:testSDK:freshSimulator:freshInstall:senTestList:senTestInvertScope:], /Users/glen.tregoning/Source/thirdparty/xctool/xctool/xctool/RunTestsAction.m:247
2013-05-06 23:45:10.310 xctool[86174:707] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unexpected SDK: (null)'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff920370a6 __exceptionPreprocess + 198
    1   libobjc.A.dylib                     0x00007fff959b23f0 objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff92036ee8 +[NSException raise:format:arguments:] + 104
    3   Foundation                          0x00007fff926b26a2 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 189
    4   xctool                              0x0000000108f2dae3 -[RunTestsAction runTestable:reproters:objRoot:symRoot:sharedPrecompsDir:xcodeArguments:testSDK:freshSimulator:freshInstall:senTestList:senTestInvertScope:] + 988
    5   xctool                              0x0000000108f2e354 -[RunTestsAction runTestables:testSDK:freshSimulator:freshInstall:options:xcodeSubjectInfo:] + 515
    6   xctool                              0x0000000108f2d6d8 -[RunTestsAction performActionWithOptions:xcodeSubjectInfo:] + 960
    7   xctool                              0x0000000108f22724 -[XCTool run] + 1755
    8   xctool                              0x0000000108f21a60 main + 244
    9   xctool                              0x0000000108f21964 start + 52
)
libc++abi.dylib: terminate called throwing an exception
/Users/glen.tregoning/Source/thirdparty/xctool/xctool.sh: line 48: 86174 Abort trap: 6           "$XCTOOL_DIR"/build

run-tests will crash if build-tests is not called first.

Application Specific Information:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[1]'
terminate called throwing an exception
abort() called


Application Specific Backtrace 1:
0   CoreFoundation                      0x00007fff8b6b3b06 __exceptionPreprocess + 198
1   libobjc.A.dylib                     0x00007fff8de753f0 objc_exception_throw + 43
2   CoreFoundation                      0x00007fff8b666117 -[__NSPlaceholderArray initWithObjects:count:] + 119
3   CoreFoundation                      0x00007fff8b678ad0 +[NSArray arrayWithObjects:count:] + 48
4   xctool                              0x000000010e2ef4ae -[OCUnitIOSAppTestRunner runTestsAndFeedOutputTo:gotUncaughtSignal:error:] + 992
5   xctool                              0x000000010e2f06f7 -[OCUnitTestRunner runTestsWithError:] + 280
6   xctool                              0x000000010e2fa956 __125-[RunTestsAction blockForTestable:reporters:objRoot:symRoot:sharedPrecompsDir:xcodeArguments:senTestList:senTestInvertScope:]_block_invoke + 1381
7   xctool                              0x000000010e2fb774 -[RunTestsAction runTestables:options:xcodeSubjectInfo:] + 869
8   xctool                              0x000000010e2f95da -[RunTestsAction performActionWithOptions:xcodeSubjectInfo:] + 897
9   xctool                              0x000000010e2ecf99 -[XCTool run] + 1840
10  xctool                              0x000000010e2ec280 main + 244
11  xctool                              0x000000010e2ec184 start + 52

Enable Support for Implicit Dependencies

Over the last several weeks I have configured a test and CI environment for AFNetworking on top of xctool and converted my existing RestKit test harness over using xctool (instead of xcoder). Both projects have testing dependencies on CocoaPods.

Everything was working for awhile then last week both test suites started breaking because of an inability to link the CocoaPods targets. Both projects have shared schemes that are copied into the Travis build path and are failing with the error "library not found for -lPods-osx"

@alloy and I have had a conversation going back on forth on AFNetworking/AFNetworking@57074f2 discussing the failures. He believes that the issue is that CocoaPods installations on the Travis CI build is producing UUID's that differ from the shared schemes, causing the build to fail.

UUID reuse is on the roadmap for CocoaPods, but is not a trivial matter. Is it possible to add support for implicit dependencies to xctool to match the behavior of xcodebuild? I'd be happy to jump in and champion the dev if bandwidth is an issue.

xcodebuild still running after xctool killed

hi,
xctool seems not killing xcode when itself gets killed. So every time when I need kill a build, I need kill xctool and xcodebuild. Also this makes CI server cannot kill the actual xcodebuild process.

Could someone take a look at this?
Thanks!

Get Path to build folder for code coverage

Hi how can I get the path to project build folder when I run the Test action

I want to generate code coverage reports from the files located in the build folder of xcode DerivedData (/Build/Intermediates/ProjectName.build/Debug-iphonesimulator/ProjectName.build/Objects-normal/i386)

I tried to useCONFIGURATION_BUILD_DIR=ProjectFolder/build/ but only the .app and .octest files are copied to the build folder

Thanks

Choose test simulator device

When I run my tests with

xctool.sh -workspace my-workspace -scheme my-app -sdk iphonesimulator clean test

My tests are always run in the iPhone 3.5" simulator. Is it possible to a simulator device to test against?

test and build-tests options do not build dependent targets

I am developing a complex OS X application whose tests depend on a number of frameworks. When I build them using "xcodebuild test -workspace MyWorkspace -scheme MyScheme" all dependent frameworks are built first.
"xctool test" however tries to build the targets in the order they are listed in the build scheme, ignoring all dependencies.
This does not occur when I use "xctool build".

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: ''test-output' event should only come during a test.'

For one of my test cases I'm running into an issue with xctool failing because some of the test cleanup results in printout to the log after the test is complete.

Ideally xctool would be robust to this and not throw an exception.

<snip>
      ✓ -[APITests testDoStuff] (0 ms)

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

2013-05-07 18:38:50.757 otest[15788:4403] DDLogFileInfo: Error renaming file (log-1DA7CC.txt): Error Domain=NSCocoaErrorDomain Code=516 "The operation couldn’t be completed. (Cocoa error 516.)" UserInfo=0xe50f5e0 {NSSourceFilePathErrorKey=/Users/me/Library/Application Support/iPhone Simulator/6.1/Library/Caches/Logs/log-1DA7CC.txt, NSUserStringVariant=(
    Move
), NSFilePath=/Users/me/Library/Application Support/iPhone Simulator/6.1/Library/Caches/Logs/log-1DA7CC.txt, NSDestinationFilePath=/Users/me/Library/Application Support/iPhone Simulator/6.1/Library/Caches/Logs/log-1DA7CC.archived.txt, NSUnderlyingError=0xe50f140 "The operation couldn’t be completed. File exists"}
2013-05-07 18:38:50.765 xctool[15772:707] *** Assertion failure in -[OCUnitCrashFilter handleEvent:], /Users/me/Source/thirdparty/xctool/xctool/xctool/OCUnitCrashFilter.m:92
2013-05-07 18:38:50.795 xctool[15772:707] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: ''test-output' event should only come during a test.'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff920370a6 __exceptionPreprocess + 198
    1   libobjc.A.dylib                     0x00007fff959b23f0 objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff92036ee8 +[NSException raise:format:arguments:] + 104
    3   Foundation                          0x00007fff926b26a2 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 189
    4   xctool                              0x000000010d1f4566 -[OCUnitCrashFilter handleEvent:] + 1717
    5   xctool                              0x000000010d1e5f4c __38-[OCUnitTestRunner runTestsWithError:]_block_invoke + 199
    6   xctool                              0x000000010d1f3c11 __LaunchTaskAndFeedOuputLinesToBlock_block_invoke + 62
    7   xctool                              0x000000010d1f3aed LaunchTaskAndFeedOuputLinesToBlock + 582
    8   xctool                              0x000000010d1e5573 -[OCUnitIOSLogicTestRunner runTestsAndFeedOutputTo:error:] + 285
    9   xctool                              0x000000010d1e5caf -[OCUnitTestRunner runTestsWithError:] + 240
    10  xctool                              0x000000010d1eee03 -[RunTestsAction runTestable:reproters:objRoot:symRoot:sharedPrecompsDir:xcodeArguments:testSDK:freshSimulator:freshInstall:senTestList:senTestInvertScope:] + 2172
    11  xctool                              0x000000010d1ef1d4 -[RunTestsAction runTestables:testSDK:freshSimulator:freshInstall:options:xcodeSubjectInfo:] + 515
    12  xctool                              0x000000010d1ee558 -[RunTestsAction performActionWithOptions:xcodeSubjectInfo:] + 960
    13  xctool                              0x000000010d1e34c1 -[XCTool run] + 1832
    14  xctool                              0x000000010d1e27b0 main + 244
    15  xctool                              0x000000010d1e26b4 start + 52
)
libc++abi.dylib: terminate called throwing an exception
/Users/me/Source/thirdparty/xctool/xctool.sh: line 50: 15772 Abort trap: 6           "$XCTOOL_DIR"/build/$REVISION/Products/Release/xctool "$@"

"Failed to run tests" but no helpful information given

I'm using issue #16 as a guide to get my project (which uses CocoaPods and Kiwi) to have tests running on the command line so I can have CI useful.

Running with the following command does all of the pre-test test successfully but fails when attempting to run the app in the simulator.

xctool -workspace MyApp.xcworkspace -scheme MyApp ONLY_ACTIVE_ARCH=NO -configuration Debug test

Where I can I look for reasons why the test suite failed to run?

Support -userdefault=value argument of xcodebuild

The original xcodebuild command supports setting user defaults values by using an argument of the form "-userdefault=value". xctool should allow this as well.
When I currently try to use this argument with xctool, the following error is returned:

Assertion failed: (settings.count == 1), function -[XcodeSubjectInfo populate], file /Users/frank/Desktop/xctool-master-1/xctool/xctool/XcodeSubjectInfo.m, line 734.
Abort trap: 6

Official way to install xctool?

I have been using brew, but it doesnt look like that is being kept up to date (0.1.2 is the latest version on brew) since 0.1.3 and 0.1.4 have both been tagged. What's the official way of installing?

Thanks for the great library!

OS X Test Targets Not Emitting Output

I've just switched the testing automation on RestKit/RestKit to using xctool. Executing the iOS test suite was a total dream -- it ran right out of the box.

When I tried to execute the OS X tests for the framework target, it appears that xctool is running the suite but failing to parse any of the output. I see my test server responding to the requests and if I open Console.app I can see the otest output being logged, but xctool reports:

  run-test RestKitFrameworkTests.octest (macosx10.8, logic-test, GC OFF)
** TEST SUCCEEDED: 0 of 0 tests passed ** (24035 ms)

I am running the suite via:

xctool -workspace RestKit.xcworkspace -scheme RestKitFramework test -test-sdk macosx -sdk macosx

Will try to investigate more thoroughly and get a patch together.

Tests passing on xcodebuild/Xcode, but not on xctool.sh

Hey again,

Sorry for the not-so-descriptive subject, but I'm not quite sure what is going on here.

When I try to run the ReactiveCocoa tests I get this:

$ git clone https://github.com/ReactiveCocoa/ReactiveCocoa.git
$ cd ReactiveCocoa
$ git submodule update --init
$ git submodule foreach "git submodule update --init"
$ xctool.sh -project ReactiveCocoa.xcodeproj -scheme ReactiveCocoa -configuration Release test
[…SNIP…]
** TEST FAILED: 727 of 730 tests passed ** (20300 ms)
$ xcodebuild -project ReactiveCocoa.xcodeproj -scheme ReactiveCocoa -configuration 
Executed 740 tests, with 0 failures (0 unexpected) in 6.132 (6.310) seconds
** TEST SUCCEEDED **

Not sure the difference in test count is significant here. I tried running the tests in Xcode, and they pass there too.

Kiwi: Do not run KWSpec and KWTestCase when all tests are executed

Given: iOS project which uses Kiwi for unit testing. (Problem with implicit/explicit dependencies is already solved in the project).

Problem: when I run tests with xctool it also includes KWSpec and KWTestCase suites to run and in results.

  ...
  run-test FooBarTests.octest (iphonesimulator6.1, application-test, GC OFF)
    [2013-05-06 09:30:17|Info] Installing '/Users/yas/Library/Developer/Xcode/DerivedData/FooBar-ajkeysuvkvwfhjgmubnbplcrxzfl/Build/Products/Debug-iphonesimulator/FooBar.app' ...
    [2013-05-06 09:30:19|Info] Launching test host and running tests...
    suite FooSpec
        -[FooSpec Foo_Bar_Works]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
2013-05-06 09:30:19.922 FooBar[27159:c07] + 'Foo, bar, works' [PASSED]
━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
      ✓ -[FooSpec Foo_Bar_Works] (33 ms)
      1 of 1 tests passed (34 ms)

    suite KWSpec
      0 of 0 tests passed (0 ms)

    suite KWTestCase
      0 of 0 tests passed (0 ms)

** TEST SUCCEEDED: 1 of 1 tests passed ** (6254 ms)

Would be good to not include KWSpec and KWTestCase suites. Thanks in advance!

Btw, AppCode has the same problem: http://youtrack.jetbrains.com/issue/OC-6803#

Jenkins: "Failed to build xctool"

Dear people,

When I run:

/xctool.sh -project /MyApp.xcodeproj -scheme MyTestsScheme ONLY_ACTIVE_ARCH=NO -arch i386 -sdk iphonesimulator test

on a terminal, all works fine.

But when I have the following build step in Jenkins:

$WORKSPACE/..../xctool.sh -project $WORKSPACE/..../MyApp.xcodeproj -scheme MyTestsScheme ONLY_ACTIVE_ARCH=NO -arch i386 -sdk iphonesimulator test

I see the following console output:
....
�[1;97m=== BUILDING XCTOOL ===�[0m

/Users/jenkinsnaxos/slave/workspace/Test_Regression_Debug/naxos/xctool/build.sh
....
�[1;31mERROR�[0m: Failed to build xctool:

=== BUILD NATIVE TARGET otest-shim-ios OF PROJECT otest-shim WITH CONFIGURATION Release ===
Check dependencies
....

/Users/jenkinsnaxos/slave/workspace/Test_Regression_Debug/naxos/xctool/xctool/../Vendor/OCHamcrest.framework/Headers/HCMatcher.h:10:9: fatal error: 'HCSelfDescribing.h' file not found

import "HCSelfDescribing.h"

    ^

1 error generated.
....

I see lots of these "file not found" of HC.... headers.

What could this be?

Thanks,

Cornelis

different SDKs used between xcodebuild and xctool

xcodebuild -project Transmit.xcodeproj -configuration Debug -scheme "All"   build 
/Users/james/Developer/Jenkins/tools/xctool/xctool.sh -project Transmit.xcodeproj -configuration Debug -scheme "All"   build 

Sometimes I will get some build error output from xctool telling me that SUAppcast.m (part of Sparkle) failed to build. I diffed the CompileC commands and xctool is somehow using the 10.8 SDK while xcodebuild uses the 10.7 SDK. The Sparkle framework target has the 10.7 SDK specified. Is this the same as #12 ?

Invalid xml written in junit reporter output when writing to output file

Firstly, thanks for writing this great tool. Much appreciated!

When running unit tests with reporter set to junit and an output file selected, xctool writes some invalid xml.
The exact same command with no output file selected looks perfect in stdout.

Output when written to file

�[38;5;60m2013-06-06 13:58:25:747 SportsBook[71395:c07] priceWithResult:correctScorePrice:firstGoalScorerPrice: [Line 141] info
�[0m2013-06-06 13:58:25.748 SportsBook[71395:c07] Scorecast price not found (0.181019 ms).

Output when no output file selected and written to stdout

2013-06-06 13:45:49:611 SportsBook[66981:c07] priceWithResult:correctScorePrice:firstGoalScorerPrice: [Line 141] info
2013-06-06 13:45:49.611 SportsBook[66981:c07] Scorecast price not found (0.128984 ms).

As a result of this Jenkins crashes out with an exception when archiving test results..

screen shot 2013-06-06 at 14 06 32

Thanks
Darragh

Build fails with target specifies product type 'com.apple.product-type.tool', but there's no such product type for the 'iphonesimulator' platform Error

For some reasons when i build my workspace with xctool I get an error the first time i run the build and it works the second time.

This is the error I get

Check dependencies
target specifies product type 'com.apple.product-type.tool', but there's no such product type for the 'iphonesimulator' platform

If I re-run the build it just works. If I re-re-run the build it fails again, if I re-re-re-run the build it works again :)

I know this may not give you much detail about the problem but lets first see if its a known issue somehow ?

The workspace contains multiple sub projects and dependencies with external xcconfig files as well. The build just works with xcodebuild.

This is the command I run

GHUNIT_CLI=1 xctool/xctool.sh -workspace MyWorkspace.xcworkspace -scheme MyScheme -configuration Debug -sdk iphonesimulator -arch i386

NSInternalInconsistencyException: Unexpected SDK: (null)

Hey, awesome work on xctool, I'm looking into maybe making it the new default for Travis builds, since xctool seems to be able to run iOS tests more nicely.

I'm getting some errors when trying to build the Mantle project. I've tried specifying the SDK and test-SDK directly on the command line, but I'm still seeing this error.

Any ideas what's going on here/how to fix it?

Steps to reproduce:

git clone https://github.com/github/Mantle.git
cd Mantle
$XCTOOL_PATH/xctool.sh -project Mantle.xcodeproj -scheme "Mantle Mac" test

Full output:

[master][~/code/Mantle] ../xctool/xctool.sh -project Mantle.xcodeproj -scheme "Mantle Mac" test
=== TEST ===

  xcodebuild build build
    Mantle / Mantle Mac (Debug)
      ✓ Check dependencies (114 ms)
      ✓ Analyze NSArray+MTLManipulationAdditions.m (272 ms)
      ✓ Compile NSArray+MTLManipulationAdditions.m (257 ms)
      ✓ Compile NSDictionary+MTLManipulationAdditions.m (252 ms)
      ✓ Compile MTLJSONAdapter.m (300 ms)
      ✓ Compile MTLModel.m (298 ms)
      ✓ Compile NSValueTransformer+MTLPredefinedTransformerAdditions.m (280 ms)
      ✓ Analyze MTLModel.m (331 ms)
      ✓ Compile MTLReflection.m (66 ms)
      ✓ Analyze NSDictionary+MTLManipulationAdditions.m (49 ms)
      ✓ Analyze MTLModel+NSCoding.m (489 ms)
      ✓ Compile MTLModel+NSCoding.m (101 ms)
      ✓ Analyze NSValueTransformer+MTLPredefinedTransformerAdditions.m (75 ms)
      ✓ Analyze MTLJSONAdapter.m (91 ms)
      ✓ Analyze MTLReflection.m (62 ms)
      ✓ Link Mantle (74 ms)
      ✓ Generate Mantle.framework.dSYM (24 ms)
      ✓ Copy Mantle.h (1 ms)
      ✓ Touch Mantle.framework (5 ms)


  xcodebuild build build
    Expecta / Expecta (Debug)
      ✓ Check dependencies (107 ms)

    Specta / Specta (Debug)
      ✓ Check dependencies (0 ms)

    Mantle / Mantle Mac (Debug)
      ✓ Check dependencies (11 ms)

    Mantle / Mantle Mac Tests (Debug)
      ✓ Check dependencies (1 ms)
      ✓ Precompile MantleTests-Prefix.pch (727 ms)
      ✓ Precompile MantleTests-Prefix.pch (897 ms)
      ✓ Analyze MTLTestModel.m (435 ms)
      ✓ Analyze MTLTestNotificationObserver.m (422 ms)
      ✓ Analyze MTLArrayManipulationSpec.m (405 ms)
      ✓ Analyze MTLDictionaryManipulationSpec.m (405 ms)
      ✓ Analyze MTLComparisonAdditionsSpec.m (241 ms)
      ✓ Analyze MTLModelSpec.m (453 ms)
      ✓ Analyze MTLValueTransformerSpec.m (437 ms)
      ✓ Analyze MTLPredefinedTransformerAdditionsSpec.m (459 ms)
      ✓ Compile MTLValueTransformerSpec.m (101 ms)
      ✓ Compile MTLTestModel.m (82 ms)
      ✓ Compile MTLTestNotificationObserver.m (42 ms)
      ✓ Compile MTLModelSpec.m (160 ms)
      ✓ Compile MTLArrayManipulationSpec.m (99 ms)
      ✓ Compile MTLDictionaryManipulationSpec.m (89 ms)
      ✓ Compile MTLComparisonAdditionsSpec.m (76 ms)
      ✓ Compile MTLPredefinedTransformerAdditionsSpec.m (138 ms)
      ✓ Analyze MTLModelNSCodingSpec.m (75 ms)
      ✓ Analyze MTLJSONAdapterSpec.m (62 ms)
      ✓ Compile MTLModelNSCodingSpec.m (128 ms)
      ✓ Compile MTLJSONAdapterSpec.m (116 ms)
      ✓ Link Mantle Mac Mantle Mac Tests (154 ms)
      ✓ Generate Mantle Mac Tests.octest.dSYM (52 ms)
      ✓ Run custom shell script 'Run Script' (22 ms)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
/Applications/Xcode.app/Contents/Developer/Tools/RunUnitTests:68: note: RunUnitTests exited without running tests because TEST_AFTER_BUILD was set to NO.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
      ✓ Touch Mantle Mac Tests.octest (5 ms)


2013-05-05 05:50:14.388 xctool[29040:707] *** Assertion failure in -[RunTestsAction runTestable:reproters:objRoot:symRoot:sharedPrecompsDir:xcodeArguments:testSDK:freshSimulator:freshInstall:senTestList:senTestInvertScope:], /Users/henrikhodne/code/xctool/xctool/xctool/RunTestsAction.m:247
2013-05-05 05:50:14.390 xctool[29040:707] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unexpected SDK: (null)'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff84801b06 __exceptionPreprocess + 198
    1   libobjc.A.dylib                     0x00007fff85c053f0 objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff84801948 +[NSException raise:format:arguments:] + 104
    3   Foundation                          0x00007fff8508ec82 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 189
    4   xctool                              0x0000000101555a63 -[RunTestsAction runTestable:reproters:objRoot:symRoot:sharedPrecompsDir:xcodeArguments:testSDK:freshSimulator:freshInstall:senTestList:senTestInvertScope:] + 988
    5   xctool                              0x00000001015562d4 -[RunTestsAction runTestables:testSDK:freshSimulator:freshInstall:options:xcodeSubjectInfo:] + 515
    6   xctool                              0x0000000101555658 -[RunTestsAction performActionWithOptions:xcodeSubjectInfo:] + 960
    7   xctool                              0x000000010155d7f6 -[TestAction performActionWithOptions:xcodeSubjectInfo:] + 79
    8   xctool                              0x000000010154a5e1 -[XCTool run] + 1832
    9   xctool                              0x00000001015498d0 main + 244
    10  xctool                              0x00000001015497d4 start + 52
    11  ???                                 0x0000000000000006 0x0 + 6
)
libc++abi.dylib: terminate called throwing an exception
../xctool/xctool.sh: line 50: 29040 Abort trap: 6           "$XCTOOL_DIR"/build/$REVISION/Products/Release/xctool "$@"

xctool/build/./Products/Release/xctool:No such file or directory

I download the newest version xctool,i run the xctool.sh bulid and this error come up.
I google it and find nothing. I thought maybe i download the wrong version ,so i redownload the newest 3 version but didn,t work.

I downloaded crap xcode5 and delete it once,maybe xcode5 problem?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.