Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Run unit tests on iOS - #3989

Merged
jfirebaugh merged 5 commits into
masterfrom
3989-ios-unit-tests
Mar 22, 2016
Merged

jfirebaugh merged 5 commits into
masterfrom
3989-ios-unit-tests

Conversation

@kkaefer

@kkaefer kkaefer commented Feb 18, 2016

Copy link
Copy Markdown
Member

Follow up to #2150

@kkaefer kkaefer self-assigned this Feb 17, 2016
@kkaefer

kkaefer commented Feb 18, 2016

Copy link
Copy Markdown
Member Author

@1ec5 how can we run this on Bitrise? There's now a new target called "test" in the default Xcode project for iOS. That target works on both actual devices and the simulator and all tests are passing.

@jfirebaugh There are two OfflineDatabase tests that fail on iOS: PutEvictsLeastRecentlyUsedResources and PutFailsWhenEvictionInsuffices. Do you have any idea why they might be failing?

@1ec5

1ec5 commented Feb 18, 2016

Copy link
Copy Markdown
Contributor

how can we run this on Bitrise?

The Bitrise steps are defined in bitrise.yml. It essentially does two things: it runs make ipackage-sim on the command line and then tests ios-tests.xcodeproj using Xcode. Since the test target has been added to a gyp-generated project (#3275), you’ll have to add a make target that builds and runs the tests. That make target could invoke gyp, followed by a shell script that looks like test.sh. (test.sh is invoked by make itest, but Bitrise doesn’t use it.)

@jfirebaugh

Copy link
Copy Markdown
Contributor

The eviction tests were tuned for a database page size of 1024, while on iOS the page size is 4096. I pushed a change that makes it work for both.

@kkaefer

kkaefer commented Feb 19, 2016

Copy link
Copy Markdown
Member Author

Ah interesting. Reading the patch, it's unclear to me how this would fix the issue. Can you please explain? If our eviction is based on page size, we should enforce page size with PRAGMA page_size = 1024; (or whatever value we chose) so that all platforms behave the same.

@jfirebaugh

Copy link
Copy Markdown
Contributor

The eviction algorithm tries to keep the total size of the database below a specified limit. The tests were setting this limit to 1024 * 25 = 25,600 bytes. SQLite appears to enforce a minimum of 15 pages in a database. In cases where the page size is 1024, a limit of 25,600 bytes is above this minimum size of 1024 * 15, but if the page size is 4096, then even an empty database is larger than 25,600 bytes. Increasing the limit to 1024 * 100 ensures that the eviction limit is greater than the minimum database size in both cases.

A better way to write this test would be to query the page size and minimum number of pages dynamically, and then create a fresh database with an eviction limit greater than the product of those two. But I took the lazier route of just bumping the numbers.

@kkaefer
kkaefer force-pushed the 3989-ios-unit-tests branch from cc86742 to 2fc95e9 Compare February 23, 2016 14:51
@jfirebaugh
jfirebaugh force-pushed the 3989-ios-unit-tests branch from 2fc95e9 to 5f0406d Compare March 22, 2016 18:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants