Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand Test Execution Coverage #979

Merged
merged 8 commits into from
Jul 12, 2018

Conversation

joeydong-stripe
Copy link
Contributor

@joeydong-stripe joeydong-stripe commented Jun 29, 2018

Seems like Travis CI picks up our builds relatively quickly now so I think it's an appropriate time to expand our iOS version test coverage. Also would catch problems like #978. See individual commits.

@joeydong-stripe joeydong-stripe self-assigned this Jun 29, 2018
@joeydong-stripe joeydong-stripe force-pushed the joeydong/testExecutionCoverage branch 2 times, most recently from 1723dd2 to 63fe9c0 Compare June 29, 2018 23:12
@joeydong-stripe joeydong-stripe force-pushed the joeydong/testExecutionCoverage branch 3 times, most recently from f4d45bd to 70d738a Compare July 2, 2018 21:11
@joeydong-stripe joeydong-stripe force-pushed the joeydong/testExecutionCoverage branch from 70d738a to b94736b Compare July 2, 2018 21:13
@joeydong-stripe joeydong-stripe force-pushed the joeydong/testExecutionCoverage branch from b94736b to 4a00bf0 Compare July 2, 2018 21:19
@joeydong-stripe joeydong-stripe changed the title [WIP] Expand Test Execution Coverage Expand Test Execution Coverage Jul 2, 2018
// CMYK is the only one where all 1's results in a dark color
testColorSpace(colorSpaceNames[i], colorSpaceNames[i] != kCGColorSpaceGenericCMYK);
testColorSpace(name, name != (__bridge NSString *)kCGColorSpaceGenericCMYK);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, I would have assumed we needed to use [NSString isEqualToString:] but the tests are passing anyway?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm less confident about keeping this as a pointer equality check with the bridging involved. I think it's probable that CFStringRef is always toll-free bridged to NSString and this'll be fine, but I think it's also plausible that some future runtime changes that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I agree it's not smart to leave it as a pointer check. I'm more wondering why it still works. Maybe this constant is always mapped to the same memory address. Anyway, I'll switch it to the usual isEqualToString.


if (@available(iOS 10.0, *)) {
colorSpaceNames = [colorSpaceNames arrayByAddingObjectsFromArray:@[
(__bridge NSString *)kCGColorSpaceLinearGray,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding all this (ugly?) bridging, since it was only two iOS 10 cases, did you consider just following the pattern that the iOS 11-only case kCGColorSpaceGenericLab took?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, I was so focused on struggling with this Core Foundation syntax I forgot to try that.

// CMYK is the only one where all 1's results in a dark color
testColorSpace(colorSpaceNames[i], colorSpaceNames[i] != kCGColorSpaceGenericCMYK);
testColorSpace(name, name != (__bridge NSString *)kCGColorSpaceGenericCMYK);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm less confident about keeping this as a pointer equality check with the bridging involved. I think it's probable that CFStringRef is always toll-free bridged to NSString and this'll be fine, but I think it's also plausible that some future runtime changes that.

-scheme "Standard Integration (Swift)" \
-sdk "iphonesimulator" \
-destination "platform=iOS Simulator,name=iPhone 6,OS=11.2" \
| xcpretty
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was it intentional to drop the -c flag that colorizes the output?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, to me, the default behavior seems to works so why bother specifying it:

screen shot 2018-07-09 at 3 05 30 pm

# Execute tests (iPhone 6 @ iOS 11.2)
info "Executing tests (iPhone 6 @ iOS 11.2)..."

xcodebuild clean test \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you combine the build & test steps? They were intentionally separated last year: eb8009a

I know I've run into this problem in the past (and have the radar to prove it), but I don't know if it's still an issue in Xcode 9.

Copy link
Contributor Author

@joeydong-stripe joeydong-stripe Jul 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i combined it to reduce code duplication, and it seems to work? i think if we need it again in the future, we should leave the reasoning as a comment in the code because a bum like me is going to miss the commit blame.

-scheme "StripeiOS" \
-configuration "Debug" \
-sdk "iphonesimulator" \
-destination "platform=iOS Simulator,name=iPhone 4s,OS=9.3" \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when you try to stick this in the previous xcodebuild command? Does it fail because Debug only builds for the active architecture?

Did you consider DRYing this up instead of duplicating so many parameters?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when you try to stick this in the previous xcodebuild command? Does it fail because Debug only builds for the active architecture?

Oops, forgot to leave a reason comment but yeah that's why. Never figured it out but your guess seems reasonable! The code duplication is definitely annoying. I haven't tried parameters in a variable before but I'll look into it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplication doesn't look too bad after adding the ONLY_ACTIVE_ARCH=NO usage

@joeydong-stripe joeydong-stripe force-pushed the joeydong/testExecutionCoverage branch from a0d3392 to 2fc6b5b Compare July 9, 2018 23:13
Copy link
Contributor

@danj-stripe danj-stripe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@joeydong-stripe joeydong-stripe merged commit 80b8872 into master Jul 12, 2018
csabol-stripe pushed a commit that referenced this pull request Apr 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants