Skip to content

Commit

Permalink
Fix flaky REPL tests, ensure static is false in REPL evals
Browse files Browse the repository at this point in the history
  • Loading branch information
Olical committed Oct 24, 2021
1 parent 270731c commit 4bb3a4c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
1 change: 1 addition & 0 deletions fnl/aniseed/eval.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
(set eval-values nil)

(fn [code]
(global ANISEED_STATIC_MODULES false)
(coroutine.resume co code)
(let [prev-eval-values eval-values]
(set eval-values nil)
Expand Down
1 change: 1 addition & 0 deletions lua/aniseed/eval.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ local function repl(opts)
coroutine.resume(co, compile["macros-prefix"](nil, opts0))
eval_values = nil
local function _7_(code)
ANISEED_STATIC_MODULES = false
coroutine.resume(co, code)
local prev_eval_values = eval_values
eval_values = nil
Expand Down
29 changes: 15 additions & 14 deletions test/fnl/aniseed/eval-test.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,28 @@
(t.= (contains? last-error "ohno")))

;; Using Aniseed module macros.
;; TODO These tests are flaky... why!?
(let [eval-a! (eval.repl)
eval-b! (eval.repl)]
;; Ensure you can run this test multiple times in one session.
(tset package.loaded :eval-test-module nil)

;; Creating a new module
;; Ensure you can run this test multiple times in one session.
(tset package.loaded :eval-test-module nil)
(tset package.preload :eval-test-module nil)

;; Creating a new module
(let [eval-a! (eval.repl)]
(t.pr= [] (eval-a! "(module eval-test-module)"))
(t.pr= [] (eval-a! "(def world 25)"))
(t.pr= [] (eval-a! "(def- shh 10)"))
(t.pr= [40] (eval-a! "(+ 15 world)"))
(t.pr= [40] (eval-a! "(+ 15 world)")))

;; Entering an existing module
;; Entering an existing module
(let [eval-b! (eval.repl)]
(t.pr= [] (eval-b! "(module eval-test-module)"))
(t.pr= [40] (eval-b! "(+ 15 world)"))
(t.pr= [25] (eval-b! "(+ 15 shh)"))
(t.pr= [] (eval-b! "(def world (+ world 20))"))
(t.pr= [] (eval-b! "(def- shh (+ shh 10))"))
(t.pr= [] (eval-b! "(def- shh (+ shh 10))")))

;; And again!
(let [eval-c! (eval.repl)]
(t.pr= [] (eval-c! "(module eval-test-module)"))
(t.pr= [60] (eval-c! "(+ 15 world)"))
(t.pr= [35] (eval-c! "(+ 15 shh)")))))
;; And again!
(let [eval-c! (eval.repl)]
(t.pr= [] (eval-c! "(module eval-test-module)"))
(t.pr= [60] (eval-c! "(+ 15 world)"))
(t.pr= [35] (eval-c! "(+ 15 shh)"))))

0 comments on commit 4bb3a4c

Please sign in to comment.