# file      : tests/dir-iterator/testscript
# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
# license   : MIT; see accompanying LICENSE file

test.options = -v

: file
:
mkdir a;
touch a/b;
$* a >"reg     b"

: dir
:
mkdir -p a/b;
$* a >"dir     b"

# Note that on Windows only directory symlinks are currently supported (see
# mksymlink() for details).
#
: dangling-link
:
if ($cxx.target.class != 'windows')
{
  +mkdir a
  +touch --no-cleanup a/b
  +ln -s a/b a/l
  +rm a/b

  +touch a/c

  $* ../a     >! 2>!       != 0 : keep
  $* -i ../a  >'reg     c'      : skip
}
else
{
  +mkdir a
  +mkdir --no-cleanup a/b
  +ln -s a/b a/bl
  +rmdir a/b

  +touch a/c

  +mkdir a/d
  +ln -s a/d a/dl

  # On Wine dangling symlinks are not visible (see mksymlink() for details).
  #
  #$* ../a >! 2>! != 0 : keep

  : skip
  :
  $* -i ../a >>~%EOO%
    %(reg     c|dir     d|sym dir dl)%{3}
    EOO
}