Skip to content

Commit

Permalink
don't run graphical tests when jvm is headless
Browse files Browse the repository at this point in the history
  • Loading branch information
ogeagla committed Feb 16, 2024
1 parent a7d5a40 commit 307edd0
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 74 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/clojure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: Clojure CI
on:
push:
branches: [ "master" ]
# pull_request:
# branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:
Expand Down
149 changes: 77 additions & 72 deletions test/closyr/symbolic_regression_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
[closyr.ops :as ops]
[closyr.ops.common :as ops-common]
[closyr.ops.initialize :as ops-init]
[closyr.symbolic-regression :as symreg]))
[closyr.symbolic-regression :as symreg])
(:import
(java.awt
GraphicsEnvironment)))


(alter-var-root #'symreg/*is-testing* (constantly true))
Expand Down Expand Up @@ -202,77 +205,79 @@


(deftest can-run-experiment-gui:start-restart-stop
(binding [ops/*print-top-n* 1]
(testing "gui can start and restart experiments; NOTE: do not run this while in headless mode, eg on CI"
(with-redefs-fn {#'symreg/config->log-steps (fn [_ _] 500)}
(fn []
(let [control-process (go
(<! (timeout 200))

(is (put! symreg/*sim-stop-start-chan*
{:new-state :start
:input-data-x [0 1 2 3 4]
:input-data-y [1 3 6 18 8]
:input-iters 200
:input-phenos-count 500}))

(<! (timeout 100))
(is (put! symreg/*sim-stop-start-chan*
{:new-state :pause}))
(<! (timeout 100))
(is (put! symreg/*sim-stop-start-chan*
{:new-state :start}))
(<! (timeout 100))
(is (put! symreg/*sim-stop-start-chan*
{:new-state :pause}))
(<! (timeout 100))

(is (put! symreg/*sim-stop-start-chan*
{:new-state :restart
:input-data-x [0 1 2 3 4]
:input-data-y [1 13 16 8 8]
:input-iters 1500
:input-phenos-count 500}))

(<! (timeout 100))

(is (put! symreg/*sim-stop-start-chan*
{:new-state :restart
:input-data-x [0 1 2 3 4]
:input-data-y [1 13 16 8 8]
:input-iters 5
:input-phenos-count 5}))

(<! (timeout 100))

(is (put! symreg/*sim-stop-start-chan*
{:new-state :restart
:input-data-x [0 1 2 3 4]
:input-data-y [11 3 6 18 8]
:input-iters 300
:input-phenos-count 400}))

(<! (timeout 100))

(is (put! symreg/*sim-stop-start-chan*
{:new-state :stop}))

(<! (timeout 100))

(is (put! symreg/*gui-close-chan* :close-please))
(is (put! symreg/*sim->gui-chan* :next))
true)]

(symreg/run-solver
{:initial-phenos (ops-init/initial-phenotypes 20)
:initial-muts (ops-init/initial-mutations)
:input-xs-exprs symreg/example-input-xs-exprs
:input-ys-exprs symreg/example-input-ys-exprs
:iters 20
:use-gui? true})


(is (= (<!! control-process) true))))))))
(when (not (GraphicsEnvironment/isHeadless))
(binding [ops/*print-top-n* 1]
(testing "gui can start and restart experiments; NOTE: do not run this while in headless mode, eg on CI"
(with-redefs-fn {#'symreg/config->log-steps (fn [_ _] 500)}
(fn []
(let [control-process
(go
(<! (timeout 200))

(is (put! symreg/*sim-stop-start-chan*
{:new-state :start
:input-data-x [0 1 2 3 4]
:input-data-y [1 3 6 18 8]
:input-iters 200
:input-phenos-count 500}))

(<! (timeout 100))
(is (put! symreg/*sim-stop-start-chan*
{:new-state :pause}))
(<! (timeout 100))
(is (put! symreg/*sim-stop-start-chan*
{:new-state :start}))
(<! (timeout 100))
(is (put! symreg/*sim-stop-start-chan*
{:new-state :pause}))
(<! (timeout 100))

(is (put! symreg/*sim-stop-start-chan*
{:new-state :restart
:input-data-x [0 1 2 3 4]
:input-data-y [1 13 16 8 8]
:input-iters 1500
:input-phenos-count 500}))

(<! (timeout 100))

(is (put! symreg/*sim-stop-start-chan*
{:new-state :restart
:input-data-x [0 1 2 3 4]
:input-data-y [1 13 16 8 8]
:input-iters 5
:input-phenos-count 5}))

(<! (timeout 100))

(is (put! symreg/*sim-stop-start-chan*
{:new-state :restart
:input-data-x [0 1 2 3 4]
:input-data-y [11 3 6 18 8]
:input-iters 300
:input-phenos-count 400}))

(<! (timeout 100))

(is (put! symreg/*sim-stop-start-chan*
{:new-state :stop}))

(<! (timeout 100))

(is (put! symreg/*gui-close-chan* :close-please))
(is (put! symreg/*sim->gui-chan* :next))
true)]

(symreg/run-solver
{:initial-phenos (ops-init/initial-phenotypes 20)
:initial-muts (ops-init/initial-mutations)
:input-xs-exprs symreg/example-input-xs-exprs
:input-ys-exprs symreg/example-input-ys-exprs
:iters 20
:use-gui? true})


(is (= (<!! control-process) true)))))))))


(deftest derive-log-steps
Expand Down

0 comments on commit 307edd0

Please sign in to comment.