scarb
scarb copied to clipboard
Showcase `scarb cairo-test` arguments in `scarb test --help` output
Problem
Users are confused by the fact that scarb test
does not include scarb cairo-test
's arguments in its --help
output. The Run 'scarb test -- --help for test program options.
message seems to be overlooked.
Proposed Solution
Perhaps add a separate clap
heading that we'll somehow populate (semi)automatically?
https://docs.rs/clap/latest/clap/struct.Command.html#method.defer may be helpful
Suggested help outputs
[!IMPORTANT] These are just suggestions to target. The final code does not have to match this 1:1 if this would be very hard to achieve.
scarb test --help
:
Execute all unit and integration tests of a local package
By default, this command delegates to `scarb cairo-test`. This behaviour can be changed by defining a script named `test` in workspace Scarb.toml file.
Run `scarb test -- --help` for test program options.
Usage: scarb test [OPTIONS] [ARGS]...
Arguments:
[ARGS]... Arguments for the test program
Options:
-p, --package <SPEC> Packages to run this command on, can be a concrete package name (`foobar`) or a prefix glob (`foo*`) [env: SCARB_PACKAGES_FILTER=] [default: *]
-v, --verbose... Increase logging verbosity.
-w, --workspace Run for all packages in the workspace
-F, --features <FEATURES> Comma separated list of features to activate [env: SCARB_FEATURES=]
-q, --quiet... Decrease logging verbosity.
--all-features Activate all available features [env: SCARB_ALL_FEATURES=]
--verbosity <VERBOSITY> Set UI verbosity level by name. [env: SCARB_UI_VERBOSITY=]
--no-default-features Do not activate the `default` feature [env: SCARB_NO_DEFAULT_FEATURES=]
-h, --help Print help
Options for cairo-test:
-f, --filter <FILTER> Run only tests whose name contain FILTER [default: ]
--include-ignored Run ignored and not ignored tests
--ignored Run only ignored tests
--print-resource-usage Whether to print resource usage after each test
scarb cairo-test --help
- this one should stay unchanged
Execute all unit tests of a local package
Usage: scarb-cairo-test [OPTIONS]
Options:
-p, --package <SPEC> Packages to run this command on, can be a concrete package name (`foobar`) or a prefix glob (`foo*`) [env: SCARB_PACKAGES_FILTER=] [default: *]
-w, --workspace Run for all packages in the workspace
-f, --filter <FILTER> Run only tests whose name contain FILTER [default: ]
--include-ignored Run ignored and not ignored tests
--ignored Run only ignored tests
--print-resource-usage Whether to print resource usage after each test
-h, --help Print help
-V, --version Print version
Notes by @mkaput
We are using derive-style clap.
scarb cairo-test
arguments are defined here:
https://github.com/software-mansion/scarb/blob/7f67815ee8c482edbcd2d52e5d3549de305a87de/extensions/scarb-cairo-test/src/main.rs#L14-L36
scarb test
args are here:
https://github.com/software-mansion/scarb/blob/a5e4c114c45005ede8346849c006fe04ad361de2/scarb/src/bin/scarb/args.rs#L386-L399
In scarb test
arguments there is a "catch-all" used and we don't want the cairo-test
specific arguments to eat them. This is the hard part here that I don't know how to solve. Because I think the easiest would be to add cairo-test
arguments as #[flatten]
. These could be "imported" via the following module hack:
#[path = "......"]
mod foo
like it is done in scarb-test-support
:
https://github.com/software-mansion/scarb/blob/8ea3887f39990f1dd89d9069027fe43a2c3f0128/utils/scarb-test-support/src/fsx.rs#L14-L16
Hi, I would like to try this!
The task is yours 😄
Do you have an idea how to approach this nicely, without copy-pasting help docs?
Thanks for assigning it to me!
I am still figuring some things out, is there a telegram group where I can ask questions if needed?
I am still figuring some things out, is there a telegram group where I can ask questions if needed?
https://t.me/+G_YxIv-XTFlhNWU0
Unassigning from Steven as discussed offline. This task is again open for taking!
I am also going to update issue description with insights we gathered with Steven.
I am applying to this issue via OnlyDust platform.
My background and how it can be leveraged
I have contributed to a lot of project in Starknet and worked in the ecosystem, I have experience in Rust
How I plan on tackling this issue
Read the codebase to see the current implementation and investigate the proposed solution
Hi @chachaleo ! We will welcome any contributions, but please be aware we don't have any funds assigned on the only dust platform.
No problem, happy to work on this :)