Skip to content

Conversation

@moliholy
Copy link
Collaborator

@moliholy moliholy commented Oct 30, 2025

Closes #682.

This PR allows specifying an extra argument that acts a cargo test <filter>-compatible filter.

For instance, in the flipper contract you can now run:

pop test my_contract::tests
Screenshot 2025-10-30 at 13 13 28

OR

pop test my_contract::tests::it_works
Screenshot 2025-10-30 at 13 14 02

OR

pop test --e2e my_contract::e2e_tests::it_works
8972112a-d363-421c-acee-3defb168eb50

@moliholy moliholy requested a review from Daanvdplas October 30, 2025 12:14
@moliholy moliholy self-assigned this Oct 30, 2025
@moliholy moliholy requested a review from AlexD10S October 30, 2025 12:16
@moliholy moliholy force-pushed the feat/allow-specify-test-filter branch from 3840c65 to 502e68d Compare October 30, 2025 12:16
@codecov
Copy link

codecov bot commented Oct 30, 2025

Codecov Report

❌ Patch coverage is 56.81818% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.08%. Comparing base (c3dba17) to head (4c58a5c).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
crates/pop-cli/src/commands/test/mod.rs 25.00% 7 Missing and 2 partials ⚠️
crates/pop-common/src/test.rs 66.66% 0 Missing and 5 partials ⚠️
crates/pop-contracts/src/test.rs 76.92% 1 Missing and 2 partials ⚠️
crates/pop-cli/src/commands/test/contract.rs 0.00% 2 Missing ⚠️
@@            Coverage Diff             @@
##             main     #701      +/-   ##
==========================================
- Coverage   77.10%   77.08%   -0.03%     
==========================================
  Files         109      109              
  Lines       24753    24785      +32     
  Branches    24753    24785      +32     
==========================================
+ Hits        19087    19105      +18     
- Misses       3663     3671       +8     
- Partials     2003     2009       +6     
Files with missing lines Coverage Δ
crates/pop-cli/src/commands/mod.rs 68.00% <100.00%> (+0.16%) ⬆️
crates/pop-cli/src/main.rs 88.57% <100.00%> (+0.05%) ⬆️
crates/pop-cli/src/commands/test/contract.rs 0.00% <0.00%> (ø)
crates/pop-contracts/src/test.rs 79.06% <76.92%> (-3.29%) ⬇️
crates/pop-common/src/test.rs 72.41% <66.66%> (+0.19%) ⬆️
crates/pop-cli/src/commands/test/mod.rs 60.86% <25.00%> (-6.93%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@moliholy
Copy link
Collaborator Author

@AlexD10S @Daanvdplas another option is to respect the way cargo does it, which is NOT to have a --test flag and instead place the test filter as the argument. That can be conflictive in the future if we want to add subcommands, but I prefer to raise this now and gather your input.

For reference, cargo does it this way:

cargo test my_contract::tests

@Daanvdplas
Copy link
Collaborator

@AlexD10S @Daanvdplas another option is to respect the way cargo does it, which is NOT to have a --test flag and instead place the test filter as the argument. That can be conflictive in the future if we want to add subcommands, but I prefer to raise this now and gather your input.

For reference, cargo does it this way:

cargo test my_contract::tests

I personally think this is the way. And it should then also work like pop test --e2e it_works (so not the full path)

@moliholy
Copy link
Collaborator Author

moliholy commented Oct 30, 2025

I personally think this is the way.

Fine for me, but that will directly break in case in the future we add more subcommands.

And it should then also work like pop test --e2e it_works

Tests can be named equally between different scope (Rust mods). I don't think we should do it that way.

@Daanvdplas
Copy link
Collaborator

I personally think this is the way.

Fine for me, but that will directly break in case in the future we add more subcommands.

And it should then also work like pop test --e2e it_works

Tests can be named equally between different scope (Rust mods). I don't think we should do it that way.

Oke then we shouldn't do it

@moliholy
Copy link
Collaborator Author

moliholy commented Oct 30, 2025

@Daanvdplas refactored so that the --test or -t flags are replaced by an extra argument.

$ pop test --help
Test a Rust project

Usage: pop test [OPTIONS] [PATH] [FILTER]
       pop test <COMMAND>

Commands:
  on-runtime-upgrade  Test migrations
  execute-block       Executes the given block against some state
  fast-forward        Executes a runtime upgrade (optional), then mines a number of blocks while performing try-state checks
  create-snapshot     Create a chain state snapshot
  help                Print this message or the help of the given subcommand(s)

Arguments:
  [PATH]  Directory path without flag for your project [default: current directory]

Options:
  -p, --path <PATH>  Directory path for your project [default: current directory]
  -h, --help         Print help

Smart contract testing options:
  -e, --e2e           Run end-to-end tests
  -n, --node <NODE>   Path to the contracts node binary to run e2e tests [default: none]
  -y, --skip-confirm  Automatically source the needed binary required without prompting for confirmation
  [FILTER]        Run with the specified test filter

@moliholy moliholy force-pushed the feat/allow-specify-test-filter branch from 87e4c40 to 55dfefc Compare October 30, 2025 17:06
Copy link
Collaborator

@Daanvdplas Daanvdplas left a comment

Choose a reason for hiding this comment

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

Nice and clean, thanks!

@moliholy moliholy merged commit b065712 into main Oct 31, 2025
25 of 28 checks passed
@moliholy moliholy deleted the feat/allow-specify-test-filter branch October 31, 2025 10:36
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.

Allow naming specific test with pop test --e2e

3 participants