-
Notifications
You must be signed in to change notification settings - Fork 8
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
Barebones of int selfie #23
Conversation
- Attemp to implement int selfie
Sorry for slow response, I'm trying to structure this task a little better. Thanks for taking a shot, I'll have more background ASAP. |
@jknack I fleshed this out some more, I'd love your help if you're available! This is the integration test for the user experience that we're working towards. selfie/selfie-runner-junit5/src/test/kotlin/com/diffplug/selfie/junit5/InlineIntTest.kt Lines 29 to 40 in 465a08d
The unimplemented code is this part: selfie/selfie-runner-junit5/src/main/kotlin/com/diffplug/selfie/junit5/WriteTracker.kt Lines 88 to 112 in 002129d
The first thing I would do is refactor the code above to make it easier to do fast "unit" test instead of only big slow integration test. Something like this |
sure I'll take it. Thank you @nedtwigg |
- parse single line literal - inject encoded value - TODO: tests are still failing - TODO: add Slice - TODO: support multi-line parsing
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.
Great progress, definitely on the right track! My main feedback would be to add a way to test the replacement logic that doesn't need the Harness
and UT_
stuff, something like "when testfile is , replacement value is , and callstack is , the result is ".
For now, we can assume test files are only Java / Kotlin. But someday we will want this to support Javascript, Scala, Groovy, Clojure, etc. Those can all be enduser PR's in the future, but we'll want to have good infrastructure to support this parse/replace operation.
We also might want to support wrapper libraries, where someone does Assert.assertEquals(actual, expected)
but it's just a wrapper for selfie, which will replace the value in the assertEquals()
line. We shoudn't complicate our code for this now, we should do the simplest thing that works, so I think your regex is perfect.
But over time, as we get enduser PRs to support more usecases, this code will see a lot of traffic. So spare no expense when it comes to framing out its internal API and testing.
// TODO: probably need more than ignore import?? | ||
if (line.contains(start) && !line.contains("import ")) "L$index: $line" else null |
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.
I don't see why it needs anything more than line.conains(start)
. The trick is to do linesFrom
only for things where you know the line is unique. If this was enduser API I would probably enforce that it must be unique, and throw an error with line numbers if more than one line matched. If we're having trouble with it in our test code, then I'd support adding a uniqueness check here.
Hi @nedtwigg, Sorry for being lost... I'm back if you still want to work with me. Thanks |
Hi @jknack, thrilled to have you back! No worries, I would still love your help on this. The inline snapshot stuff is exactly where you left it. My comment above is imo still the relevant next step. If it's confusing, just let me know and I can take a try at writing the harness myself to demonstrate what I mean. |
Just FYI @jknack, I've been integrating Selfie into our website, and have a bunch of changes I've made to make the integration work. I've also decided to rename the packages from
Once I'm at that point I would love your help improving the inline snapshot mechanism if you're available. I'm hoping to get this all done by tomorrow evening, TBD. |
Hi @jknack. I've decided not to rename packages for now. There's a ton of open work in If you have time, just go down the list and implement. I'm gonna implement one more thing from the list then it's all yours. |
@nedtwigg thank you |
@nedtwigg I'm a bit lost, not sure if this is what are we looking for.