-
Notifications
You must be signed in to change notification settings - Fork 9
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
Move tests from jvmTest to commonTest #108
Move tests from jvmTest to commonTest #108
Conversation
The first step for making the library multiplatform. This commit also removes JSON parsing and Moshi test dependency.
Great question. Renovate is on our radar. I have a personal preference to avoid giving a third party write access to our Git repo, given the security breaches that have occurred in the past few years due to GitHub apps (e.g. Travis and Heroku). I keep hoping that Dependabot will get better Gradle support, especially now that Gradle supports toml version catalogs. But it may be worth seriously evaluating the tradeoffs.
This looks like a gap in the documentation, thanks for noting it. I filed an issue. I note that the docs you point to don't include the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this PR. Having this Multiplatform work split up into several smaller PRs helps us get parts of it merged much more quickly.
I have one small inline comment, although I don't think it is necessary to address. I will wait a bit of time to merge until after I hear from you, just to confirm you agree with my assessment.
fun ByteArray.toHex(): String { | ||
val sb = StringBuilder(size * 2) | ||
for (b in this) | ||
sb.append(String.format("%02x", b)) | ||
for (b in this) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the Kotlin common implementation is more complex and harder to follow compared to the version relying on the JVM, one very small suggestion would be considering whether we need a test case for the to/from hex methods. They're doing some non-trivial work, and our test assertions rely on them.
One test case could be a round-trip through toHex and fromHex, asserting the data comes out the same. Another could be converting bytes to hex and making sure the output matches a known expected value.
That said, if there was a bug here our tests should fail due to how our tests are set up. So I think we have parity with our JVM tests from before.
Put another way: if you were writing this from scratch I'd say we need a test case. But because it worked before under the JVM, we can be more confident that the conversion here is valid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me at first it felt not quite natural to test code created just for testing. But you're right - this is important part of testing logic and there is no reason why it shouldn't be tested. Added in 1c0fa82
Renovate has another GitHub app called "Forking Renovate" (docs), which does not require write access to code (permissions table). It opens PRs from a fork, similarly to any other contributor. I think it's a good security improvement.
I've already lost my hope, GitHub issue with over 200 thumbs up is open for over a year and a half. Also Renovate is much more configurable, and has a extra nice features, such as Dependency Dashboard. |
This change also includes moving test extensions and test data to utils package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great. There's just one minor ktlint issue blocking CI. Do you want to push a fix for that, then I can merge this?
@burnoo Thank you very much for this great enhancement. It is a pleasure working with you, and I appreciate the effort that went into this contribution. These small pieces are really helpful to move us towards a multiplatform future! |
I've decided to follow up work done in #14 by moving tests from
jvmTest
tocommonMain
(as suggested by @ccjernigan here). It would be the first step for making the library multiplatform.PR details
Moshi
andJSON
parsing from tests and replaced it with hardcoded listString.format()
andCharacter.digit()
)jvmTest
tocommonTest
Next steps
jvmMain
tocommonMain
(usingactual
/expect
)Extra thoughts
.toml
files, so it would automate updating Gradle dependencies../gradlew dependencies --write-locks
). It didn't work for me - I had to use module specific Gradle task:./gradlew bip39-lib:dependencies --write-locks
. It would be great to either include it in the docs or makebip39-lib:dependencies
task run while runningdependencies
.Author
./gradlew check
then coverage reports are generated underbuild/reports/kover
.Reviewer