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

[Merged by Bors] - Move x records outputed from smdk test to --verbose #3169 #3234

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion crates/smartmodule-development-kit/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ mod set_public;
use std::path::{PathBuf};
use clap::Parser;
use anyhow::Result;
use tracing::debug;

use cmd::SmdkCommand;

Expand All @@ -23,6 +24,6 @@ fn main() -> Result<()> {
}

pub(crate) fn read_bytes_from_path(path: &PathBuf) -> Result<Vec<u8>> {
println!("loading module at: {}", path.display());
debug!("loading module at: {}", path.display());
std::fs::read(path).map_err(|err| anyhow::anyhow!("error reading wasm file: {}", err))
}
8 changes: 7 additions & 1 deletion crates/smartmodule-development-kit/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ pub struct TestCmd {
/// E.g. smdk test --text '{}' --transform='{"uses":"infinyon/[email protected]","with":{"spec":"[{\"operation\":\"default\",\"spec\":{\"source\":\"test\"}}]"}}'
#[clap(long, short, group = "TestSmartModule")]
transform: Vec<String>,

/// verbose output
#[clap(short = 'v', long = "verbose")]
verbose: bool,
}

fn parse_key_val(s: &str) -> Result<(String, String)> {
Expand Down Expand Up @@ -125,7 +129,9 @@ impl TestCmd {

let output = chain.process(SmartModuleInput::try_from(test_records)?, &metrics)?;

println!("{:?} records outputed", output.successes.len());
if self.verbose {
println!("{:?} records outputed", output.successes.len());
}
for output_record in output.successes {
let output_value = output_record.value.as_str()?;
println!("{output_value}");
Expand Down
24 changes: 12 additions & 12 deletions tests/cli/smdk_smoke_tests/smdk-basic.bats
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ setup_file() {
assert_success

# Test
run $SMDK_BIN test --text 'a'
run $SMDK_BIN test --verbose --text 'a'
assert_output --partial "1 records outputed"
assert_success
}
Expand Down Expand Up @@ -152,7 +152,7 @@ setup_file() {
assert_success

# Test
run $SMDK_BIN test --text '2'
run $SMDK_BIN test --verbose --text '2'
assert_output --partial "1 records outputed"
assert_output --partial "4"
assert_success
Expand Down Expand Up @@ -193,7 +193,7 @@ setup_file() {
assert_success

# Test
run $SMDK_BIN test --text '["foo", "bar"]'
run $SMDK_BIN test --verbose --text '["foo", "bar"]'
assert_output --partial "2 records outputed"
assert_output --partial "foo"
assert_output --partial "bar"
Expand Down Expand Up @@ -236,7 +236,7 @@ setup_file() {
assert_success

# Test
run $SMDK_BIN test --text '2'
run $SMDK_BIN test --verbose --text '2'
assert_output --partial "1 records outputed"
assert_output --partial "2"
assert_success
Expand Down Expand Up @@ -277,7 +277,7 @@ setup_file() {
assert_success

# Test
run $SMDK_BIN test --text '2'
run $SMDK_BIN test --verbose --text '2'
assert_output --partial "1 records outputed"
assert_output --partial "2"
assert_success
Expand Down Expand Up @@ -320,7 +320,7 @@ setup_file() {
assert_success

# Test
run $SMDK_BIN test --text 'a' -e key=value
run $SMDK_BIN test --verbose --text 'a' -e key=value
assert_output --partial "1 records outputed"
assert_success
}
Expand Down Expand Up @@ -502,7 +502,7 @@ setup_file() {
assert_success

# Test
run $SMDK_BIN test --text 'a'
run $SMDK_BIN test --verbose --text 'a'
assert_output --partial "1 records outputed"
assert_success
}
Expand Down Expand Up @@ -542,7 +542,7 @@ setup_file() {
assert_success

# Test
run $SMDK_BIN test --text '2'
run $SMDK_BIN test --verbose --text '2'
assert_output --partial "1 records outputed"
assert_output --partial "4"
assert_success
Expand Down Expand Up @@ -583,7 +583,7 @@ setup_file() {
assert_success

# Test
run $SMDK_BIN test --text '["foo", "bar"]'
run $SMDK_BIN test --verbose --text '["foo", "bar"]'
assert_output --partial "2 records outputed"
assert_output --partial "foo"
assert_output --partial "bar"
Expand Down Expand Up @@ -625,7 +625,7 @@ setup_file() {
assert_success

# Test
run $SMDK_BIN test --text '2'
run $SMDK_BIN test --verbose --text '2'
assert_output --partial "1 records outputed"
assert_output --partial "2"
assert_success
Expand Down Expand Up @@ -666,7 +666,7 @@ setup_file() {
assert_success

# Test
run $SMDK_BIN test --text '2'
run $SMDK_BIN test --verbose --text '2'
assert_output --partial "1 records outputed"
assert_output --partial "2"
assert_success
Expand Down Expand Up @@ -709,7 +709,7 @@ setup_file() {
assert_success

# Test
run $SMDK_BIN test --text 'a' -e key=value
run $SMDK_BIN test --verbose --text 'a' -e key=value
assert_output --partial "1 records outputed"
assert_success
}
Expand Down