-
Notifications
You must be signed in to change notification settings - Fork 119
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
impl: test sub cmd with support for --manifest-path (#280) #283
The head ref may contain hidden characters: "t\u00FCv"
Conversation
User @chiefbiiko, please sign the CLA here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What precisely is the win of having cargo contract test
over just using cargo test
as it can be done right now?
@Robbepop At the moment
If one invokes So we could either remove the sub-command or just hand over to What's your opinion? |
I currently do not see a major reason but it might help against confusion. So yeah let's do it the proposed way. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, it looks good!
I've got just some minor things. We use the writing off-chain
everywhere, hence the suggestion of keeping it consistent.
Cargo.toml
Outdated
@@ -3,7 +3,7 @@ members = [".", "metadata"] | |||
|
|||
[package] | |||
name = "cargo-contract" | |||
version = "0.12.1" | |||
version = "0.13.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
version = "0.13.0" | |
version = "0.12.1" |
Good that you thought of this, but we plan on having another change in the next release as well, so let's wait for that :-).
CHANGELOG.md
Outdated
## [0.13.0] - 2021-05-27 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
## [0.13.0] - 2021-05-27 |
README.md
Outdated
@@ -87,6 +87,9 @@ toolchain of a directory by executing `rustup override set nightly` in it. | |||
Checks that the code builds as WebAssembly. This command does not output any `<name>.contract` | |||
artifact to the `target/` directory. | |||
|
|||
##### `cargo contract test` | |||
|
|||
Runs test suites defined for a smart contract - offchain. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Runs test suites defined for a smart contract - offchain. | |
Runs test suites defined for a smart contract off-chain. |
@@ -99,6 +99,7 @@ test-new-project-template: | |||
|
|||
- cargo run --all-features -- contract build --manifest-path new_project/Cargo.toml | |||
- cargo run --all-features -- contract check --manifest-path new_project/Cargo.toml | |||
- cargo run --all-features -- contract test --manifest-path new_project/Cargo.toml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great that you thought of adding it here!
Cargo.lock
Outdated
@@ -487,7 +487,7 @@ dependencies = [ | |||
|
|||
[[package]] | |||
name = "cargo-contract" | |||
version = "0.12.1" | |||
version = "0.13.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
version = "0.13.0" | |
version = "0.12.1" |
src/cmd/test.rs
Outdated
#[derive(Debug, StructOpt)] | ||
#[structopt(name = "test")] | ||
pub struct TestCommand { | ||
/// Path to the Cargo.toml of the contract to test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Path to the Cargo.toml of the contract to test | |
/// Path to the `Cargo.toml` of the contract to test |
src/cmd/test.rs
Outdated
use std::{convert::TryFrom, path::PathBuf}; | ||
use structopt::StructOpt; | ||
|
||
/// Executes smart-contract tests offchain by delegating to `cargo test`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Executes smart-contract tests offchain by delegating to `cargo test`. | |
/// Executes smart-contract tests off-chain by delegating to `cargo test`. |
src/cmd/test.rs
Outdated
} | ||
} | ||
|
||
/// Executes cargo +nightly test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Executes cargo +nightly test. | |
/// Executes `cargo +nightly test`. |
src/cmd/test.rs
Outdated
with_new_contract_project(|manifest_path| { | ||
let res = super::execute(&manifest_path, Verbosity::Default).expect("test failed"); | ||
|
||
assert!(res.stdout.len() > 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add another assertions which checks for something like test result: ok. 2 passed; 0 failed; 0 ignored
?
This way we can then be sure that there was no other unrelated failure the cause of stdout.len() > 0
.
CHANGELOG.md
Outdated
## [0.13.0] - 2021-05-27 | ||
|
||
### Added | ||
- Convenient offchain testing through `cargo contract test` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Convenient offchain testing through `cargo contract test` | |
- Convenient off-chain testing through `cargo contract test` |
thanks for the review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
drafts
cargo contract test [FLAGS] [--manifest-path]
in this first impl stdout is uncolored
let me know if you care much for the colors