pub fn run_cmd(cmd: &str) -> Result<CmdOutput, StepError>Expand description
Run a shell command via sh -c.
Examples found in repository?
examples/coder.rs (line 120)
118 fn run(&mut self, mut state: Task, ctx: &mut Ctx) -> StepResult<Task> {
119 let manifest = ctx.get("manifest_path").unwrap_or("Cargo.toml").to_string();
120 let result = tools::run_cmd(&format!("cargo test --manifest-path {manifest} --lib"))?;
121
122 if result.success {
123 ctx.log("tester: all passed");
124 Ok((state, Outcome::Done))
125 } else {
126 state.test_output = result.stderr;
127 state.attempts += 1;
128 ctx.log(format!("tester: failed (attempt {})", state.attempts));
129
130 if state.attempts >= state.max_attempts {
131 Ok((
132 state,
133 Outcome::Fail("max fix attempts reached, tests still failing".into()),
134 ))
135 } else {
136 Ok((state, Outcome::Next("coder")))
137 }
138 }
139 }