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

Host-based unit tests #17

Merged
merged 2 commits into from
Nov 9, 2023
Merged

Host-based unit tests #17

merged 2 commits into from
Nov 9, 2023

Conversation

divergentdave
Copy link
Collaborator

@divergentdave divergentdave commented Nov 8, 2023

This repeats the existing client smoke tests on the host, in addition to running them in an emulator. This closes #3. I moved some of the common setup code to a new library module, so I could reuse it via intra-project dependencies. I also had to provide a mock for android.util.Base64, since it's not available on the host. It was easy to polyfill using java.util.Base64.

Using the native library in host unit tests is enabled by adding a desktop target to the list of cross-compilation targets, and modifying the value of java.library.path when running the tests. Note that our JNI native library does not depend on any NDK methods, only common Linux libc functions for memory management or getrandom. Since I needed to sniff the host OS and architecture to pick the right build artifact, I also added a narrower task dependency from the unit tests to cargo, by only requiring the host target, and not any Android cross-compile targets.

@divergentdave divergentdave changed the title Load library in host-based unit tests Host-based unit tests Nov 8, 2023
@divergentdave divergentdave marked this pull request as ready for review November 8, 2023 16:32
@divergentdave divergentdave requested a review from a team as a code owner November 8, 2023 16:32
Copy link
Contributor

Choose a reason for hiding this comment

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

What are these .pro files? Since they're either empty or completely commented out, can we omit them?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

They're Proguard files, introduced by the Android Studio new module wizard. Proguard is responsible for minifying/obfuscating class files, so these files govern exclusions of classes, methods, fields, etc. that need to have their names preserved if they are used by reflection, etc. The files are directly referenced by proguardFiles() and consumerProguardFiles() directives in the build system. The AAR includes a proguard.txt file that is probably merged from consumerProguardFiles() inputs. I'm inclined to keep them, since they're a normal part of an Android project.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair enough, I don't have a good enough argument to push for removing them.

@divergentdave divergentdave merged commit d703419 into main Nov 9, 2023
2 checks passed
@divergentdave divergentdave deleted the david/desktop-library branch November 9, 2023 18:45
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.

Build Rust library for host-based unit tests
3 participants