Skip to content

Tests: Replace String with Vec<u8> for stdout (stderr?) #1916

@Mikadore

Description

@Mikadore

Currently, the CmdResult struct has stdout as:

    /// captured utf-8 standard output after running the Command
    pub stdout: String,

This means that we can't completely test any utility that should be able to handle arbitrary bytes, for no added benefit.
The same holds true for stderr, which can hold binary data, but I don't know whether there are any legitimate uses for this.

As far as I can tell the implementation should be easy. This is the code of the run function:

pub fn run(&mut self) -> CmdResult {
        let prog = self.run_no_wait().wait_with_output().unwrap();

        CmdResult {
            tmpd: self.tmpd.clone(),
            code: prog.status.code(),
            success: prog.status.success(),
            stdout: from_utf8(&prog.stdout).unwrap().to_string(),
            stderr: from_utf8(&prog.stderr).unwrap().to_string(),
        }
    }

where stdout and stderr are needlessly converted. (ofc changing this will affect some other parts of the code)

I'd implement this once I'm done with #1911, if no one else shows interest

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions