# file      : tests/test/script/builtin/sleep.testscript
# license   : MIT; see accompanying LICENSE file

.include ../common.testscript

: success
:
$c <<EOI && $b
  sleep 1
  EOI

: timeout
:
{{
  : failure
  :
  $c <<EOI && $b 2>>~%EOE% != 0
    env -t 1 -- sleep 86400
    EOI
    %testscript:.*: error: builtin sleep terminated: execution timeout expired%
    %.
    EOE

  : success
  :
  $c <<EOI && $b
    timeout --success 1;
    sleep 86400
    EOI
}}

: syntax-1
:
{{
  b = [cmdline] $regex.apply($b, '(.+testscript.syntax).+', "\1 = 1'")

  : success
  :
  $c <'sleep 1' && $b

  : timeout
  :
  {{
    : failure
    :
    $c <'env -t 1 -- sleep 86400' && $b 2>>~%EOE% != 0
      %testscript:.*: error: builtin sleep terminated: execution timeout expired%
      %.
      EOE

    : success
    :
    $c <<EOI && $b
      timeout --success 1;
      sleep 86400
      EOI
  }}
}}
