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

.include ../common.testscript

: cleanup
:
{{
  : enabled
  :
  $c <'touch a' && $b

  : disabled
  :
  $c <<EOI && $b
    touch --no-cleanup a;
    rm a
    EOI

  : existing
  :
  : Test that touching an existing file does not register cleanup. If it does
  : then the file would be removed while leaving the embedded scope, and so
  : the cleanup registered by the first touch would fail.
  :
  $c <<EOI && $b
    {{
      +touch a
      {
        touch ../a
      }
    }}
    EOI
}}

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

  : cleanup
  :
  {{
    : enabled
    :
    $c <'touch a' && $b

    : disabled
    :
    $c <<EOI && $b
      touch --no-cleanup a;
      rm a
      EOI

    : existing
    :
    : Test that touching an existing file does not register cleanup. If it does
    : then the file would be removed while leaving the embedded scope, and so
    : the cleanup registered by the first touch would fail.
    :
    $c <<EOI && $b
      {
        +touch a
        {
          touch ../a
        }
      }
      EOI
  }}
}}
