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

Extract e2e testing framework to its own crate #1429

Merged
merged 12 commits into from
Oct 6, 2022
Merged

Conversation

ascjones
Copy link
Collaborator

@ascjones ascjones commented Sep 29, 2022

Pulls all of the e2e testing framework and the macro into their own crates.

  • Keeps all e2e related code and dependencies together
  • Only builds e2e dependencies for testing, prevents pulling in a big dependency tree for ink crates

Should resolve #1428

@cmichi
Copy link
Collaborator

cmichi commented Sep 30, 2022

Thanks a lot for this! I don't see how it will resolve #1428, but we should merge it nonetheless, as it's more structured this way.

I don't think it will resolve our issue because of the following:

  • E.g. flipper includes the ink dependency.
  • You execute cargo test on flipper.
  • This will result in the direct dev-dependencies defined in flipper/Cargo.toml being built.
  • However: The ink crate will be built without the information that flipper is built in a developer/testing environment. So you have no way to know in the ink crate if it is being built for dev-dependencies or regular dependencies.
  • This is unfortunately documented behavior (here):

Dev-dependencies are not used when compiling a package for building, but are used for compiling tests, examples, and benchmark. These dependencies are not propagated to other packages which depend on this package.

I think what we have to do is require every contract to have a Cargo.toml like this:

[dependencies]
ink = { version = "4.0", default-features = false }

[dev-dependencies]
ink = { version = "4.0", default-features = false, features = ["as-dev-dependency"] }

The we can have the crates/ink/Cargo.toml contain:

[features]
as-dev-dependency = [
   "ink_e2e"
]

@ascjones
Copy link
Collaborator Author

I don't see how it will resolve #1428

The idea is that ink_e2e is a standalone crate (not reexported by the main ink crate).

[dev-dependencies]
ink_e2e = { path = "../../crates/e2e" }

@ascjones
Copy link
Collaborator Author

ascjones commented Oct 3, 2022

Waiting for use-ink/cargo-contract#763 to be merged and released, then update ink! CI in this PR

@ascjones ascjones marked this pull request as ready for review October 6, 2022 11:01
@ascjones ascjones requested review from a team, cmichi and HCastano as code owners October 6, 2022 11:01
@@ -183,18 +183,16 @@ pub mod give_me {
#[cfg(test)]
mod e2e_tests {
use super::*;
use ink::env::e2e::*;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was previously required to bring the reexported tokio crate into scope for the tokio::test macro. In order to make this properly hygienic, I have replaced the usage of the tokio::test macro with explicit async execution (copied from tokio::test) 7e63d1c

@codecov-commenter
Copy link

Codecov Report

Merging #1429 (791afbc) into master (a4594f0) will increase coverage by 0.05%.
The diff coverage is 7.14%.

@@            Coverage Diff             @@
##           master    #1429      +/-   ##
==========================================
+ Coverage   70.84%   70.89%   +0.05%     
==========================================
  Files         193      193              
  Lines        6077     6071       -6     
==========================================
- Hits         4305     4304       -1     
+ Misses       1772     1767       -5     
Impacted Files Coverage Δ
crates/e2e/macro/src/codegen.rs 0.00% <0.00%> (ø)
crates/e2e/macro/src/config.rs 45.65% <ø> (ø)
crates/e2e/macro/src/ir.rs 0.00% <0.00%> (ø)
crates/e2e/macro/src/lib.rs 0.00% <0.00%> (ø)
crates/e2e/src/lib.rs 0.00% <ø> (ø)
crates/e2e/src/xts.rs 0.00% <ø> (ø)
crates/ink/codegen/src/generator/mod.rs 100.00% <ø> (ø)
crates/ink/codegen/src/lib.rs 100.00% <ø> (ø)
crates/ink/macro/src/lib.rs 100.00% <ø> (+11.11%) ⬆️
crates/ink/ir/src/ir/utils.rs 92.59% <100.00%> (ø)
... and 1 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Collaborator

@cmichi cmichi left a comment

Choose a reason for hiding this comment

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

Thank you, Andrew!

@ascjones ascjones merged commit 4156112 into master Oct 6, 2022
@ascjones ascjones deleted the aj/e2w-crate branch October 6, 2022 15:21
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.

E2E: Include e2e deps only for cargo test
3 participants