~subsetpark/bagatto

6cc23665a2c107ea88378b2456278044f4d4219a — Zach Smith 3 months ago e1c958e
Add defrequire tests
3 files changed, 22 insertions(+), 1 deletions(-)

M src/core.janet
M src/env.janet
A test/require.janet
M src/core.janet => src/core.janet +1 -1
@@ 21,7 21,7 @@
  (thread/new (fn [parent]
                (temple/add-loader)
                (merge-into root-env bagatto)
                (setdyn :executable-blacklist env/exec-blacklist)
                (env/setdyn-blacklist!)
                (f parent))
              1 :hc))


M src/env.janet => src/env.janet +2 -0
@@ 41,6 41,8 @@
    (unless (on-path? check)
      (put exec-blacklist check true))))

(defn setdyn-blacklist! [] (setdyn :executable-blacklist exec-blacklist))

(defn prepare-root-env!
  []
  (prepare-syspath!)

A test/require.janet => test/require.janet +19 -0
@@ 0,0 1,19 @@
(import testament :prefix "" :exit true)
(import src/env)

(setdyn :executable-blacklist {})

(deftest in-place
  (env/defrequire "ls" should-run [] :ok)
  (env/prepare-root-env!)
  (env/setdyn-blacklist!)
  (is (= :ok (should-run))))

(deftest not-in-place
  (env/defrequire "this-application-cannot-be-found" should-fail [] :ok)
  (env/prepare-root-env!)
  (env/setdyn-blacklist!)
  (assert-thrown 
   (should-fail)))

(run-tests!)