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

refactor: Prepare flank codebase for supporting iOS testplans #1281

Merged
merged 15 commits into from
Nov 19, 2020

Conversation

jan-goral
Copy link
Contributor

@jan-goral jan-goral commented Oct 28, 2020

This PR brings the partial implementation of #685.

As feature #685 will bring a lot of changes in codebase it will be delivered in separate pull requests for reducing code review complexity.

The main goals of this PR are:

  1. Refactor of existing code related to xctestrun v1, so the code can be reused for v2.
  2. Raw Implementation for xctest v2 (without integration with rest of code)
  3. Preparing the codebase for supporting xctest v2

This pull request SHOULD NOT change the current behavior of the flank.
This pull request IS NOT exposing a new feature.
The full integration of flank with xctestrun v2 will be added in the next pull request(s)

Test Plan

How do we know the code works?

Everything is working like before
The unit tests pass

Checklist

  • Documented
  • Refactor of ios Parse.kt file & related unit tests
  • Refactor of ios Xctestrun.kt file & related unit tests
  • Test plan (xctestrun v2) parser implementation
  • Upload test artifacts for #685-ios-support-for-testplans
  • Unit tested

@zuziaka zuziaka force-pushed the #685-ios-support-for-testplans branch from e587a71 to 38ae7d2 Compare November 2, 2020 10:22
docs/feature/ios_test_plans.md Outdated Show resolved Hide resolved
docs/feature/ios_test_plans.md Outdated Show resolved Hide resolved
docs/feature/ios_test_plans.md Outdated Show resolved Hide resolved
@github-actions
Copy link
Contributor

github-actions bot commented Nov 4, 2020

Timestamp: 2020-11-19 11:40:11
Buildscan url for ubuntu-workflow run 372174738
https://gradle.com/s/fzh35qsqjp5qs

@codecov-io
Copy link

codecov-io commented Nov 4, 2020

Codecov Report

Merging #1281 (17be78e) into master (733e444) will decrease coverage by 0.14%.
The diff coverage is 76.71%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1281      +/-   ##
============================================
- Coverage     79.61%   79.47%   -0.15%     
+ Complexity      735      700      -35     
============================================
  Files           237      244       +7     
  Lines          4573     4618      +45     
  Branches        792      809      +17     
============================================
+ Hits           3641     3670      +29     
- Misses          526      531       +5     
- Partials        406      417      +11     

@jan-goral jan-goral changed the title #685 ios support for testplans feat: iOS support for testplans Nov 5, 2020
@jan-goral
Copy link
Contributor Author

After merging #1300 this PR should be easier to review.

