Skip to content

impl: test sub cmd with support for --manifest-path (#280)#283

Merged
cmichi merged 1 commit into
use-ink:masterfrom
chiefbiiko:tüv
Jul 3, 2021

Hidden character warning

The head ref may contain hidden characters: "t\u00fcv"
Merged

impl: test sub cmd with support for --manifest-path (#280)#283
cmichi merged 1 commit into
use-ink:masterfrom
chiefbiiko:tüv

Conversation

@chiefbiiko

Copy link
Copy Markdown
Contributor

drafts cargo contract test [FLAGS] [--manifest-path]

in this first impl stdout is uncolored

let me know if you care much for the colors

@cla-bot-2021

cla-bot-2021 Bot commented May 27, 2021

Copy link
Copy Markdown

User @chiefbiiko, please sign the CLA here.

@Robbepop Robbepop left a comment

Copy link
Copy Markdown
Contributor

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?

@cmichi

cmichi commented Jun 17, 2021

Copy link
Copy Markdown
Collaborator

@Robbepop At the moment cargo contract --help shows the sub-command as:

test     Test the smart contract off-chain

If one invokes cargo contract test currently this results in an unimplemented! panic though, which is why people were irritated and started creating issues about it in this repository.

So we could either remove the sub-command or just hand over to cargo test. After talking to @ascjones we concluded that it's probably best to just spawn a sub-process with cargo test until we have further ideas what to do with the sub-command (#280).

What's your opinion?

@Robbepop

Copy link
Copy Markdown
Contributor

@Robbepop At the moment cargo contract --help shows the sub-command as:

test     Test the smart contract off-chain

If one invokes cargo contract test currently this results in an unimplemented! panic though, which is why people were irritated and started creating issues about it in this repository.

So we could either remove the sub-command or just hand over to cargo test. After talking to @ascjones we concluded that it's probably best to just spawn a sub-process with cargo test until we have further ideas what to do with the sub-command (#280).

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.

@cmichi cmichi left a comment

Copy link
Copy Markdown
Collaborator

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.

Comment thread Cargo.toml Outdated
[package]
name = "cargo-contract"
version = "0.12.1"
version = "0.13.0"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
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 :-).

Comment thread CHANGELOG.md Outdated
Comment on lines +9 to +10
## [0.13.0] - 2021-05-27

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
## [0.13.0] - 2021-05-27

Comment thread README.md Outdated

##### `cargo contract test`

Runs test suites defined for a smart contract - offchain.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Runs test suites defined for a smart contract - offchain.
Runs test suites defined for a smart contract off-chain.

Comment thread .gitlab-ci.yml

- 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

Copy link
Copy Markdown
Collaborator

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!

Comment thread Cargo.lock Outdated
[[package]]
name = "cargo-contract"
version = "0.12.1"
version = "0.13.0"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
version = "0.13.0"
version = "0.12.1"

Comment thread src/cmd/test.rs Outdated
#[derive(Debug, StructOpt)]
#[structopt(name = "test")]
pub struct TestCommand {
/// Path to the Cargo.toml of the contract to test

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// Path to the Cargo.toml of the contract to test
/// Path to the `Cargo.toml` of the contract to test

Comment thread src/cmd/test.rs Outdated
use std::{convert::TryFrom, path::PathBuf};
use structopt::StructOpt;

/// Executes smart-contract tests offchain by delegating to `cargo test`.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// Executes smart-contract tests offchain by delegating to `cargo test`.
/// Executes smart-contract tests off-chain by delegating to `cargo test`.

Comment thread src/cmd/test.rs Outdated
}
}

/// Executes cargo +nightly test.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// Executes cargo +nightly test.
/// Executes `cargo +nightly test`.

Comment thread 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);

Copy link
Copy Markdown
Collaborator

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.

Comment thread CHANGELOG.md Outdated
## [0.13.0] - 2021-05-27

### Added
- Convenient offchain testing through `cargo contract test`

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- Convenient offchain testing through `cargo contract test`
- Convenient off-chain testing through `cargo contract test`

@chiefbiiko

Copy link
Copy Markdown
Contributor Author

thanks for the review
i have included your suggestions now

@cmichi cmichi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the PR!

@cmichi
cmichi merged commit 78d4d4e into use-ink:master Jul 3, 2021
@cmichi cmichi mentioned this pull request Jul 3, 2021
4 tasks
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