Make site and examples work with ClojureScript 2816

ClojureScript all of a sudden complains about "single segment
namespaces", which forces a rather massive reorg.

Also, cljs.test/run-tests is broken.
This commit is contained in:
Dan Holmsand 2015-02-10 14:18:56 +01:00
parent 4d559ef862
commit 163308a392
29 changed files with 88 additions and 77 deletions

View File

@ -3,7 +3,7 @@ var cljsLoad = require("./cljs-load");
var srcFile = "outsite/public/js/main.js";
var outputDirectory = "outsite/public/js/out/";
var moduleName = "devsetup";
var moduleName = "reagentdemo.dev";
var beep = "\u0007";
@ -16,7 +16,10 @@ if (typeof location === "undefined") {
var gensite = function () {
console.log("Loading " + srcFile);
var optNone = cljsLoad.load(srcFile, outputDirectory, moduleName);
sitetools.genpages({"opt-none": optNone});
if (typeof reagenttest != "undefined") {
reagenttest.runtests.run_tests();
}
sitetools.core.genpages({"opt-none": optNone});
}
var compileFail = function () {

View File

@ -1,8 +1,8 @@
(ns demo
(ns reagentdemo.core
(:require [reagent.core :as reagent :refer [atom]]
[reagent.interop :as i :refer-macros [.' .!]]
[clojure.string :as string]
[sitetools :as tools :refer [link]]
[sitetools.core :as tools :refer [link]]
[reagentdemo.common :as common :refer [demo-component]]
[reagentdemo.intro :as intro]
[reagentdemo.news :as news]

View File

@ -4,10 +4,10 @@
[reagent.debug :refer-macros [dbg println]]
[clojure.string :as string]
[reagentdemo.syntax :as s]
[sitetools :refer [link]]
[sitetools.core :refer [link]]
[reagentdemo.common :as common :refer [demo-component]]
[simpleexample :as simple]
[todomvc :as todo]))
[simpleexample.core :as simple]
[todomvc.core :as todo]))
(defn simple-component []
[:div
@ -307,7 +307,7 @@
[demo-component {:comp simple/simple-example
:complete true
:src (s/src-of nil "simpleexample.cljs")}]])
:src (s/src-of nil "simpleexample/core.cljs")}]])
(defn todomvc-demo []
[:div.demo-text
@ -319,7 +319,7 @@
[demo-component {:comp todo/todo-app
:complete true
:src (s/src-of nil "todomvc.cljs")}]])
:src (s/src-of nil "todomvc/core.cljs")}]])
(defn main []
(let [show-all (atom false)

View File

@ -3,7 +3,7 @@
[reagent.interop :refer-macros [.' .!]]
[reagent.debug :refer-macros [dbg println]]
[reagentdemo.syntax :as s]
[sitetools :as tools :refer [link]]
[sitetools.core :as tools :refer [link]]
[reagentdemo.common :as common :refer [demo-component]]
[geometry.core :as geometry]))

View File

@ -3,7 +3,7 @@
[reagent.interop :refer-macros [.' .!]]
[reagent.debug :refer-macros [dbg println]]
[reagentdemo.syntax :as s]
[sitetools :as tools :refer [link]]
[sitetools.core :as tools :refer [link]]
[reagentdemo.common :as common :refer [demo-component]]))
(def url "news/reagent-is-async.html")

View File

@ -3,7 +3,7 @@
[reagent.interop :refer-macros [.' .!]]
[reagent.debug :refer-macros [dbg]]
[reagentdemo.syntax :as s]
[sitetools :as tools :refer [link]]
[sitetools.core :as tools :refer [link]]
[reagentdemo.common :as common :refer [demo-component]]
[reagentdemo.news.binaryclock :as binaryclock]))

View File

@ -3,9 +3,8 @@
[reagent.interop :refer-macros [.' .!]]
[reagent.debug :refer-macros [dbg println]]
[reagentdemo.syntax :as s]
[sitetools :as tools :refer [link]]
[reagentdemo.common :as common :refer [demo-component]]
[todomvc :as todomvc]))
[sitetools.core :as tools :refer [link]]
[reagentdemo.common :as common :refer [demo-component]]))
(def url "news/news050.html")
(def title "News in 0.5.0-alpha")

View File

@ -3,9 +3,9 @@
[reagent.interop :refer-macros [.' .!]]
[reagent.debug :refer-macros [dbg println]]
[reagentdemo.syntax :as s]
[sitetools :as tools :refer [link]]
[sitetools.core :as tools :refer [link]]
[reagentdemo.common :as common :refer [demo-component]]
[todomvc :as todomvc]))
[todomvc.core :as todomvc]))
(def url "news/cloact-reagent-undo-demo.html")
(def title "Cloact becomes Reagent: Undo is trivial")

View File

@ -1,4 +1,4 @@
(ns sitetools
(ns sitetools.core
(:require [clojure.string :as string]
[goog.events :as evt]
[goog.history.EventType :as hevt]

View File

@ -1,6 +1,6 @@
(ns ^:figwheel-always devsetup
(:require [demo :as site]
[runtests]
(ns ^:figwheel-always reagentdemo.dev
(:require [reagentdemo.core :as demo]
[reagenttest.runtests :as runtests]
[reagent.core :as r]
[figwheel.client :as fw]))
@ -13,6 +13,7 @@
(defn start! []
(demo/start! {:test-results test-results})
(runtests/run-tests))
(when r/is-client
(runtests/run-tests)))
(start!)

View File

@ -1,12 +0,0 @@
(ns envsetup
(:require [demo :as site]
[reagent.core :as r]))
(site/start! nil)
(defn do-test []
(when (exists? js/runtests)
(js/runtests.run-tests)))
;; Wait for tests to be defined
(r/next-tick do-test)

13
env/prod/reagentdemo/prod.cljs vendored Normal file
View File

@ -0,0 +1,13 @@
(ns reagentdemo.prod
(:require [reagentdemo.core :as demo]
[reagent.core :as r]))
(demo/start! nil)
(defn do-test []
(when (and (exists? js/reagenttest))
(js/reagenttest.runtests.run-tests)))
;; Wait for tests to be defined
(when r/is-client
(r/next-tick do-test))

View File

@ -1,4 +1,4 @@
(ns devsetup
(ns geometry.dev
(:require [geometry.core :as example]
[figwheel.client :as fw]))

View File

@ -1,6 +1,6 @@
(defproject geometry-reagent "0.5.0-alpha3"
:dependencies [[org.clojure/clojure "1.6.0"]
[org.clojure/clojurescript "0.0-2760"]
[org.clojure/clojurescript "0.0-2816"]
[reagent "0.5.0-alpha3"]
[figwheel "0.2.3-SNAPSHOT"]]
@ -12,7 +12,7 @@
:profiles {:dev {:cljsbuild
{:builds {:client {:source-paths ["devsrc"]
:compiler
{:main devsetup
{:main geometry.dev
:optimizations :none
:source-map true
:source-map-timestamp true}}}}}

View File

@ -1,5 +1,5 @@
(ns devsetup
(:require [todomvc :as example]
(ns simpleexample.dev
(:require [simpleexample.core :as example]
[figwheel.client :as fw]))
(fw/start {:on-jsload example/run

View File

@ -11,7 +11,7 @@
</div>
<script src="target/client.js"></script>
<script>
simpleexample.run();
simpleexample.core.run();
</script>
</body>
</html>

View File

@ -1,7 +1,7 @@
(defproject simple-reagent "0.5.0-alpha3"
:dependencies [[org.clojure/clojure "1.6.0"]
[org.clojure/clojurescript "0.0-2760"]
[org.clojure/clojurescript "0.0-2816"]
[reagent "0.5.0-alpha3"]
[figwheel "0.2.3-SNAPSHOT"]]
@ -13,7 +13,7 @@
:profiles {:dev {:cljsbuild
{:builds {:client {:source-paths ["devsrc"]
:compiler
{:main devsetup
{:main simpleexample.dev
:optimizations :none
:source-map true
:source-map-timestamp true}}}}}

View File

@ -1,4 +1,4 @@
(ns simpleexample
(ns simpleexample.core
(:require [reagent.core :as reagent :refer [atom]]))
(defonce timer (atom (js/Date.)))

View File

@ -1,5 +1,5 @@
(ns devsetup
(:require [simpleexample :as example]
(ns todomvc.dev
(:require [todomvc.core :as example]
[figwheel.client :as fw]))
(fw/start {:on-jsload example/run

View File

@ -11,7 +11,7 @@
</div>
<script src="target/client.js"></script>
<script>
todomvc.run();
todomvc.core.run();
</script>
</body>
</html>

View File

@ -1,6 +1,6 @@
(defproject todomvc-reagent "0.5.0-alpha3"
:dependencies [[org.clojure/clojure "1.6.0"]
[org.clojure/clojurescript "0.0-2760"]
[org.clojure/clojurescript "0.0-2816"]
[reagent "0.5.0-alpha3"]
[figwheel "0.2.3-SNAPSHOT"]]
@ -12,7 +12,7 @@
:profiles {:dev {:cljsbuild
{:builds {:client {:source-paths ["devsrc"]
:compiler
{:main devsetup
{:main todomvc.dev
:optimizations :none
:source-map true
:source-map-timestamp true}}}}}

View File

@ -1,4 +1,4 @@
(ns todomvc
(ns todomvc.core
(:require [reagent.core :as reagent :refer [atom]]))
(defonce todos (atom (sorted-map)))

View File

@ -1,11 +1,10 @@
(defproject reagent "0.5.0-SNAPSHOT"
:url "http://github.com/reagent-project/reagent"
:license {:name "MIT"}
:description "A simple ClojureScript interface to React"
:dependencies [[org.clojure/clojure "1.6.0"]
[org.clojure/clojurescript "0.0-2760"]
[org.clojure/clojurescript "0.0-2816"]
[cljsjs/react "0.12.2-5"]]
:plugins [[lein-cljsbuild "1.0.4"]]
@ -24,7 +23,7 @@
{:builds
{:client
{:source-paths ["env/dev"]
:compiler {:main "devsetup"
:compiler {:main "reagentdemo.dev"
:source-map true
:source-map-timestamp true
:optimizations :none
@ -41,7 +40,7 @@
{:cljsbuild
{:builds {:client
{:source-paths ["env/prod"]
:compiler {:main "prodsetup"
:compiler {:main "reagentdemo.prod"
:optimizations :advanced
:elide-asserts true
:pretty-print false
@ -54,6 +53,7 @@
"outsite/public/js"
"outsite/public/site"
"outsite/public/news"
"outsite/public/css"
"outsite/public/index.html"
"out"]

View File

@ -1,26 +1,32 @@
(ns runtests
(:require [testreagent]
[testcursor]
[testinterop]
[testratom]
[testwrap]
(ns reagenttest.runtests
(:require [reagenttest.testreagent]
[reagenttest.testcursor]
[reagenttest.testinterop]
[reagenttest.testratom]
[reagenttest.testwrap]
[cljs.test :as test :include-macros true]
[reagent.core :as reagent :refer [atom]]
[reagent.interop :refer-macros [.' .!]]
[reagent.debug :refer-macros [dbg println]]))
(defn all-tests []
(test/run-tests 'testreagent
'testcursor
'testinterop
'testratom
'testwrap))
[reagent.debug :refer-macros [dbg log]]))
(enable-console-print!)
(defn all-tests []
(test/run-tests 'reagenttest.testreagent
'reagenttest.testcursor
'reagenttest.testinterop
'reagenttest.testratom
'reagenttest.testwrap))
(def test-results (atom nil))
(defmethod test/report [::test/default :summary] [m]
;; ClojureScript 2814 doesn't return anything from run-tests
(reset! test-results m)
(println "\nRan" (:test m) "tests containing"
(+ (:pass m) (:fail m) (:error m)) "assertions.")
(println (:fail m) "failures," (:error m) "errors."))
(def test-box {:position 'absolute
:margin-left -35
:color :#aaa})
@ -46,14 +52,15 @@
[:div {:style test-box} "testing"])))
(defn ^:export run-all-tests []
(println "-----------------------------------------")
(log "-----------------------------------------")
(try
(reset! test-results (all-tests))
(reset! test-results nil)
(all-tests)
(catch js/Object e
(do
(println "Testrun failed\n" e "\n" (.-stack e))
(log "Testrun failed\n" e "\n" (.-stack e))
(reset! test-results {:error e}))))
(println "-----------------------------------------"))
(log "-----------------------------------------"))
(defn ^:export run-tests []
(if reagent/is-client

View File

@ -1,4 +1,4 @@
(ns testcursor
(ns reagenttest.testcursor
(:require [cljs.test :as t :refer-macros [is deftest testing]]
[reagent.ratom :as rv :refer-macros [run! reaction]]
[reagent.debug :refer-macros [dbg]]

View File

@ -1,4 +1,4 @@
(ns testinterop
(ns reagenttest.testinterop
(:require [cljs.test :as t :refer-macros [is deftest]]
[reagent.debug :refer-macros [dbg]]
[reagent.interop :refer-macros [.' .!]]))

View File

@ -1,4 +1,4 @@
(ns testratom
(ns reagenttest.testratom
(:require [cljs.test :as t :refer-macros [is deftest testing]]
[reagent.ratom :as rv :refer-macros [run! reaction]]
[reagent.debug :refer-macros [dbg]]

View File

@ -1,4 +1,4 @@
(ns testreagent
(ns reagenttest.testreagent
(:require [cljs.test :as t :refer-macros [is deftest testing]]
[reagent.ratom :as rv :refer-macros [reaction]]
[reagent.debug :refer-macros [dbg println log]]

View File

@ -1,4 +1,4 @@
(ns testwrap
(ns reagenttest.testwrap
(:require [cljs.test :as t :refer-macros [is deftest]]
[reagent.debug :refer-macros [dbg println log]]
[reagent.core :as r :refer [atom wrap]]))