@jan-goral jan-goral added Feature New Option Used to track PR with new configuration option (useful when updating fladle) Tiger 🐯 labels Nov 5, 2020
@jan-goral jan-goral force-pushed the #685-ios-support-for-testplans branch from 390f9c7 to fb7ba02 Compare November 6, 2020 10:34
@jan-goral jan-goral added Documentation Pull request which touches documentation iOS and removed Documentation Pull request which touches documentation labels Nov 6, 2020
@jan-goral jan-goral changed the title feat: iOS support for testplans chore: Prepare flank codebase for supporting iOS testplans Nov 9, 2020
@jan-goral jan-goral marked this pull request as ready for review November 9, 2020 14:56
@@ -79,7 +79,7 @@ IosArgs
private fun IosArgs.calculateShardChunks() = if (disableSharding)
emptyList() else
ArgsHelper.calculateShards(
filteredTests = filterTests(findTestNames(xctestrunFile), testTargets)
filteredTests = filterTests(findXcTestNamesV1(xctestrunFile), testTargets)
Copy link
Contributor

Choose a reason for hiding this comment

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

will there be a v2?

Copy link
Contributor Author

@jan-goral jan-goral Nov 10, 2020

Choose a reason for hiding this comment

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

Probably but in the next PR (I am working on it). It's in the description "The full integration of flank with xctestrun v2 will be added in the next pull request(s)".

import ftl.ios.xctest.common.parseToNSDictionary
import java.io.File

internal fun findXcTestNamesV2(xctestrun: String): Map<String, XctestrunMethods> =
Copy link
Contributor

Choose a reason for hiding this comment

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

ahh i see it now. Why the v1 vs v2?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The xctestrun file can come (currently) in two versions. Those files can have a slightly different structure and require different parsers. In the documentation you can find differences between them https://github.com/Flank/flank/blob/4c3b55d30723aefc9ca65b1bec4415a095217531/docs/feature/ios_test_plans.md

// https://github.com/linkedin/bluepill/blob/37e7efa42472222b81adaa0e88f2bd82aa289b44/Source/Shared/BPXCTestFile.m#L18
// must quote binary path in case there are spaces
var cmd = "nm -U ${binary.quote()}"
if (!FtlConstants.isMacOS) cmd = "PATH=~/.flank $cmd"
Copy link
Contributor

Choose a reason for hiding this comment

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

has this been tested on windows?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nope

Copy link
Contributor

Choose a reason for hiding this comment

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

its gonna break it i see it 🗡️

Copy link
Contributor

Choose a reason for hiding this comment

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

parseObjcTests is used only on ios tests. Flank not supporting ios tests on windows so I think it's fine.

val results = mutableListOf<String>()
// https://github.com/linkedin/bluepill/blob/37e7efa42472222b81adaa0e88f2bd82aa289b44/Source/Shared/BPXCTestFile.m#L18
// must quote binary path in case there are spaces
var cmd = "nm -U ${binary.quote()}"
Copy link
Contributor

Choose a reason for hiding this comment

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

i am not sure windows is supported?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Me too, this code is untouched, only moved from:
https://github.com/Flank/flank/blob/ab55fbcb02f6cfe99b3b502db6bf52f661cd34ca/test_runner/src/main/kotlin/ftl/ios/Parse.kt

Everything should work like before. It's in the description: "This pull request SHOULD NOT change the current behavior of the flank."

Copy link
Contributor

Choose a reason for hiding this comment

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

hmmm alright. We may need to test it


@Test
fun `findTestNames respects skip`() {
assumeFalse(FtlConstants.isWindows)
Copy link
Contributor

Choose a reason for hiding this comment

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

we have this here, but what about the other tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

makes sense. We will need a fixup task for windows again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We will need a fixup task for windows again.

"Again" in this context sounds like that was working previously, then was broken, fixed and now is broken again. But It's not true for this test.

As I said, nothing changes here except file name.

@jan-goral jan-goral requested a review from Sloox November 10, 2020 13:38
@bootstraponline bootstraponline force-pushed the #685-ios-support-for-testplans branch 2 times, most recently from 29bb33f to a97c1aa Compare November 12, 2020 07:00
val result = parseToNSDictionary(swiftXcTestRunV1)
assertThat(arrayOf("EarlGreyExampleSwiftTests", "__xctestrun_metadata__")).isEqualTo(result.allKeys())
val dict = result["EarlGreyExampleSwiftTests"] as NSDictionary
assertThat(dict.count()).isEqualTo(20)
Copy link
Contributor

Choose a reason for hiding this comment

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

I know that this test isn't new, but I don't think that asserting number of a key:value pairs here is a good idea.
It may change with new version of Xcode.

@bootstraponline bootstraponline force-pushed the #685-ios-support-for-testplans branch from 0007791 to 858801f Compare November 16, 2020 12:19
import ftl.util.copyBinaryResource

internal val installBinaries by lazy {
if (!FtlConstants.isMacOS) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Will it work properly on Windows 🤔 ?

Copy link
Contributor Author

@jan-goral jan-goral Nov 17, 2020

Choose a reason for hiding this comment

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

Not sure. It's refactoring ;P. I haven't got windows OS.

Copy link
Contributor

Choose a reason for hiding this comment

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

probably it should be
if (!FtlConstants.isMacOS && !isWindows)
but if this just moving to new file, you could leave it

@piotradamczyk5
Copy link
Contributor

piotradamczyk5 commented Nov 16, 2020

I think that this more
refactor:
instead of
chore:

@jan-goral jan-goral changed the title chore: Prepare flank codebase for supporting iOS testplans refactor: Prepare flank codebase for supporting iOS testplans Nov 17, 2020
@bootstraponline bootstraponline force-pushed the #685-ios-support-for-testplans branch from 858801f to d81c933 Compare November 17, 2020 13:02
@jan-goral jan-goral force-pushed the #685-ios-support-for-testplans branch from d81c933 to 17be78e Compare November 18, 2020 12:05
Copy link
Contributor

@adamfilipow92 adamfilipow92 left a comment

Choose a reason for hiding this comment

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

  • Tested
  • Outputs of master and this branch compared and is the same
    👍

@bootstraponline bootstraponline force-pushed the #685-ios-support-for-testplans branch from 17be78e to ee6a99a Compare November 18, 2020 16:04
@jan-goral jan-goral force-pushed the #685-ios-support-for-testplans branch from ee6a99a to cd39b11 Compare November 19, 2020 11:30
@bootstraponline bootstraponline force-pushed the #685-ios-support-for-testplans branch from cd39b11 to fa5ff24 Compare November 19, 2020 11:34
@jan-goral jan-goral merged commit 501ea71 into master Nov 19, 2020
@jan-goral jan-goral deleted the #685-ios-support-for-testplans branch November 19, 2020 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature iOS New Option Used to track PR with new configuration option (useful when updating fladle) Tiger 🐯
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants