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

Run tests in CI, and fix fonts for snapshot testing #233

Merged
merged 30 commits into from
Aug 5, 2024

Conversation

DJMcNab
Copy link
Member

@DJMcNab DJMcNab commented Apr 29, 2024

See also linebender/vello#439

This should open the door to doing much more comprehensive testing at higher level in the nearish future (including e.g. in xilem_masonry)

@DJMcNab DJMcNab marked this pull request as draft April 29, 2024 10:47
@DJMcNab
Copy link
Member Author

DJMcNab commented Apr 29, 2024

Comment on lines 165 to 166
// TODO: Is this the right place for this?
pub fn add_test_font(
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems reasonable. RenderRoot is the type ultimately responsible for turning semantic data into bitmaps. You can either pass a test font with a constructor argument, a build method, or a setter. I think a setter is fine.

@PoignardAzur
Copy link
Contributor

Will try to run this on my machine this afternoon, then review.

@DJMcNab
Copy link
Member Author

DJMcNab commented Jul 18, 2024

Ooh, a time limit to get it working? Exciting!

@DJMcNab DJMcNab force-pushed the tests-ci branch 2 times, most recently from a383a57 to 7f617da Compare July 18, 2024 10:00
@DJMcNab DJMcNab marked this pull request as ready for review July 18, 2024 10:01
@DJMcNab
Copy link
Member Author

DJMcNab commented Jul 18, 2024

The status of this is that there's a lot more work needed on testing, including moving this into Xilem. However, this does get our existing tests working in a cross-platform way.

One concern I have with the size of screenshot tests. I'm planning on raising this in office hours, to see if anyone has any good solutions, so won't merge until them.
Ideally, we could just use git lfs, but they don't want to support this well in GitHub

.github/workflows/ci.yml Outdated Show resolved Hide resolved
@PoignardAzur
Copy link
Contributor

Unit tests pass on my machine! 🎉

(PopOs 22.04, RTX 2070 with X11, for what it's worth.)

@DJMcNab
Copy link
Member Author

DJMcNab commented Aug 1, 2024

I'm going to postpone merging this PR until after I port linebender/vello#647 to this repository, to avoid adding the new snapshots into main as-is.

I think I'll do that in a different PR, because it also has implications on other caching choices, and shouldn't be controversial.

@PoignardAzur
Copy link
Contributor

Makes sense, yes. FWIW the developer experience of git-lfs in Vello seems pretty good to me.

Copy link
Contributor

@PoignardAzur PoignardAzur left a comment

Choose a reason for hiding this comment

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

LGTM.

Comment on lines 531 to 534
if std::env::var("SKIP_RENDER_SNAPSHOTS").is_ok_and(|it| !it.is_empty()) {
// FIXME - This is a terrible, awful hack.
// We need a way to skip render snapshots on CI and locally
// until we can make sure the snapshots render the same on
Copy link
Contributor

Choose a reason for hiding this comment

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

The comment should probably be changed to reflect our likely best practices (eg test render snapshots by default, skip them if we have LFS-related problems). The "FIXME" part should be removed.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll do that when I rebase this past #475

Comment on lines +543 to 544
let new_image: DynamicImage = self.render().into();

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't remember: is there a reason render runs after the SKIP_RENDER_SNAPSHOT early-exit? It feels like even if we wanted to skip the "compare pixels" part, we'd still want to exercise the painting code in case we find panics there.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure. I'm wanting to redo a lot of this testing code, but I think that will want to come after linebender/rfcs#7

Copy link
Contributor

Choose a reason for hiding this comment

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

Wait, no, I misread the code. We already redraw in the early exit, the only thing this skips is actually sending the Vello scene to GPU. So that makes sense.

masonry/src/testing/screenshots.rs Outdated Show resolved Hide resolved
masonry/src/widget/tests/safety_rails.rs Outdated Show resolved Hide resolved
DJMcNab added 4 commits August 5, 2024 11:53
Unclear why the status of these has changed
Since if you can render, the snapshots will work
@DJMcNab DJMcNab requested a review from PoignardAzur August 5, 2024 11:07
@DJMcNab
Copy link
Member Author

DJMcNab commented Aug 5, 2024

Requested review just to get final sign-off on the latest pushed changed (since ac7549d)

@DJMcNab DJMcNab added this pull request to the merge queue Aug 5, 2024
Merged via the queue into linebender:main with commit e27b3ce Aug 5, 2024
17 checks passed
@DJMcNab DJMcNab deleted the tests-ci branch August 5, 2024 13:08
Copy link
Contributor

@PoignardAzur PoignardAzur left a comment

Choose a reason for hiding this comment

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

LGTM. Tests still compile on my machine.

Comment on lines +543 to 544
let new_image: DynamicImage = self.render().into();

Copy link
Contributor

Choose a reason for hiding this comment

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

Wait, no, I misread the code. We already redraw in the early exit, the only thing this skips is actually sending the Vello scene to GPU. So that makes sense.

Comment on lines +56 to +59
#[cfg_attr(
not(debug_assertions),
ignore = "This test doesn't work without debug assertions (i.e. in release mode). See https://github.com/linebender/xilem/issues/477"
)]
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you need to link to the issue. Doing a cfg_attr fixes it.

For the message I'd write something like:

"Safety rails are disabled when debug_assertions is false (i.e. in release mode)."

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