1
0
mirror of https://github.com/janet-lang/janet synced 2024-12-24 07:20:27 +00:00

Add some test usage for the sample bundle.

This commit is contained in:
Calvin Rose 2024-05-25 12:57:09 -05:00
parent 7d8af2f99a
commit 2260a593bd
3 changed files with 13 additions and 2 deletions

View File

@ -0,0 +1,3 @@
(defn function
[x]
(+ x x))

View File

@ -0,0 +1,3 @@
(defn install
[manifest &]
(bundle/add-file manifest "dep2.janet"))

View File

@ -35,9 +35,10 @@
nil) nil)
# Setup a temporary syspath for manipultation # Setup a temporary syspath for manipultation
(def syspath (string "./" (gensym) "_jpm_tree.tmp")) (def syspath (string "./" (string (math/random)) "_jpm_tree.tmp"))
(rmrf syspath)
(os/mkdir syspath) (os/mkdir syspath)
(setdyn *syspath* (os/realpath syspath)) (put root-env *syspath* (os/realpath syspath))
(setdyn *out* @"") (setdyn *out* @"")
(assert (empty? (bundle/list)) "initial bundle/list") (assert (empty? (bundle/list)) "initial bundle/list")
(assert (empty? (bundle/topolist)) "initial bundle/topolist") (assert (empty? (bundle/topolist)) "initial bundle/topolist")
@ -74,6 +75,10 @@
(assert (= 3 (length (bundle/list))) "bundles are listed correctly 3") (assert (= 3 (length (bundle/list))) "bundles are listed correctly 3")
(assert (= 3 (length (bundle/topolist))) "bundles are listed correctly 4") (assert (= 3 (length (bundle/topolist))) "bundles are listed correctly 4")
# Check that we can import the main dependency
(import mymod)
(assert (= 288 (mymod/myfn 12)) "using sample-bundle")
# Manual uninstall of dep1 and dep2 shouldn't work either since that would break dependencies # Manual uninstall of dep1 and dep2 shouldn't work either since that would break dependencies
(assert-error "cannot uninstall sample-dep1, breaks dependent bundles @[\"sample-bundle\"]" (assert-error "cannot uninstall sample-dep1, breaks dependent bundles @[\"sample-bundle\"]"
(bundle/uninstall "sample-dep1")) (bundle/uninstall "sample-dep1"))