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: cargo test takes too long to test #90

Merged
merged 11 commits into from
Apr 4, 2024
Merged

fix: cargo test takes too long to test #90

merged 11 commits into from
Apr 4, 2024

Conversation

AlexD10S
Copy link
Collaborator

@AlexD10S AlexD10S commented Apr 1, 2024

Fixing Issue #88

  • Run only unit tests when cargo test

  • unit tests that are a bit slower, build a contract move it into feature unit_contract. To run cargo test --features unit_contract

  • Run e2e tests using a feature flag cargo test --features e2e_contract for contracts and cargo test --features e2e_parachain for parachains

  • Moved the test that builds a parachain to e2e test

  • In the CI run everything cargo test --all-features -- --include-ignored

.github/workflows/build.yml Outdated Show resolved Hide resolved
@weezy20
Copy link
Contributor

weezy20 commented Apr 1, 2024

cargo test --bins runs fast with 3 ignored test. However, if I run cargo test, I get the same followed by a somewhat time consuming:

running 3 tests
test test_contract_build_fails_if_no_contract_exists ... ok
test test_contract_build_specify_path ... ok
test test_contract_build ... ok

Why is test_contract_build running even after being #[ignore]d?

@AlexD10S
Copy link
Collaborator Author

AlexD10S commented Apr 2, 2024

cargo test --bins runs fast with 3 ignored test. However, if I run cargo test, I get the same followed by a somewhat time consuming:

running 3 tests
test test_contract_build_fails_if_no_contract_exists ... ok
test test_contract_build_specify_path ... ok
test test_contract_build ... ok

Why is test_contract_build running even after being #[ignore]d?

The ignored one was not being run, there were 2 tests called test_contract_build. I changed that. To run only unit tests now cargo test, to run e2e related to contracts: cargo test --features e2e_contract and to run everything ignored too: cargo test --all-features -- --include-ignored.

My doubt is still what to run in the CI, once we have the up tests run everything cargo test --all-features -- --include-ignored can take more than 2h but we will be sure the product is stable.

@AlexD10S AlexD10S requested a review from weezy20 April 2, 2024 06:52
@AlexD10S AlexD10S marked this pull request as ready for review April 2, 2024 08:26
@AlexD10S AlexD10S requested a review from brunopgalvao April 2, 2024 09:09
tests/build_contract.rs Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
.github/workflows/build.yml Outdated Show resolved Hide resolved
@weezy20
Copy link
Contributor

weezy20 commented Apr 3, 2024

My doubt is still what to run in the CI, once we have the up tests run everything cargo test --all-features -- --include-ignored can take more than 2h but we will be sure the product is stable.

So here's my suggestion. For product stability, i.e. sanity of generated template builds, it doesn't make sense to have them run whilst a PR is open for review or constantly being worked on. This slows us down.

At bare minimum unit tests must be run on PRs.
For e2e tests, specifically build_* tests, they can be merged only on merge to main. See https://stackoverflow.com/a/61565445/6591533

Copy link
Contributor

@brunopgalvao brunopgalvao left a comment

Choose a reason for hiding this comment

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

I am not a fan of using ignore. I would rather use a tiered approach.

cargo test
cargo test --features all_tests
cargo test --features all_unit_tests
cargo test --features all_contract_unit_tests
cargo test --features all_parachain_unit_tests
cargo test --features all_e2e_tests
cargo test --features all_e2e_contract_tests
cargo test --features all_e2e_parachain_tests

OR

cargo test
cargo test --features tier1_tests
cargo test --features tier2_tests
cargo test --features tier3_tests

where tier 1 would be least amount of tests and tier 3 would be full testing.

@AlexD10S
Copy link
Collaborator Author

AlexD10S commented Apr 4, 2024

I am not a fan of using ignore. I would rather use a tiered approach.

cargo test
cargo test --features all_tests
cargo test --features all_unit_tests
cargo test --features all_contract_unit_tests
cargo test --features all_parachain_unit_tests
cargo test --features all_e2e_tests
cargo test --features all_e2e_contract_tests
cargo test --features all_e2e_parachain_tests

OR

cargo test
cargo test --features tier1_tests
cargo test --features tier2_tests
cargo test --features tier3_tests

where tier 1 would be least amount of tests and tier 3 would be full testing.

Done! No more ignored tests

@AlexD10S AlexD10S requested review from brunopgalvao and weezy20 April 4, 2024 08:38
README.md Show resolved Hide resolved
Copy link
Contributor

@weezy20 weezy20 left a comment

Choose a reason for hiding this comment

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

Lgtm. Thanks @AlexD10S

@AlexD10S AlexD10S merged commit 60d7f80 into main Apr 4, 2024
1 check passed
@AlexD10S AlexD10S deleted the alex/improve-tests branch April 4, 2024 16:10
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.

3 participants