aboutsummaryrefslogtreecommitdiff
path: root/tests/builtin/test.testscript
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2019-09-06 22:20:46 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2019-09-27 17:08:05 +0300
commit1c6758009e82c47b5b341d418be2be401ef31482 (patch)
treed3ef8c053280477086f6230e3d25ff90b25871a2 /tests/builtin/test.testscript
parent070871d97b4f6440c3f0fc647ece73b53a5837db (diff)
Add builtins support
Diffstat (limited to 'tests/builtin/test.testscript')
-rw-r--r--tests/builtin/test.testscript84
1 files changed, 84 insertions, 0 deletions
diff --git a/tests/builtin/test.testscript b/tests/builtin/test.testscript
new file mode 100644
index 0000000..3e132d9
--- /dev/null
+++ b/tests/builtin/test.testscript
@@ -0,0 +1,84 @@
+# file : tests/builtin/test.testscript
+# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
+test.arguments = "test"
+
+: file
+:
+{
+ : exists
+ :
+ touch a;
+ $* -f a
+
+ : not-exists
+ :
+ $* -f a == 1
+
+ : not-file
+ :
+ $* -f . == 1
+}
+
+: dir
+:
+{
+ : exists
+ :
+ $* -d .
+
+ : not-exists
+ :
+ $* -d a == 1
+
+ : not-dir
+ :
+ touch a;
+ $* -d a == 1
+}
+
+: options
+:
+{
+ : unknown
+ :
+ $* -u 2>"test: unknown option '-u'" == 2
+
+ : none
+ :
+ $* 2>"test: either -f|--file or -d|--directory must be specified" == 2
+
+ : both-file-dir
+ :
+ $* -fd 2>"test: both -f|--file and -d|--directory specified" == 2
+}
+
+: args
+:
+{
+ : none
+ :
+ $* -f 2>"test: missing path" == 2
+
+ : unexpected
+ :
+ $* -f a b 2>"test: unexpected argument 'b'" == 2
+
+ : empty-path
+ :
+ $* -d '' 2>"test: invalid path ''" == 2
+}
+
+: cwd
+:
+: When cross-testing we cannot guarantee that host absolute paths are
+: recognized by the target process.
+:
+if ($test.target == $build.host)
+{
+ test.options += -d $~/a;
+ mkdir -p a/b;
+
+ $* -d b
+}