Radish alpha
r
rad:z3qg5TKmN83afz2fj9z3fQjU8vaYE
Radicle CI adapter for native CI
Radicle
Git
feat: combine stdout and stderr into one stream
Lars Wirzenius committed 1 year ago
commit 1488501beda7f2bd0e221667b02a278e1223ff0a
parent d4141ef
3 files changed +6 -11
modified src/bin/run_log.rs
@@ -28,7 +28,6 @@ fn main() {
        Path::new("/tmp"),
        0,
        "This is stdout".as_bytes(),
-
        "Error messages go here".as_bytes(),
        started,
        ended,
    );
@@ -37,7 +36,6 @@ fn main() {
        Path::new("/tmp"),
        0,
        "This is stdout".as_bytes(),
-
        "Error messages go here".as_bytes(),
        started,
        ended,
    );
modified src/run.rs
@@ -207,9 +207,11 @@ impl Run {
        }

        let started = SystemTime::now();
-
        let argv0 = argv[0];
-
        let output = Command::new(argv0)
-
            .args(&argv[1..])
+
        let output = Command::new("bash")
+
            .arg("-c")
+
            .arg(r#""$@" 2>&1"#)
+
            .arg("--")
+
            .args(argv)
            .current_dir(cwd)
            .output()
            .map_err(|e| RunError::Command(argv.iter().map(|s| s.to_string()).collect(), e))?;
@@ -222,7 +224,6 @@ impl Run {
                .map_err(|e| RunError::Canonicalize(cwd.into(), e))?,
            exit,
            &output.stdout,
-
            &output.stderr,
            started,
            ended,
        );
modified src/runlog.rs
@@ -82,7 +82,6 @@ impl RunLog {
        cwd: &Path,
        exit: i32,
        stdout: &[u8],
-
        stderr: &[u8],
        started: SystemTime,
        ended: SystemTime,
    ) {
@@ -94,7 +93,6 @@ impl RunLog {
            cwd: cwd.into(),
            exit,
            stdout: stdout.to_vec(),
-
            stderr: stderr.to_vec(),
        });
    }

@@ -217,7 +215,6 @@ struct Command {
    cwd: PathBuf,
    exit: i32,
    stdout: Vec<u8>,
-
    stderr: Vec<u8>,
}

impl Command {
@@ -267,8 +264,7 @@ impl Command {

        body.push_child(Element::new(Tag::P).with_text(&format!("Exit code: {}", self.exit)));

-
        self.output(body, "Stdout:", &self.stdout);
-
        self.output(body, "Stderr:", &self.stderr);
+
        self.output(body, "Output (stdout and stderr):", &self.stdout);
    }

    fn output(&self, body: &mut Element, stream: &str, data: &[u8]) {