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

.include ../common.testscript

: dir
:
{
  : test-scope
  :
  : Removing scope directory fails.
  :
  $c <<EOI && $b
  rmdir ./ 2>/"rmdir: 'test/1/' contains test working directory 'test/1/'" == 1
  EOI

  : outside-scope
  :
  : Need to use a path that unlikely exists (not to remove something useful).
  :
  {
    : fail
    :
    : Removing directory outside the testscript working directory fails.
    :
    $c <<EOI && $b
    rmdir ../../a/b/c 2>>/EOE == 1
    rmdir: 'a/b/c/' is out of working directory 'test/'
    EOE
    EOI

    : force
    :
    : Removing path outside the testscript working directory succeeds with -f
    : option.
    :
    $c <'rmdir -f ../../a/b/c' && $b
  }
}
