aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2017-06-21 18:40:49 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2017-06-21 20:02:08 +0300
commitaf8747969925a0815c09825ee8420a1be9dcc6c7 (patch)
tree7d43c43f4c0ff2b53a276e4d6ff95d60554c51a0 /tests
parentf6c20ad37b2ececb446b5051837bccba93c81d7a (diff)
Add support for $envvar() function
Diffstat (limited to 'tests')
-rw-r--r--tests/function/builtin/testscript61
1 files changed, 61 insertions, 0 deletions
diff --git a/tests/function/builtin/testscript b/tests/function/builtin/testscript
index 0b005f3..3e27958 100644
--- a/tests/function/builtin/testscript
+++ b/tests/function/builtin/testscript
@@ -60,3 +60,64 @@
$* <'print $identity(abc)' >'abc';
$* <'print $type($identity(abc))' >'' : untyped
}
+
+: getenv
+:
+{
+ : set
+ :
+ : Here we rely on the facts that on POSIX PATH environment variable most
+ : likely is set at the time of login, and on Windows it is set by build2 on
+ : startup.
+ :
+ : @@ Use a custom variable, when an ability to set environment variables in
+ : testscript is implemented.
+ :
+ {
+ : string
+ :
+ $* <'print $getenv([string] "PATH")' | set v;
+ ($v != '[null]') || exit "PATH environment variable is not set"
+
+ : untyped
+ :
+ $* <'print $getenv("PATH")' | set v;
+ ($v != '[null]') || exit "PATH environment variable is not set"
+
+ : path
+ :
+ $* <'print $getenv([path] a)' 2>>~/EOE/ != 0
+ <stdin>:1:8: error: unmatched call to getenv(path)
+ /((
+ info: candidate: getenv(<untyped>), qualified name builtin.getenv
+ info: candidate: getenv(string), qualified name builtin.getenv
+ /)|(
+ info: candidate: getenv(string), qualified name builtin.getenv
+ info: candidate: getenv(<untyped>), qualified name builtin.getenv
+ /))
+ EOE
+
+ : none
+ :
+ $* <'print $getenv()' 2>>~/EOE/ != 0
+ <stdin>:1:8: error: unmatched call to getenv()
+ /((
+ info: candidate: getenv(<untyped>), qualified name builtin.getenv
+ info: candidate: getenv(string), qualified name builtin.getenv
+ /)|(
+ info: candidate: getenv(string), qualified name builtin.getenv
+ info: candidate: getenv(<untyped>), qualified name builtin.getenv
+ /))
+ EOE
+
+ : names
+ :
+ $* <'print $getenv(a b)' 2>>EOE != 0
+ error: invalid argument: invalid string value: multiple names
+ EOE
+ }
+
+ : unset
+ :
+ $* <'print $getenv("non-existent-var-name")' >'[null]'
+}