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

test: make the EventFactory available to all crates #4296

Merged
merged 5 commits into from
Nov 20, 2024
Merged

Conversation

bnjbvr
Copy link
Member

@bnjbvr bnjbvr commented Nov 19, 2024

This had been requested by crypto folks in the past, notably @BillCarsonFr if I remember correctly: it makes the EventFactory available from all crates, by moving it into matrix-sdk-test. Because the common crate depended on the test crate, and EventFactory depends on the common crate, this required cutting the circular dependency by having the common crate use the test-macro crate directly. I find it an acceptable tradeoff.

The two first commits tidy up the test utils implemented in the SDK crate. I don't think they can be moved to another external crate:

  • they need concepts defined in the SDK crate, like a Client,
  • but the SDK crate uses these mock helpers in a few places

So we'd have a circular dependency there too, if we moved this code to another crate (unless I'm missing something).

@bnjbvr bnjbvr requested a review from a team as a code owner November 19, 2024 15:56
@bnjbvr bnjbvr requested review from jmartinesp and removed request for a team November 19, 2024 15:56
Copy link

codecov bot commented Nov 19, 2024

Codecov Report

Attention: Patch coverage is 87.50000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 85.03%. Comparing base (0af53e9) to head (e981ec6).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
crates/matrix-sdk/src/test_utils/client.rs 87.50% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4296      +/-   ##
==========================================
- Coverage   85.04%   85.03%   -0.01%     
==========================================
  Files         274      274              
  Lines       30114    29977     -137     
==========================================
- Hits        25610    25491     -119     
+ Misses       4504     4486      -18     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@Hywan Hywan requested review from Hywan and removed request for jmartinesp November 20, 2024 10:15
Copy link
Member

@Hywan Hywan left a comment

Choose a reason for hiding this comment

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

It's an improvement, thanks. Can you rebase your history before merging please?

@@ -44,7 +44,7 @@ wasm-bindgen = "0.2.84"
[dev-dependencies]
assert_matches = { workspace = true }
proptest = { version = "1.4.0", default-features = false, features = ["std"] }
matrix-sdk-test = { workspace = true }
matrix-sdk-test-macros = { path = "../../testing/matrix-sdk-test-macros" }
Copy link
Member

Choose a reason for hiding this comment

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

👍

@@ -21,7 +21,7 @@ http = { workspace = true }
matrix-sdk-common = { path = "../../crates/matrix-sdk-common" }
matrix-sdk-test-macros = { version = "0.7.0", path = "../matrix-sdk-test-macros" }
once_cell = { workspace = true }
ruma = { workspace = true, features = ["rand"] }
ruma = { workspace = true, features = ["rand", "unstable-msc3381"] }
Copy link
Member

Choose a reason for hiding this comment

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

Why is it useful?

Copy link
Member Author

Choose a reason for hiding this comment

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

Enabling support for polls when the crate is built independently. I'll add a comment.

@bnjbvr bnjbvr requested a review from a team as a code owner November 20, 2024 12:07
@bnjbvr bnjbvr requested review from richvdh and removed request for a team and richvdh November 20, 2024 12:07
This is more in line with what we're doing in the SDK in general.
The (matrix-sdk-)common crate used the (matrix-sdk-)test crate only to
benefit from the `async_test` proc macro, which is conveniently defined
in another crate.

My goal is to make `EventFactory`, at this point in the commit history,
defined in the main SDK crate, available in the test crate.
`EventFactory` makes use of some types defined in common, so there's a
circular dependency at the moment.

To split this circular dependency, I've changed the common crate to
depend on the test-macro crate directly; now the test crate can depend
on the common crate, and everybody's happy.
@bnjbvr bnjbvr enabled auto-merge (rebase) November 20, 2024 14:44
This makes it available to the crypto crate, by lowering it into the
local dependency tree.
@bnjbvr bnjbvr disabled auto-merge November 20, 2024 15:20
@bnjbvr bnjbvr enabled auto-merge (rebase) November 20, 2024 15:21
@bnjbvr bnjbvr disabled auto-merge November 20, 2024 15:29
@bnjbvr bnjbvr merged commit 1f563c9 into main Nov 20, 2024
39 checks passed
@bnjbvr bnjbvr deleted the bnjbvr/test-utils branch November 20, 2024 15: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