tests/testthat/test-stdin.R

context("test-stdin")

test_that("streaming from stdin works", {
  tmp <- tempfile()
  input <- c("foo", "bar", "baz")
  writeLines(input, con = tmp)
  res <- exec_internal('sort', std_in = tmp)
  expect_equal(res$status, 0)
  con <- rawConnection(res$stdout)
  output <- readLines(con)
  close(con)
  expect_equal(output, sort(input))
})

Try the sys package in your browser

Any scripts or data that you put into this service are public.

sys documentation built on May 31, 2023, 8:32 p.m.