aboutsummaryrefslogtreecommitdiff
path: root/tests/test/hnh-util-env.scm
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2023-04-04 14:39:29 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2023-04-10 23:45:29 +0200
commitfc6759c3596b695634466330e37baa4d16222b0c (patch)
tree1e2b0ea4715ebe7afa3d0a8cf5ba95a223f24a77 /tests/test/hnh-util-env.scm
parentBorrow state-monad from guile-dns. (diff)
downloadcalp-fc6759c3596b695634466330e37baa4d16222b0c.tar.gz
calp-fc6759c3596b695634466330e37baa4d16222b0c.tar.xz
Reorder (util .*) tests.
Added test groups for each exported procedure (meaning that the TODOs are now updated (at least for (hnh util))). Split path tests out into own file. Also rename those files so they map 1-1 onto their core module names.
Diffstat (limited to 'tests/test/hnh-util-env.scm')
-rw-r--r--tests/test/hnh-util-env.scm47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/test/hnh-util-env.scm b/tests/test/hnh-util-env.scm
new file mode 100644
index 00000000..93f72bc9
--- /dev/null
+++ b/tests/test/hnh-util-env.scm
@@ -0,0 +1,47 @@
+(define-module (test hnh-util-env)
+ :use-module (srfi srfi-64)
+ :use-module (srfi srfi-64 test-error)
+ :use-module (srfi srfi-88)
+ :use-module ((guile) :select (setenv getenv))
+ :use-module ((hnh util env) :select (let-env)))
+
+
+(test-group "let-env"
+ (setenv "CALP_TEST_ENV" "1")
+
+ (test-equal
+ "Ensure we have set value beforehand"
+ "1"
+ (getenv "CALP_TEST_ENV"))
+
+ (let-env
+ ((CALP_TEST_ENV "2"))
+ (test-equal
+ "Test our local override"
+ "2"
+ (getenv "CALP_TEST_ENV")))
+
+ (test-equal
+ "Test that we have returned"
+ "1"
+ (getenv "CALP_TEST_ENV"))
+
+ (catch 'test-error
+ (lambda ()
+ (let-env
+ ((CALP_TEST_ENV "2"))
+ (test-equal
+ "Test our local override again"
+ "2"
+ (getenv "CALP_TEST_ENV"))
+ (throw 'test-error)))
+ list)
+
+ (test-equal
+ "Test restoration after non-local exit"
+ "1"
+ (getenv "CALP_TEST_ENV")))
+
+(test-group "with-working-directory"
+ 'TODO)
+