Search results

There are no results.

std.test.Process

class pub Process

A child process to run as part of a unit test.

Instance methods

argument

Show source code
Hide source code
fn pub mut argument(value: String) {
  @cmd.arguments.push(value)
}
fn pub mut argument(value: String)

Adds an argument to the process.

spawn

Show source code
Hide source code
fn pub move spawn -> Output {
  let child = match @cmd.spawn {
    case Ok(child) -> child
    case Error(err) -> panic('Failed to spawn the child process: ${err}')
  }

  let _ = (child.stdin := Option.None).get.write_string(@stdin)
  let stdout = ByteArray.new
  let stderr = ByteArray.new
  let _ = child.stdout.as_mut.get.read_all(stdout)
  let _ = child.stderr.as_mut.get.read_all(stderr)
  let status = match child.wait {
    case Ok(val) -> val
    case Error(err) -> panic('Failed to wait for the child process: ${err}')
  }

  Output(
    status: status,
    stdout: stdout.into_string,
    stderr: stderr.into_string,
  )
}
fn pub move spawn -> Output

Spawns the process, waits for it to finish, and returns an Output containing the results.

stdin

Show source code
Hide source code
fn pub mut stdin(bytes: String) {
  @stdin = bytes
}
fn pub mut stdin(bytes: String)

Sets the data to write to STDIN.

variable

Show source code
Hide source code
fn pub mut variable(name: String, value: String) {
  @cmd.variables.set(name, value)
}
fn pub mut variable(name: String, value: String)

Adds or updates an environment variable to the process.