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

refactor: improve test capability and coverage #24

Merged
merged 7 commits into from
Oct 22, 2024

Conversation

knarewski
Copy link
Contributor

@knarewski knarewski commented Oct 18, 2024

Background
I'm prototyping libvips-based Morandi on a separate branch in hope of improving its memory profile and performance

Problem
The specs only check for presence of output files and do little to assess their content, requiring manual visual inspection

Solution
Introduce:

  • a matcher for checking the image content
  • the first test which uses the matcher (ICC colour profile conversion)

Notes

  • it's best to review this commit-wise or to ignore whitespaces, as one of the commits removes a level of indentation from a few hundred lines
  • I've also:
    • bumped the required Ruby version from 2.0 to 2.7 to cater for safe navigation operation (2.3+) and for ensure keyword available in blocks (2.5+)
    • bumped Ruby version used for development to allow using Ruby LST VSCode extension
    • added Gemfile.lock for smoother Development experience (otherwise it's often required to run bundle install after launching the container because of some gems getting outdated)
    • loosened rubocop requirements WRT blocklength, to make the newlines introduced for readability not count anymore

Screenshots

image
A new matcher's output after disabling colour profile conversion
image
Content of reference image (tmp/reference-image-matches/morandi_spec-rb-512/reference.jpg)
image
Content of actual image (tmp/reference-image-matches/morandi_spec-rb-512/tested.jpg) after disabling colour profile conversion (there's clear colour difference caused by stripping colour profile information without proper conversion)
image
Content of tmp/reference-image-matches/morandi_spec-rb-512/diff.jpg after disabling colour profile conversion (red-ish pixels indicate colour mismatch)

For smoother development experience. Example VSCode's Ruby LSP required Ruby 3.0+
…ent experience

The file is being removed on CI, because different ruby versions may resolve differently

See also: https://bundler.io/guides/faq.html#using-gemfiles-inside-gems
To make the spec more reliable, a new matcher has been introduced for visual image comparison
A pumpkin photo was made by me and is distributed under MIT license
@knarewski knarewski requested a review from MrLukeSmith October 18, 2024 15:15
Copy link
Contributor

@MrLukeSmith MrLukeSmith left a comment

Choose a reason for hiding this comment

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

Clean and user-friendly, very nice!

@knarewski knarewski changed the title refactor: improve test capacity and coverage refactor: improve test capability and coverage Oct 22, 2024
@knarewski knarewski merged commit 28806e0 into master Oct 22, 2024
15 checks passed
@knarewski knarewski deleted the improve-test-quality branch October 22, 2024 08:33
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.

2 participants