Skip to content
Merged
4 changes: 2 additions & 2 deletions crates/icp-cli/src/commands/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use icp::{

use crate::{
commands::Context,
progress::{MAX_LINES_PER_STEP, ProgressManager, RollingLines, ScriptProgressHandler},
progress::{MAX_LINES_PER_STEP, ProgressManager, ScriptProgressHandler},
};

#[derive(Parser, Debug)]
Expand Down Expand Up @@ -177,7 +177,7 @@ pub async fn exec(ctx: &Context, cmd: Cmd) -> Result<(), CommandError> {
#[derive(Debug)]
struct StepOutput {
title: String,
output: RollingLines,
output: Vec<String>,
Comment thread
viviveevee marked this conversation as resolved.
Outdated
}

fn dump_build_output(ctx: &Context, canister_name: &str, step_outputs: Vec<StepOutput>) {
Expand Down
8 changes: 6 additions & 2 deletions crates/icp-cli/src/progress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ impl RollingLines {
pub fn iter(&self) -> impl Iterator<Item = &str> {
self.buf.iter().map(|s| s.as_str())
}

pub fn into_iter(self) -> impl Iterator<Item = String> {
self.buf.into_iter()
}
}

/// Shared progress bar utilities for build and sync commands
Expand Down Expand Up @@ -163,7 +167,7 @@ impl ScriptProgressHandler {

/// Create a channel and start handling script output for progress updates
/// Returns the sender and a join handle for the background receiver task.
pub fn setup_output_handler(&self) -> (mpsc::Sender<String>, JoinHandle<RollingLines>) {
pub fn setup_output_handler(&self) -> (mpsc::Sender<String>, JoinHandle<Vec<String>>) {
let (tx, mut rx) = mpsc::channel::<String>(100);

// Shared progress-bar messaging utility
Expand Down Expand Up @@ -195,7 +199,7 @@ impl ScriptProgressHandler {
set_message(msg);
}

complete
complete.into_iter().collect()
});

(tx, handle)
Expand Down
8 changes: 5 additions & 3 deletions crates/icp-cli/tests/build_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ fn build_adapter_display_failing_prebuilt_output() {
command: echo "initial step succeeded"
- type: pre-built
path: /nonexistent/path/to/wasm.wasm
sha256: 0000000000000000000000000000000000000000000000000000000000000000
sha256: invalid
"#};

write_string(
Expand All @@ -170,7 +170,9 @@ fn build_adapter_display_failing_prebuilt_output() {
))
.stdout(contains("initial step succeeded"))
.stdout(contains(
"Building: pre-built (path: /nonexistent/path/to/wasm.wasm, sha: 0000000000000000000000000000000000000000000000000000000000000000) 2 of 2",
"Building: pre-built (path: /nonexistent/path/to/wasm.wasm, sha: invalid) 2 of 2",
))
.stdout(contains("Reading local file: /nonexistent/path/to/wasm.wasm"));
.stdout(contains(
"Reading local file: /nonexistent/path/to/wasm.wasm",
));
}
10 changes: 3 additions & 7 deletions crates/icp/src/canister/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ impl Build for Script {

// Iterate over configured commands
for input_cmd in cmds {
stdio
.send(format!("Running command: {}", input_cmd))
.await?;

// Parse command input
let input = shellwords::split(&input_cmd).context(ScriptError::Parse {
command: input_cmd.to_owned(),
Expand Down Expand Up @@ -110,7 +106,7 @@ impl Build for Script {
// Spawn command and handle stdio
// We need to join! as opposed to try_join! even if we only care about the result of the task
// because we want to make sure we finish reading all of the output
let (stdout_result, stderr_result, status) = join!(
let (stdout, stderr, status) = join!(
//
// Stdout
tokio::spawn({
Expand Down Expand Up @@ -144,8 +140,8 @@ impl Build for Script {
child.wait().await
}),
);
stdout_result??;
stderr_result??;
stdout??;
stderr??;

// Status
let status =
Expand Down