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

Interpreter testing #132

Merged
merged 10 commits into from
May 31, 2023
Merged

Conversation

CosmicHorrorDev
Copy link
Collaborator

Here is the aforementioned interpreter testing PR

All the changes are split out into individual commits to keep reviewing a bit easier as needed. The changes are basically

  1. Shifting the layout (no code changes)
  2. Splitting out nasty external state behind a separate trait, so that we can do dependency injection
  3. Some boilerplate for being able to get the results from interpreting a single markdown document since the interpreter is meant to run continuously in a background thread
  4. Slimming down a lot of noise in the debug impls for some things to make snapshot tests easier to review

I think interpreter tests are a pretty good candidate for snapshot testing since eyeballing the results of the output is a pretty good way to see that we're generating elements right, and they're very easy to update. Here's an example of the review screen if you haven't used insta before (it does mean using cargo-insta for reviews though when snapshots do change. You don't have to, but it's the easiest ways to handle it)

insta_review

You also don't have to use snapshot tests either since tests can just use the interpret_md() helper function

(Side note: I only noticed from looking at the snapshot file that having a textbox with multiple anchors doesn't work, so the textbox with multiple footnotes only has the second anchor attached)

@CosmicHorrorDev CosmicHorrorDev added the C-refactor Category: Reworking an existing feature label May 28, 2023
@CosmicHorrorDev CosmicHorrorDev requested a review from trimental May 28, 2023 00:10
@CosmicHorrorDev
Copy link
Collaborator Author

Forgot to mention: we'll want to add custom debug impls for some of the other elements, but I was saving that for whenever we end up using other elements. Image probably has a massive Debug output since it holds the compressed image data

@trimental
Copy link
Collaborator

Everything looks good. Thanks for the commit separation, made reviewing a lot easier. Insta seems like a very good choice for testing this.

Slightly unrelated to this PR but does the repology svg render for you? Looks like it might be a windows specific ssl issue but the request for it is failing for me.

@trimental trimental merged commit f360b04 into Inlyne-Project:main May 31, 2023
@CosmicHorrorDev
Copy link
Collaborator Author

Slightly unrelated to this PR but does the repology svg render for you? Looks like it might be a windows specific ssl issue but the request for it is failing for me.

Works fine for me on linux. I'm not sure what windows normally uses for ssl, but we could always switch to rustls instead. It should just a default-features = false, features = ["rustls-tls"] to switch

CosmicHorrorDev added a commit to CosmicHorrorDev/inlyne that referenced this pull request Nov 19, 2023
@CosmicHorrorDev CosmicHorrorDev mentioned this pull request Nov 19, 2023
8 tasks
CosmicHorrorDev added a commit that referenced this pull request Nov 23, 2023
* Some clean ups, fixes, config flag (#91)

* Refactor: Remove unneccesary CLI branching

* Refactor: Refactor configuration load function

* Feat: Add '--config' flag

* Refactor: Reduce passing of args and configuration

* Fix: Fix cli parsing of page width

* Clean: use 'display()' instead of debug print for path

* Clean: use Default for Keybindings

* Refactor: Use Keybindings in tests

* Doc: Fix 'page width' to 'page_width'

* Refactor: use interpolation style

* Refactor: Remove inline on Keybindings::new

* Refactor: Extract Keybindings Default implementation

* Refactor: Destructure Config and Args in opts

* Support bare relative links (#103)

* Attempt to reregister file watcher on file "removal" (#106)

* Add a test for all CLI options (#116)

* Add repology badge for package manager installation (#109)

* Make correct location of `inlyne.toml` file clearer (#122)

* Make correct location of `inlyne.toml` file clearer

* Fix missing backtick

* Interpreter testing (#132)

* Interpreter test tweaks (#138)

* Cleanup existing custom debug impls

* Add custom debug impls for `Element::Image(_)`

* Add a snapshot test for complex image elements

* More robust file watching (#147)

* The watcher should attempt to re-register on name changes

* Re-register watcher after longer delays

* Add a reminder for fixing watching after file changes

* Move file watcher into its own file

* Make file watcher testable

* Watcher follows file changes

* Test the file watcher

* Final test tweaks

* Swap back to the old delays

* Final final test tweaks

* Use a slightly longer delay

* Shorter poll interval for file watcher

* Follow through with rename

* Make file reloading less panic happy (#145)

* Rework panic happy file reloading

* Tweak logs

* The watcher should attempt to re-register on name changes

* Re-register watcher after longer delays

* Improve syntax highlighting (#150)

* Add failing test

* Use extended syntax definitions

* Add failing test

* Allow for comma as an info string delimiter

* Retry watcher test with increased delays (#155)

* Fix-up nested lists (#154)

* Add failing tests

* Handle nesting of lists

* Cleanup list prefix handling

* Dogfood new `smart-debug` crate (#156)

* Dont ignore locked mutex in debug impl (#166)

* fix: add missing `fontdb` feature flag (#169)

This solves an issue with the NixOS build where fonts are required at
runtime for inlyne to start. With the `fontconfig` feature flag inlyne
will use font-config to determine a font.

Partially resolves #164

* Add relevant keywords to `Cargo.toml` (#171)

* Use `human-panic` for a custom panic hook (#172)

* Use `human-panic` for a custom panic hook

* Indicate that the version is a "git release"

* `cargo upgragde`

* Update `two-face`

* `cargo update`

* Update simple dependencies

* Update `smart-debug`

* Update `resvg` & co.

* Update `rust-version` to v1.70.0

* Bump version to v0.3.2

---------

Co-authored-by: Gijs Burghoorn <g.burghoorn@gmail.com>
Co-authored-by: Nico Burns <nico@nicoburns.com>
Co-authored-by: AlphaKeks <85143381+AlphaKeks@users.noreply.github.com>
@CosmicHorrorDev CosmicHorrorDev deleted the interpreter-testing branch April 6, 2024 04:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-refactor Category: Reworking an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants