aboutsummaryrefslogtreecommitdiff
path: root/tests/test/script/builtin/rm.testscript
blob: 7160c73972e8232640a1fbd6d2f7f3437e7ba7cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# file      : tests/test/script/builtin/rm.testscript
# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
# license   : MIT; see accompanying LICENSE file

.include ../common.testscript

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

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

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