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

Fix CI. #3727

Merged
merged 7 commits into from
Sep 15, 2024
Merged

Fix CI. #3727

Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/yew/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ mod renderer;

#[cfg(feature = "csr")]
#[cfg(test)]
pub mod tests;
pub(crate) mod tests;
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be pub, not pub(crate). The tests module is part of the public API. Please just suppress the clippy lints here.

See https://yew.rs/docs/more/testing#snapshot-testing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wasn't aware of the possibility for #[cfg(test)] to be transitive. AFAIK, it cannot be imported by dependents, pub or otherwise.

Cargo.toml

[package]
name = "yewimport"
version = "0.1.0"
edition = "2021"

[dependencies]
yew = {version = "0.21.0", features = ["csr"]}

src/main.rs

fn main() {
    
}

#[cfg(test)]
mod tests {
    use yew::tests::layout_tests::LayoutTest;
}

cargo test

$ cargo test
error[E0433]: failed to resolve: could not find `tests` in `yew`
   --> src/main.rs:7:14
    |
7   |     use yew::tests::layout_tests::LayoutTest;
    |              ^^^^^ could not find `tests` in `yew`
    |
note: found an item that was configured out
   --> /home/finnb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/yew-0.21.0/src/lib.rs:300:9
    |
300 | pub mod tests;
    |         ^^^^^
note: the item is gated here
   --> /home/finnb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/yew-0.21.0/src/lib.rs:299:1
    |
299 | #[cfg(test)]
    | ^^^^^^^^^^^^

For more information about this error, try `rustc --explain E0433`.
error: could not compile `yewimport` (bin "yewimport" test) due to 1 previous error

But I can make the change you suggest!


/// The module that contains all events available in the framework.
pub mod events {
Expand Down
6 changes: 4 additions & 2 deletions packages/yew/src/tests/layout_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ impl Component for Comp {
}

#[derive(Debug)]
pub struct TestLayout<'a> {
#[cfg_attr(not(target_arch = "wasm32"), allow(unused))]
pub(crate) struct TestLayout<'a> {
pub name: &'a str,
pub node: VNode,
pub expected: &'a str,
}

pub fn diff_layouts(layouts: Vec<TestLayout<'_>>) {
#[cfg_attr(not(target_arch = "wasm32"), allow(unused))]
pub(crate) fn diff_layouts(layouts: Vec<TestLayout<'_>>) {
let document = gloo::utils::document();
let scope: AnyScope = AnyScope::test();
let parent_element = document.create_element("div").unwrap();
Expand Down
2 changes: 1 addition & 1 deletion tools/website-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl Level {

fn write_into(&self, dst: &mut String, name: &str, level: usize) -> fmt::Result {
self.write_space(dst, level);
let name = name.replace(|c| c == '-' || c == '.', "_");
let name = name.replace(['-', '.'], "_");
writeln!(dst, "pub mod {name} {{")?;

self.write_inner(dst, level + 1)?;
Expand Down
Loading