Got site generation and tests working with advanced compilation

This commit is contained in:
Dan Holmsand 2014-11-29 23:26:42 +01:00
parent bc89612a76
commit 17375490fe
7 changed files with 43 additions and 74 deletions

View File

@ -25,7 +25,7 @@ runprod: clean
# production build with auto-rebuild and testing
runprodtest: clean
@$(MAKE) serve-site PROF=prod,test,$(PROF)
@$(MAKE) serve-site PROF=prod-test,$(PROF)
clean:
lein clean

View File

@ -28,7 +28,6 @@
:css-file "css/built.css"
:js-file "js/main.js"
:js-dir "js/out"
:default-title ""
:allow-html5-history false}))
(defonce page (atom "index.html"))
@ -78,7 +77,8 @@
(defn get-title []
(get-in @config [:page-titles @page]
(:default-title @config)))
(or (get-in @config [:page-titles "index.html"])
"")))
(defn default-content []
[:div "Empty"])

16
env/dev/devsetup.cljs vendored
View File

@ -1,16 +1,12 @@
(ns devsetup
(:require
[demo :as site]
[runtests]
[reagent.core :as r]
[figwheel.client :as fw :include-macros true]))
(defn test! []
(runtests/run-tests))
(:require [demo :as site]
[runtests]
[reagent.core :as r]
[figwheel.client :as fw :include-macros true]))
(defn on-update []
(r/force-update-all)
(test!))
(runtests/run-tests))
(when r/is-client
(fw/watch-and-reload
@ -19,4 +15,4 @@
(demo/start! {:test-results (fn []
[runtests/test-output-mini])})
(test!)
(runtests/run-tests)

View File

@ -1,8 +1,8 @@
(ns envsetup
(:require [mysite]))
(:require [demo :as site]
[reagent.core :as r]))
(mysite/start!)
(site/start! nil)
(when
(exists? js/runtests)
(js/runtests.main))
(when (exists? js/runtests)
(js/runtests.run-tests))

View File

@ -10,7 +10,20 @@
:resource-paths ["vendor"]
:source-paths ["src"]
:profiles {:dev-base {:dependencies
:profiles {:base {:cljsbuild {:builds
{:client
{:source-paths
["src"
"demo"
"examples/todomvc/src"
"examples/simple/src"
"examples/geometry/src"]}}}}
:test {:dependencies [[com.cemerick/clojurescript.test "0.3.1"]]
:cljsbuild {:builds
{:client {:source-paths ["test"]}}}}
:dev-base {:dependencies
[[figwheel "0.1.5-SNAPSHOT"]]
:plugins [[lein-figwheel "0.1.5-SNAPSHOT"]]
:resource-paths ["site" "outsite"]
@ -36,14 +49,11 @@
{:source-paths ["env/prod"]
:compiler {:optimizations :advanced
:elide-asserts true
:pseudo-names true
:output-dir "target/client"}}}}}]
:test {:dependencies [[com.cemerick/clojurescript.test "0.3.1"]]
:cljsbuild {:builds
{:client {:source-paths ["test"]}}}}
:dev [:dev-base :test]
:prod-test [:prod :test]}
:dev [:test :base :dev-base]
:prod-test [:test :prod]}
:clean-targets ^{:protect false} [:target-path :compile-path
"outsite/public/js"
@ -53,47 +63,8 @@
"out"]
:cljsbuild {:builds
{:client {:source-paths ["src"
"demo"
"examples/todomvc/src"
"examples/simple/src"
"examples/geometry/src"]
:compiler
{:client {:compiler
{:output-to "outsite/public/js/main.js"}}}}
:figwheel {:http-server-root "public" ;; assumes "resources"
:server-port 3449}
;-------------------
;; :profiles {:dev {:source-paths ["src" "demo"]}
;; :prod {:cljsbuild
;; {:builds
;; {:client {:compiler
;; {:optimizations :advanced
;; :elide-asserts true
;; :pretty-print false}}}}}
;; :test {:cljsbuild
;; {:builds
;; {:client {:source-paths ^:replace
;; ["test" "src" "demo"
;; "examples/todomvc/src"
;; "examples/simple/src"
;; "examples/geometry/src"]}}}}
;; :srcmap {:cljsbuild
;; {:builds
;; {:client
;; {:compiler
;; {:source-map "target/cljs-client.js.map"
;; :source-map-path "client"}}}}}}
;; :cljsbuild
;; {:builds
;; {:client {:source-paths ["src" "demo" "examples/todomvc/src"
;; "examples/simple/src"
;; "examples/geometry/src"]
;; :notify-command ["node" "./bin/gen-site.js"]
;; :compiler
;; {:output-dir "target/client"
;; :output-to "target/cljs-client.js"
;; :pretty-print true}}}}
)
:server-port 3449})

View File

@ -1,16 +1,18 @@
(ns runtests
(:require [reagent.core :as reagent :refer [atom]]
[reagent.interop :refer-macros [.' .!]]
[reagent.debug :refer-macros [dbg println]]
[demo :as demo]
[cemerick.cljs.test :as t]
(:require [demo]
[testreagent]
[testcursor]
[testinterop]
[testratom]))
[testratom]
[cemerick.cljs.test :as t]
[reagent.core :as reagent :refer [atom]]
[reagent.interop :refer-macros [.' .!]]
[reagent.debug :refer-macros [dbg println]]
;; [demo :as demo]
))
(enable-console-print!)
;; (enable-console-print!)
(def test-results (atom nil))
@ -57,7 +59,7 @@
(reset! test-results {:error e}))))
(println "-----------------------------------------"))
(defn run-tests []
(defn ^:export run-tests []
(if reagent/is-client
(do
(reset! test-results nil)