# file      : tests/builtin/echo.testscript
# license   : MIT; see accompanying LICENSE file

test.arguments = "echo"

: string
:
$* foo >foo

: strings
:
$* foo bar >"foo bar"

: big
:
: Echo a big string (about 250K) to test that the builtin is asynchronous.
:
{
  s="--------------------------------"
  s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s"
  s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s"
  s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s"
  s="$s$s"

  # Pass the echo argument via the driver's stdin.
  #
  test.options += -i

  # Sleep for 2 seconds before executing `cat` builtin to make sure that
  # `echo` builtin falls back to asynchronous implementation.
  #
  $* <"$s" | $0 -s 2 "cat" >"$s"

  $* <<"EOI" | $0 -s 2 "cat" >"foo $s bar"
    foo
    $s
    bar
    EOI
}

: empty
:
$* >''
