aboutsummaryrefslogtreecommitdiff
path: root/tests/test/script
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2019-07-22 22:37:40 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2019-07-24 21:37:58 +0300
commit72945d9c8eee18aed1550c3f42dc41e6a8a0f029 (patch)
tree9fdfe1c3bf48d0e303dc435c40116dacf48286b3 /tests/test/script
parent83bb02cada0b894d9134cc5489999e0f0fe8bd7c (diff)
Use CLI-generated classes to parse testscript builtin options
Diffstat (limited to 'tests/test/script')
-rw-r--r--tests/test/script/builtin/cat.testscript6
-rw-r--r--tests/test/script/builtin/cp.testscript6
-rw-r--r--tests/test/script/builtin/ln.testscript8
-rw-r--r--tests/test/script/builtin/mkdir.testscript8
-rw-r--r--tests/test/script/builtin/mv.testscript6
-rw-r--r--tests/test/script/builtin/rm.testscript6
-rw-r--r--tests/test/script/builtin/rmdir.testscript6
-rw-r--r--tests/test/script/builtin/sed.testscript10
-rw-r--r--tests/test/script/builtin/sleep.testscript6
-rw-r--r--tests/test/script/builtin/test.testscript58
-rw-r--r--tests/test/script/builtin/touch.testscript8
-rw-r--r--tests/test/script/runner/exit.testscript2
-rw-r--r--tests/test/script/runner/set.testscript18
13 files changed, 120 insertions, 28 deletions
diff --git a/tests/test/script/builtin/cat.testscript b/tests/test/script/builtin/cat.testscript
index d885b53..b23efcf 100644
--- a/tests/test/script/builtin/cat.testscript
+++ b/tests/test/script/builtin/cat.testscript
@@ -4,6 +4,12 @@
.include ../common.testscript
+: unknown-option
+:
+$c <<EOI && $b
+cat -u 2>"cat: unknown option '-u'" == 1
+EOI
+
: in
:
$c <<EOI && $b
diff --git a/tests/test/script/builtin/cp.testscript b/tests/test/script/builtin/cp.testscript
index 0d465e4..46828df 100644
--- a/tests/test/script/builtin/cp.testscript
+++ b/tests/test/script/builtin/cp.testscript
@@ -4,6 +4,12 @@
.include ../common.testscript
+: unknown-option
+:
+$c <<EOI && $b
+cp -u 2>"cp: unknown option '-u'" == 1
+EOI
+
: args
:
{
diff --git a/tests/test/script/builtin/ln.testscript b/tests/test/script/builtin/ln.testscript
index 4e1ea92..072c197 100644
--- a/tests/test/script/builtin/ln.testscript
+++ b/tests/test/script/builtin/ln.testscript
@@ -4,12 +4,18 @@
.include ../common.testscript
+: unknown-option
+:
+$c <<EOI && $b
+ln -u 2>"ln: unknown option '-u'" == 1
+EOI
+
: args
:
{
: -s-option
:
- $c <'ln 2>"ln: missing -s option" == 1' && $b
+ $c <'ln 2>"ln: missing -s|--symbolic option" == 1' && $b
: none
:
diff --git a/tests/test/script/builtin/mkdir.testscript b/tests/test/script/builtin/mkdir.testscript
index 573f73d..d1a3b4a 100644
--- a/tests/test/script/builtin/mkdir.testscript
+++ b/tests/test/script/builtin/mkdir.testscript
@@ -4,6 +4,12 @@
.include ../common.testscript
+: unknown-option
+:
+$c <<EOI && $b
+mkdir -u 2>"mkdir: unknown option '-u'" == 1
+EOI
+
: dirs
:
$c <<EOI && $b
@@ -28,7 +34,7 @@ $c <'mkdir -p a a a/b a/b' && $b
:
$c <<EOI && $b
mkdir -p -- -p;
-touch -p/a
+touch -- -p/a
EOI
: no-args
diff --git a/tests/test/script/builtin/mv.testscript b/tests/test/script/builtin/mv.testscript
index 313acf8..eb4860e 100644
--- a/tests/test/script/builtin/mv.testscript
+++ b/tests/test/script/builtin/mv.testscript
@@ -4,6 +4,12 @@
.include ../common.testscript
+: unknown-option
+:
+$c <<EOI && $b
+mv -u 2>"mv: unknown option '-u'" == 1
+EOI
+
: args
:
{
diff --git a/tests/test/script/builtin/rm.testscript b/tests/test/script/builtin/rm.testscript
index 0cc6f7c..46ed566 100644
--- a/tests/test/script/builtin/rm.testscript
+++ b/tests/test/script/builtin/rm.testscript
@@ -4,6 +4,12 @@
.include ../common.testscript
+: unknown-option
+:
+$c <<EOI && $b
+rm -u 2>"rm: unknown option '-u'" == 1
+EOI
+
: no-args
:
{
diff --git a/tests/test/script/builtin/rmdir.testscript b/tests/test/script/builtin/rmdir.testscript
index 1b19509..9f0c945 100644
--- a/tests/test/script/builtin/rmdir.testscript
+++ b/tests/test/script/builtin/rmdir.testscript
@@ -4,6 +4,12 @@
.include ../common.testscript
+: unknown-option
+:
+$c <<EOI && $b
+rmdir -u 2>"rmdir: unknown option '-u'" == 1
+EOI
+
: no-args
:
{
diff --git a/tests/test/script/builtin/sed.testscript b/tests/test/script/builtin/sed.testscript
index e3c0965..4a79fe3 100644
--- a/tests/test/script/builtin/sed.testscript
+++ b/tests/test/script/builtin/sed.testscript
@@ -4,6 +4,12 @@
.include ../common.testscript
+: unknown-option
+:
+$c <<EOI && $b
+sed -u 2>"sed: unknown option '-u'" == 1
+EOI
+
: arg
:
{
@@ -31,7 +37,7 @@
$c <'sed -e' && $b 2>>/EOE != 0
testscript:1:1: error: sed exit code 1 != 0
info: stderr: test/1/stderr
- sed: missing script
+ sed: missing value for option '-e'
info: test id: 1
EOE
@@ -321,7 +327,7 @@
$c <"sed -i -e 's/a/b/'" && $b 2>>/EOE != 0
testscript:1:1: error: sed exit code 1 != 0
info: stderr: test/1/stderr
- sed: -i option specified while reading from stdin
+ sed: -i|--in-place option specified while reading from stdin
info: test id: 1
EOE
diff --git a/tests/test/script/builtin/sleep.testscript b/tests/test/script/builtin/sleep.testscript
index c43418d..7d39548 100644
--- a/tests/test/script/builtin/sleep.testscript
+++ b/tests/test/script/builtin/sleep.testscript
@@ -4,6 +4,12 @@
.include ../common.testscript
+: unknown-option
+:
+$c <<EOI && $b
+sleep -u 2>"sleep: unknown option '-u'" == 1
+EOI
+
: success
:
$c <'sleep 1' && $b
diff --git a/tests/test/script/builtin/test.testscript b/tests/test/script/builtin/test.testscript
index 650f9ef..dceb229 100644
--- a/tests/test/script/builtin/test.testscript
+++ b/tests/test/script/builtin/test.testscript
@@ -42,30 +42,44 @@
EOI
}
-: no-args
+: options
:
-: Test passing no arguments.
-:
-$c <'test 2>"test: missing path" == 2' && $b
+{
+ : unknown
+ :
+ $c <<EOI && $b
+ test -u 2>"test: unknown option '-u'" == 2
+ EOI
-: invalid-option
-:
-: Test passing invalid option.
-:
-$c <'test -c a 2>"test: invalid option" == 2' && $b
+ : none
+ :
+ $c <<EOI && $b
+ test 2>"test: either -f|--file or -d|--directory must be specified" == 2
+ EOI
-: unexpected-arg
-:
-: Test passing extra argument.
-:
-$c <<EOI && $b
-test -f a b 2>"test: unexpected argument 'b'" == 2
-EOI
+ : both-file-dir
+ :
+ $c <<EOI && $b
+ test -f -d 2>"test: both -f|--file and -d|--directory specified" == 2
+ EOI
+}
-: empty-path
+: args
:
-: Test testing an empty path.
-:
-$c <<EOI && $b
-test -d '' 2>"test: invalid path ''" == 2
-EOI
+{
+ : none
+ :
+ $c <'test -f 2>"test: missing path" == 2' && $b
+
+ : unexpected
+ :
+ $c <<EOI && $b
+ test -f a b 2>"test: unexpected argument 'b'" == 2
+ EOI
+
+ : empty-path
+ :
+ $c <<EOI && $b
+ test -d '' 2>"test: invalid path ''" == 2
+ EOI
+}
diff --git a/tests/test/script/builtin/touch.testscript b/tests/test/script/builtin/touch.testscript
index a43386b..731f023 100644
--- a/tests/test/script/builtin/touch.testscript
+++ b/tests/test/script/builtin/touch.testscript
@@ -41,6 +41,12 @@ $c <<EOI && $b
}
EOI
+: unknown-option
+:
+$c <<EOI && $b
+touch -u 2>"touch: unknown option '-u'" == 1
+EOI
+
: no-args
:
: Test passing no arguments.
@@ -77,7 +83,7 @@ EOI
: no-value
:
$c <<EOI && $b
- touch --after 2>'touch: missing --after option value' != 0
+ touch --after 2>"touch: missing value for option '--after'" != 0
EOI
: not-exists
diff --git a/tests/test/script/runner/exit.testscript b/tests/test/script/runner/exit.testscript
index 261b02d..b461155 100644
--- a/tests/test/script/runner/exit.testscript
+++ b/tests/test/script/runner/exit.testscript
@@ -96,7 +96,7 @@ empty_id = ''
: Note that we also test that cleanups are executed.
:
$c <<EOI && $b >>EOO
- touch -f a;
+ touch a;
echo foo >| && exit && echo bar >|;
echo baz >|
echo box >|
diff --git a/tests/test/script/runner/set.testscript b/tests/test/script/runner/set.testscript
index 28d6686..edbff3e 100644
--- a/tests/test/script/runner/set.testscript
+++ b/tests/test/script/runner/set.testscript
@@ -40,6 +40,24 @@
EOE
}
+: options
+:
+{
+ : unknown
+ :
+ $c <'set -u' && $b 2>>EOE != 0
+ testscript:1:1: error: set: unknown option '-u'
+ info: test id: 1
+ EOE
+
+ : both-newline-whitespace
+ :
+ $c <'set -nw' && $b 2>>EOE != 0
+ testscript:1:1: error: both -n|--newline and -w|--whitespace specified
+ info: test id: 1
+ EOE
+}
+
: arguments
:
{