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

Removes not needed guard #103

Merged
merged 14 commits into from Feb 28, 2019
Merged

Removes not needed guard #103

merged 14 commits into from Feb 28, 2019

Conversation

valeriyvan
Copy link
Contributor

max func works consistently on a sequence of any length.

From documentation:

Returns
The sequence’s maximum element if the sequence is not empty; otherwise, nil.

@ghost
Copy link

ghost commented Jan 4, 2019

1 Warning
⚠️ The use of Swift 3 @objc inference in Swift 4 mode is deprecated. Please address deprecated @objc inference warnings, test your code with “Use of deprecated Swift 3 @objc inference” logging enabled, and then disable inference by changing the “Swift 3 @objc Inference” build setting to “Default” for the “FBSnapshotTestCase iOS” target. (in target ‘FBSnapshotTestCase iOS’)
1 Message
📖 Executed 49 tests, with 0 failures (0 unexpected) in 19.752 (19.810) seconds

Current coverage for WeScan is 39.48%

Files changed - -
Array+Utils.swift 100.00%

Current coverage for WeScanSampleProject is 42.86%

No files affecting coverage found


Powered by xcov

Generated by 🚫 Danger

@julianschiavo
Copy link
Contributor

Wouldn’t removing the guard make it return nil if there’s only one Quad instead of the current behavior of returning the only Quad?

@valeriyvan
Copy link
Contributor Author

valeriyvan commented Jan 5, 2019

No. max and min functions on Sequence are consistent for any length.
If you are interested you could look at implementation, starts on line 155.

@valeriyvan
Copy link
Contributor Author

@justjs, added test to make you sure.

@julianschiavo
Copy link
Contributor

Thanks for the addition of the test, but what I meant by my previous comment is this:

On the old implementation, if you had 2 or more rectangles, it would have returned the bigger one. If you had 1 rectangle, it would return the only rectangle.

On the new implementation, as per the documentation (The sequence’s maximum element if the sequence is not empty; otherwise, nil.), if you have only 1 rectangle, it will now return nil rather than the only rectangle.

This is also demonstrated by the testCorrectlyDetectsAndReturnsQuadilateral test failing.

@valeriyvan
Copy link
Contributor Author

screen shot 2019-01-06 at 12 21 25

@julianschiavo
Copy link
Contributor

Yes, that test is passing because it is using 10 rectangles. The CI is failing on the testCorrectlyDetectsAndReturnsQuadilateral test, which is the existing/old test.

@valeriyvan
Copy link
Contributor Author

Ops, I did miss this part!

@valeriyvan
Copy link
Contributor Author

screen shot 2019-01-06 at 12 24 52

About max being consistent with any sequence length.

@julianschiavo
Copy link
Contributor

That's weird, seems to be incorrect according to the documentation. However, if that's how it works this PR should work, not sure why the Travis is failing.

@valeriyvan
Copy link
Contributor Author

No, documentation is correct!
It says max return nil only for empty sequence, otherwise it returns maximum element. Single element sequence is not empty. For single element sequence that single element is max element (and min element as well). That how max/min work.
But if documentation might me misunderstood that the reason improve it, I guess.

Copy link
Contributor

@AvdLee AvdLee left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! Can you verify why CI is failing?

@valeriyvan
Copy link
Contributor Author

Sure

@julianschiavo
Copy link
Contributor

I’ve reviewed the CI error and it seems there was some kind of issue with the snapshot tests. If you’ve try run them locally maybe you can see what the issue is clearer. (In your project folder just run “git submodules init; git submodules update” to install the library used for the tests)

…ture func on CIDetector fails to find anything on 50x image but succeeds on 150x.

Failure lead to force unwrap of nil in tests.
…in tests to avoid FBSnapshotTestCase mistakingly looking for reference images in ReferenceImages_32 instead of ReferenceImages_64
@julianschiavo
Copy link
Contributor

julianschiavo commented Jan 9, 2019

Hey @valeriyvan, while I understand you are trying to fix the tests, agnosticOptions is only on the CIRectangleDetector tests because it was updated between iOS versions - so this has to stay there or the tests will fail.

Also, I think it would be better to create a new PR for this, especially as it seems these are improvements to the tests rather than fixes (as the tests pass on all other PRs).

Hope that helps 🙂

(Edit: Also, changing the size is not a good idea - while it may fix the tests we should aim to fix the underlying code instead!)

@valeriyvan
Copy link
Contributor Author

All tests passing locally. On the server one of snapshot tests fails with failure of loading reference image. FBSnapshotTestCase looks for reference image in ReferenceImages_32 when it is in ReferenceImages_64. According to documentation it should look both before failing.
Anyway, failing tests have nothing in common with the reason of this PR.

@valeriyvan
Copy link
Contributor Author

valeriyvan commented Jan 9, 2019

Guys, @AvdLee requests fixing tests, @justjs requests fixing tests in separate PR. Can't satisfy both of you.

@valeriyvan
Copy link
Contributor Author

valeriyvan commented Jan 9, 2019

Anyway, I can't fix failing test at the moment. Snapshot test still looks for reference image in wrong directory. And tests are passing locally.

@julianschiavo
Copy link
Contributor

You should listen to @AvdLee over me - I don't work for WeTransfer. But I understood it as fixing the PR, which was causing the tests to fail, while it seems like here the tests have been changed to make them pass.

@valeriyvan
Copy link
Contributor Author

The reason of tests failing is not related to this PR.

@julianschiavo
Copy link
Contributor

I don't want to be hostile/create an argument here, but recently merged PRs did not have this issue, so it does seem to be an issue with this PR: #104 and #102 (both made by you) did not have this issue.

@valeriyvan
Copy link
Contributor Author

valeriyvan commented Jan 9, 2019

I don't see this PR as breaking change. It was innocent change on its own.
"After" doesn't mean "because of".
My be I am wrong and missing something.
One of reason of tests failed was crash because of force unwrap of nil in test itself. This was fixed by fixing test itself. It wasn't related to PR.
Second reason - snapshot test case looking wrong dir for reference image. Not related to PR as well. It was fixed by fixing tests as well.
All tests are passing locally. I have no idea why snapshot test case is still looking wrong dir at server.

@AvdLee
Copy link
Contributor

AvdLee commented Jan 9, 2019

Just to make sure, did you merge in the latest changes from develop into your branch? If so, it's our responsibility to fix CI and make it work again.

@valeriyvan
Copy link
Contributor Author

Merged up to date develop

@valeriyvan
Copy link
Contributor Author

Can't believe my eyes.

Copy link
Contributor

@julianschiavo julianschiavo left a comment

Choose a reason for hiding this comment

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

As you were able to resolve the issues by merging develop, could we remove all the changes to the test in this PR to keep it focused? If the issue was merging develop it should all work, but you can try to remove parts of your changes slowly to see if everything still works. 🙂

@valeriyvan
Copy link
Contributor Author

Merge of develop haven't resolved issue with broken tests.
Accidentally switching Simulator from iPhone X to iPhone 7 and running tests I have found that tests started to fail locally. Update of reference images fixed broken tests. Now tests pass on only locally bon on CI as well.

@julianschiavo
Copy link
Contributor

Yes, because you changed the settings for the tests so the old reference images were outdated.

@valeriyvan
Copy link
Contributor Author

Any reason why this isn't being merged?

@Boris-Em
Copy link
Contributor

Waiting on @justjs's approval.

Copy link
Contributor

@julianschiavo julianschiavo left a comment

Choose a reason for hiding this comment

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

@Boris-Em I see no issue with this - only thing is that we should be careful as we're changing the reference images.

@AvdLee
Copy link
Contributor

AvdLee commented Feb 15, 2019

@justjs as long as our tests are succeeding, this shouldn't be a problem. Do you agree?

@julianschiavo
Copy link
Contributor

Fair enough, I’m ok with that. Let’s make sure to keep this in mind in case was have future issues with the tests 👍

@AvdLee AvdLee merged commit a26664e into WeTransfer:develop Feb 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants