Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

xctool can't run tests using Kiwi or Specta #202

Closed
fpotter opened this issue Oct 11, 2013 · 29 comments
Closed

xctool can't run tests using Kiwi or Specta #202

fpotter opened this issue Oct 11, 2013 · 29 comments
Labels

Comments

@fpotter
Copy link
Contributor

fpotter commented Oct 11, 2013

As of ~ v0.1.9, xctool won't run test bundles that use Kiwi or Specta. Around that time, xctool began doing introspection on each test bundle - we'd load the bundle and dump a list of all test cases inside of it. This was done inside of otest-query.

Right now, when otest-query is run against and Kiwi or Specta bundle, it's returning an empty list of test cases.

The problem is that Specta and Kiwi's test methods/cases get generated at runtime, and otest-query isn't triggering that process. We need to make it tickle the right things so that all the test methods are generated and THEN dump the list of test methods.

For Kiwi at least, this happens inside of +[KWSpec testInvocations] -- https://github.com/allending/Kiwi/blob/master/Classes/Core/KWSpec.m#L75

Hopefully we can find a generic way to trigger this testInvocations stuff so that we don't have to add Kiwi-specific or Specta-specific code to otest-query.

@hojberg
Copy link

hojberg commented Oct 16, 2013

Also affected by this. Would love to run xctool with kiwi :)

@brow
Copy link

brow commented Oct 16, 2013

👍

1 similar comment
@bilby91
Copy link

bilby91 commented Oct 16, 2013

👍

@priteshshah1983
Copy link

I'd love to use this too.

@gastonmorixe
Copy link

👍 Please!

@andres99x
Copy link

👍 Really interested in this

@mekanics
Copy link

👍

1 similar comment
@darkins
Copy link

darkins commented Oct 17, 2013

👍

@radamant
Copy link

👍 v0.1.11 runs our Kiwi unit tests, v0.1.13 does not.

@NachoSoto
Copy link

👍

@yas375
Copy link
Contributor

yas375 commented Nov 1, 2013

Looks like it's already fixed, right?
I can run Kiwi tests using the HEAD version of xctool. Maybe it makes sense to make a new release? ;)

@fpotter
Copy link
Contributor Author

fpotter commented Nov 1, 2013

Yes - new release coming later today, I hope.

@matzew
Copy link

matzew commented Nov 4, 2013

@fpotter so this will be fixed in 0.1.14 ?

@fpotter
Copy link
Contributor Author

fpotter commented Nov 4, 2013

It will be. Hopefully I can release really soon. Sorry for the wait.

@matzew
Copy link

matzew commented Nov 4, 2013

@fpotter thanks for the heads up. sounds good!

@sharplet
Copy link

sharplet commented Nov 5, 2013

@fpotter Just wanted to mention that this is currently still unresolved for me—I'm unable to run Kiwi tests on HEAD.

My setup: Xcode 4.6.3 (4H1503), xctool 0.1.13/HEAD, Kiwi 2.1.0, CocoaPods 0.27.1.

On HEAD, I get the error

2013-11-06 08:01:26.148 AppDemo[68768:707] *** Assertion failure in void ParseClassAndMethodFromTestName(NSString **, NSString **, NSString *)(), /tmp/xctool-sIwx/otest-query/../Common/ParseTestName.m:19
2013-11-06 08:01:26.150 AppDemo[68768:707] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Test name seems to be malformed: -[AppDemoTests (null)]'

On 0.1.13, if the test target has non-Kiwi tests they will be executed, but no Kiwi tests are executed. If the target has ONLY Kiwi tests, then after the app is installed in the simulator xctool just hangs and doesn't do anything.

Since changes to CocoaPods introduced in 0.25.0 to support Xcode 5, I can't build without setting ONLY_ACTIVE_ARCH=NO at the command line.

Hope this helps, let me know if there's any more info I can give you.

@fpotter
Copy link
Contributor Author

fpotter commented Nov 5, 2013

@sharplet Ahh, the null issue! I haven't been able to repro that - can you help me out?

In Xcode.app, would you mind giving me a paste of the full raw text of your test run from the build/test log? Or, can you help me figure out what combination of describe / it blocks generate this (null) case ?

@sharplet
Copy link

sharplet commented Nov 5, 2013

In Xcode.app, would you mind giving me a paste of the full raw text of your test run from the build/test log?

I can probably do that. How can I get the raw text from Xcode.app?

Or, can you help me figure out what combination of describe / it blocks generate this (null) case ?

So I removed all the existing spec files from the test target, and added a single one that looks like this:

#import <Kiwi/Kiwi.h>

SPEC_BEGIN(TestSpec)

describe(@"failure", ^{
    it(@"fails", ^{
        fail(@"failed");
    });
});

SPEC_END

The xctool output for run-tests is like this:

  [Info] Collecting info for testables... (2744 ms)
  run-test AppTests.octest (iphonesimulator6.1, application-test, GC OFF)
  Failed to query the list of test cases in the test bundle: 2013-11-06 09:38:07.536 AppDemo[82911:707] Unknown Device Type. Using UIUserInterfaceIdiomPad based on screen size
2013-11-06 09:38:07.631 AppDemo[82911:707] *** Assertion failure in void ParseClassAndMethodFromTestName(NSString **, NSString **, NSString *)(), /tmp/xctool/otest-query/../Common/ParseTestName.m:19
2013-11-06 09:38:07.632 AppDemo[82911:707] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Test name seems to be malformed: -[TestSpec (null)]'
*** First throw call stack:
(0x3495012 0x32bae7e 0x3494e78 0x2f796d0 0x1349473 0x1349d29 0x134a2b6 0x8feb7cda 0x8feb7fde 0x8feb4268 0x8feb40ba 0x8fea5dd9 0x8fea9adb 0x8fea5376 0x8fea5077)
libc++abi.dylib: terminate called throwing an exception

Removing the describe and having just a single example at the top level of the spec makes no difference.

@frosty
Copy link

frosty commented Nov 6, 2013

@fpotter I have the null issue too!

Here's a test run from Xcode, just containing the simplest test file in my project:

Test Suite 'All tests' started at 2013-11-06 16:47:46 +0000
Test Suite '/Users/frosty/Library/Developer/Xcode/DerivedData/MyProject-esencdmhzykiudavwmqkovxkepuh/Build/Products/Debug-iphonesimulator/MyProjectTests.octest(Tests)' started at 2013-11-06 16:47:46 +0000
Test Suite 'DIStatusSpec' started at 2013-11-06 16:47:46 +0000
Test Case '-[DIStatusSpec DIStatus_ParsingJSON_CreatesAStatusFromValidJSON]' started.
2013-11-06 16:47:46.791 MyProject[22795:c07] + 'DIStatus, parsing JSON, creates a status from valid JSON' [PASSED]
Test Case '-[DIStatusSpec DIStatus_ParsingJSON_CreatesAStatusFromValidJSON]' passed (0.052 seconds).
Test Case '-[DIStatusSpec DIStatus_ParsingJSON_UsesDefaultValuesIfJSONIsInvalid]' started.
2013-11-06 16:47:46.803 MyProject[22795:c07] + 'DIStatus, parsing JSON, uses default values if JSON is invalid' [PASSED]
Test Case '-[DIStatusSpec DIStatus_ParsingJSON_UsesDefaultValuesIfJSONIsInvalid]' passed (0.008 seconds).
Test Suite 'DIStatusSpec' finished at 2013-11-06 16:47:46 +0000.
Executed 2 tests, with 0 failures (0 unexpected) in 0.060 (0.064) seconds
Test Suite 'KWSpec' started at 2013-11-06 16:47:46 +0000
Test Suite 'KWSpec' finished at 2013-11-06 16:47:46 +0000.
Executed 0 tests, with 0 failures (0 unexpected) in 0.000 (0.000) seconds
Test Suite '/Users/frosty/Library/Developer/Xcode/DerivedData/MyProject-esencdmhzykiudavwmqkovxkepuh/Build/Products/Debug-iphonesimulator/MyProjectTests.octest(Tests)' finished at 2013-11-06 16:47:46 +0000.
Executed 2 tests, with 0 failures (0 unexpected) in 0.060 (0.064) seconds
Test Suite 'All tests' finished at 2013-11-06 16:47:46 +0000.
Executed 2 tests, with 0 failures (0 unexpected) in 0.060 (0.113) seconds

My spec is this:

#import "Kiwi.h"
#import "DIStatus.h"

SPEC_BEGIN(DIStatusSpec)

describe(@"DIStatus", ^{

    context(@"parsing JSON", ^{
        it(@"creates a status from valid JSON", ^{
            NSDictionary *json = @{ @"status" : @2, @"description" : @"Amber alert." };
            DIStatus *status = [DIStatus statusWithJSON:json];

            [[theValue(status.status) should] equal:theValue(DIStatusLevelAmber)];
            [[status.statusDescription should] equal:@"Amber alert."];
        });

        it(@"uses default values if JSON is invalid", ^{
            NSDictionary *json = @{};
            DIStatus *status = [DIStatus statusWithJSON:json];

            [[theValue(status.status) should] equal:theValue(0)];
            [[status.statusDescription should] equal:@""];
        });
    });

});

SPEC_END

Finally, xctool is crashing with:

2013-11-06 16:47:45.755 DataInterchange[22820:707] *** Assertion failure in void ParseClassAndMethodFromTestName(NSString **, NSString **, NSString *)(), /Users/frosty/bin/xctool/Common/ParseTestName.m:19
2013-11-06 16:47:45.756 DataInterchange[22820:707] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Test name seems to be malformed: -[DIStatusSpec (null)]'
*** First throw call stack:
(0x2cb7012 0x26fae7e 0x2cb6e78 0x23b96d0 0x4f32d3 0x4f2cf5 0x270e57b 0x4f39e7 0x4f4116 0x8fe50cda 0x8fe50fde 0x8fe4d268 0x8fe4d0ba 0x8fe3edd9 0x8fe42adb 0x8fe3e376 0x8fe3e077)
libc++abi.dylib: terminate called throwing an exception

@fpotter
Copy link
Contributor Author

fpotter commented Nov 8, 2013

@sharplet, @frosty OK, I've tried to repro but still cannot. I think it's somewhere in the project config - that spec/describe/it setup works fine for me.

Would one of you mind trying to repro the issue in a new sample project and then share that with me?

@sharplet
Copy link

sharplet commented Nov 9, 2013

@fpotter Successfully reproduced here: https://github.com/sharplet/xctool-kiwi-bug.

Aaand it looks like you just fixed it (!), in this commit.

@fpotter
Copy link
Contributor Author

fpotter commented Nov 9, 2013

Aaand it looks like you just fixed it (!), in this commit.

Sweet! I was hoping so... but then I was having trouble repro'ing before that commit, too.

Thanks so much for putting together that example!

@pdsarin
Copy link

pdsarin commented Nov 19, 2013

@fpotter do you know when the next release will ship? Looking forward to using this fix. :)

@yas375
Copy link
Contributor

yas375 commented Nov 19, 2013

@pdsarin you might now it, but just in case, you could use the head version of xctool by installing it using brew install xctool --HEAD command. ;)

@pdsarin
Copy link

pdsarin commented Nov 19, 2013

@yas375 thanks for the tip! Going to wait on the official release as I want our build env to be easily replicable.

@tleach
Copy link

tleach commented Nov 20, 2013

+1 Any sign of a release for this guys?

@robb
Copy link

robb commented Nov 24, 2013

Yeah, would be great to have this one fixed on travis-ci

@fpotter
Copy link
Contributor Author

fpotter commented Nov 26, 2013

Just posted 0.1.14 - https://github.com/facebook/xctool/releases/tag/v0.1.14

Closing this task for now, but re-open if you keep having Kiwi troubles.

@fpotter fpotter closed this as completed Nov 26, 2013
@sharplet
Copy link

Nice work @fpotter, it's working great for us now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.