mirror of
https://github.com/status-im/reagent.git
synced 2025-02-09 18:43:39 +00:00
commit
28aaf6e467
68
circle.yml
68
circle.yml
@ -7,28 +7,67 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
key: reagent-{{ checksum "project.clj" }}
|
keys:
|
||||||
|
- lein-v1-{{ checksum "project.clj" }}
|
||||||
|
- lein-v1
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
key: reagent-npm-{{ checksum "package.json" }}
|
keys:
|
||||||
|
- npm-v1-{{ checksum "package.json" }}
|
||||||
|
- npm-v1
|
||||||
- run: sudo npm install -g karma-cli
|
- run: sudo npm install -g karma-cli
|
||||||
- run: npm install
|
- run: npm install
|
||||||
- run: ./run-tests.sh
|
- run: ./run-tests.sh lein
|
||||||
- save_cache:
|
- save_cache:
|
||||||
paths:
|
paths:
|
||||||
- ~/.m2
|
- ~/.m2
|
||||||
- ~/.lein
|
- ~/.lein
|
||||||
- ~/.cljs/.aot_cache
|
- ~/.cljs/.aot_cache
|
||||||
key: reagent-{{ checksum "project.clj" }}
|
key: lein-v1-{{ checksum "project.clj" }}
|
||||||
- save_cache:
|
- save_cache:
|
||||||
paths:
|
paths:
|
||||||
- node_modules
|
- node_modules
|
||||||
key: reagent-npm-{{ checksum "package.json" }}
|
key: npm-v1-{{ checksum "package.json" }}
|
||||||
- store_artifacts:
|
- store_artifacts:
|
||||||
path: coverage
|
path: coverage
|
||||||
- run: bash <(curl -s https://codecov.io/bash)
|
- run: bash <(curl -s https://codecov.io/bash)
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
NPM_CONFIG_LOGLEVEL: warn
|
NPM_CONFIG_LOGLEVEL: warn
|
||||||
|
|
||||||
|
test-clj:
|
||||||
|
working_directory: ~/work
|
||||||
|
docker:
|
||||||
|
- image: circleci/clojure:tools-deps-1.9.0.397-node-browsers
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- restore_cache:
|
||||||
|
keys:
|
||||||
|
- clj-v1-{{ checksum "deps.edn" }}
|
||||||
|
- clj-v1
|
||||||
|
- restore_cache:
|
||||||
|
keys:
|
||||||
|
- npm-v1-{{ checksum "package.json" }}
|
||||||
|
- vpm-v1
|
||||||
|
- run: sudo npm install -g karma-cli
|
||||||
|
- run: npm install
|
||||||
|
- run: ./run-tests.sh clj
|
||||||
|
- save_cache:
|
||||||
|
paths:
|
||||||
|
- ~/.m2
|
||||||
|
- ~/.lein
|
||||||
|
- ~/.cljs/.aot_cache
|
||||||
|
key: clj-v1-{{ checksum "deps.edn" }}
|
||||||
|
- save_cache:
|
||||||
|
paths:
|
||||||
|
- node_modules
|
||||||
|
key: npm-v1-{{ checksum "package.json" }}
|
||||||
|
- store_artifacts:
|
||||||
|
path: coverage
|
||||||
|
- run: bash <(curl -s https://codecov.io/bash)
|
||||||
|
|
||||||
|
environment:
|
||||||
|
NPM_CONFIG_LOGLEVEL: warn
|
||||||
|
|
||||||
update-site:
|
update-site:
|
||||||
working_directory: ~/work
|
working_directory: ~/work
|
||||||
docker:
|
docker:
|
||||||
@ -37,12 +76,17 @@ jobs:
|
|||||||
- checkout
|
- checkout
|
||||||
- add_ssh_keys
|
- add_ssh_keys
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
key: reagent-{{ checksum "project.clj" }}
|
keys:
|
||||||
|
- lein-v1-{{ checksum "project.clj" }}
|
||||||
|
- lein-v1
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
key: reagent-npm-{{ checksum "package.json" }}
|
keys:
|
||||||
|
- npm-v1-{{ checksum "package.json" }}
|
||||||
|
- npm-v1
|
||||||
- run: npm install
|
- run: npm install
|
||||||
- deploy:
|
- deploy:
|
||||||
command: ./build-example-site.sh
|
command: ./build-example-site.sh
|
||||||
|
|
||||||
update-tagged-docs:
|
update-tagged-docs:
|
||||||
working_directory: ~/work
|
working_directory: ~/work
|
||||||
docker:
|
docker:
|
||||||
@ -51,7 +95,9 @@ jobs:
|
|||||||
- checkout
|
- checkout
|
||||||
- add_ssh_keys
|
- add_ssh_keys
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
key: reagent-{{ checksum "project.clj" }}
|
keys:
|
||||||
|
- lein-v1-{{ checksum "project.clj" }}
|
||||||
|
- lein-v1
|
||||||
- deploy:
|
- deploy:
|
||||||
command: ./build-docs.sh
|
command: ./build-docs.sh
|
||||||
workflows:
|
workflows:
|
||||||
@ -62,9 +108,14 @@ workflows:
|
|||||||
filters:
|
filters:
|
||||||
tags:
|
tags:
|
||||||
only: /v.*/
|
only: /v.*/
|
||||||
|
- test-clj:
|
||||||
|
filters:
|
||||||
|
tags:
|
||||||
|
only: /v.*/
|
||||||
- update-site:
|
- update-site:
|
||||||
requires:
|
requires:
|
||||||
- test
|
- test
|
||||||
|
- test-clj
|
||||||
filters:
|
filters:
|
||||||
branches:
|
branches:
|
||||||
only:
|
only:
|
||||||
@ -72,6 +123,7 @@ workflows:
|
|||||||
- update-tagged-docs:
|
- update-tagged-docs:
|
||||||
requires:
|
requires:
|
||||||
- test
|
- test
|
||||||
|
- test-clj
|
||||||
filters:
|
filters:
|
||||||
branches:
|
branches:
|
||||||
ignore:
|
ignore:
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
(:require [reagentdemo.core :as core]
|
(:require [reagentdemo.core :as core]
|
||||||
[reagenttest.runtests :as tests]))
|
[reagenttest.runtests :as tests]))
|
||||||
|
|
||||||
|
(enable-console-print!)
|
||||||
|
|
||||||
(defn init! []
|
(defn init! []
|
||||||
(core/init! (tests/init!)))
|
(core/init! (tests/init!)))
|
||||||
|
|
||||||
|
@ -6,8 +6,6 @@
|
|||||||
(:import goog.History
|
(:import goog.History
|
||||||
[goog.history Html5History EventType]))
|
[goog.history Html5History EventType]))
|
||||||
|
|
||||||
(enable-console-print!)
|
|
||||||
|
|
||||||
;;; Configuration
|
;;; Configuration
|
||||||
|
|
||||||
(declare main-content)
|
(declare main-content)
|
||||||
|
5
deps.edn
Normal file
5
deps.edn
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{:paths ["src" "test" "examples/todomvc/src" "examples/simple/src" "examples/geometry/src" "demo"]
|
||||||
|
:deps {org.clojure/clojurescript {:git/url "https://github.com/clojure/clojurescript.git"
|
||||||
|
:sha "f95a13b3e3b193749e10e15d95ef98506ce3be29"}
|
||||||
|
; org.clojure/clojurescript {:local/root "/home/juho/Source/clojurescript"}
|
||||||
|
doo {:mvn/version "0.1.11"}}}
|
3558
package-lock.json
generated
3558
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -17,7 +17,10 @@
|
|||||||
"karma-coverage": "https://github.com/karma-runner/karma-coverage.git#55aeead0934a39efbd9db0b575d416ab44cd8a12",
|
"karma-coverage": "https://github.com/karma-runner/karma-coverage.git#55aeead0934a39efbd9db0b575d416ab44cd8a12",
|
||||||
"karma-junit-reporter": "2.0.1",
|
"karma-junit-reporter": "2.0.1",
|
||||||
"karma-sourcemap-loader": "^0.3.7",
|
"karma-sourcemap-loader": "^0.3.7",
|
||||||
|
"karma-webpack": "4.0.2",
|
||||||
"md5-file": "4.0.0",
|
"md5-file": "4.0.0",
|
||||||
"shadow-cljs": "2.8.93"
|
"shadow-cljs": "2.8.93",
|
||||||
|
"webpack": "^4.42.1",
|
||||||
|
"webpack-cli": "^3.3.11"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
15
run-tests.sh
15
run-tests.sh
@ -12,8 +12,23 @@ EXIT=0
|
|||||||
|
|
||||||
SUMMARY="$blue##\n## SUMMARY\n##$reset\n\n"
|
SUMMARY="$blue##\n## SUMMARY\n##$reset\n\n"
|
||||||
|
|
||||||
|
TOOL=$1
|
||||||
|
|
||||||
for env in test-environments/*; do
|
for env in test-environments/*; do
|
||||||
name=$(basename "$env")
|
name=$(basename "$env")
|
||||||
|
|
||||||
|
if [[ -n $TOOL ]]; then
|
||||||
|
if [[ $name == bundle* ]]; then
|
||||||
|
if [[ $TOOL != 'clj' ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [[ $TOOL != 'lein' ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
echo -e "$blue##"
|
echo -e "$blue##"
|
||||||
echo -e "## TESTING $name"
|
echo -e "## TESTING $name"
|
||||||
echo -e "##$reset"
|
echo -e "##$reset"
|
||||||
|
10
test-environments/bundle-adv/README.md
Normal file
10
test-environments/bundle-adv/README.md
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# Advanced optimized JS bundle
|
||||||
|
|
||||||
|
- `tesh.sh`
|
||||||
|
- Creates `karma.js` bundle using `karma.edn`, including the test suite.
|
||||||
|
- Runs Karma with `karma.config.js`.
|
||||||
|
- `build.sh`
|
||||||
|
- Creates `index.js` bundle which contains the demo site, without test suite.
|
||||||
|
- Runs Webpack and copies static files to target folder.
|
||||||
|
- The bundles share the ClojureScript compiler output-dir, so need to
|
||||||
|
compile everything twice.
|
8
test-environments/bundle-adv/build.edn
Normal file
8
test-environments/bundle-adv/build.edn
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{:main reagentdemo.prod
|
||||||
|
:optimizations :advanced
|
||||||
|
:output-to "target/bundle-adv/resources/public/js/out/index.js"
|
||||||
|
:output-dir "target/bundle-adv/resources/public/js/out"
|
||||||
|
; :pseudo-names true
|
||||||
|
:elide-asserts true
|
||||||
|
:target :bundle
|
||||||
|
:closure-defines {cljs.core/*global* "window"}}
|
5
test-environments/bundle-adv/build.sh
Executable file
5
test-environments/bundle-adv/build.sh
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -ex
|
||||||
|
clj -m cljs.main -co test-environments/bundle-adv/build.edn -v --compile
|
||||||
|
npx webpack --config=test-environments/bundle-adv/webpack.config.js
|
||||||
|
cp -r site/public/index.html site/public/css target/bundle-adv/resources/public/
|
20
test-environments/bundle-adv/karma.conf.js
Normal file
20
test-environments/bundle-adv/karma.conf.js
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
module.exports = function (config) {
|
||||||
|
config.set({
|
||||||
|
browsers: ['ChromeHeadless'],
|
||||||
|
basePath: '../../target/bundle-adv/resources/public/',
|
||||||
|
files: ['js/out/karma.js'],
|
||||||
|
frameworks: ['cljs-test'],
|
||||||
|
preprocessors: {
|
||||||
|
'js/out/karma.js': ['webpack', 'sourcemap']
|
||||||
|
},
|
||||||
|
colors: true,
|
||||||
|
logLevel: config.LOG_INFO,
|
||||||
|
client: {
|
||||||
|
args: ['reagenttest.runtests.karma_tests'],
|
||||||
|
},
|
||||||
|
singleRun: true,
|
||||||
|
webpack: {
|
||||||
|
mode: 'production'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
8
test-environments/bundle-adv/karma.edn
Normal file
8
test-environments/bundle-adv/karma.edn
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{:main reagenttest.runtests
|
||||||
|
:optimizations :advanced
|
||||||
|
:output-to "target/bundle-adv/resources/public/js/out/karma.js"
|
||||||
|
:output-dir "target/bundle-adv/resources/public/js/out"
|
||||||
|
; :pseudo-names true
|
||||||
|
:elide-asserts true
|
||||||
|
:target :bundle
|
||||||
|
:closure-defines {cljs.core/*global* "window"}}
|
4
test-environments/bundle-adv/test.sh
Executable file
4
test-environments/bundle-adv/test.sh
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -ex
|
||||||
|
clojure -m cljs.main -co test-environments/bundle-adv/karma.edn -v --compile
|
||||||
|
npx karma start test-environments/bundle-adv/karma.conf.js
|
8
test-environments/bundle-adv/webpack.config.js
Normal file
8
test-environments/bundle-adv/webpack.config.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
module.exports = {
|
||||||
|
mode: 'production',
|
||||||
|
entry: './target/bundle-adv/resources/public/js/out/index.js',
|
||||||
|
output: {
|
||||||
|
path: __dirname + "/../../target/bundle-adv/resources/public/js/",
|
||||||
|
filename: 'main.js'
|
||||||
|
}
|
||||||
|
};
|
8
test-environments/bundle/build.edn
Normal file
8
test-environments/bundle/build.edn
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{:main reagenttest.runtests
|
||||||
|
:output-to "target/bundle/resources/public/js/out/index.js"
|
||||||
|
:output-dir "target/bundle/resources/public/js/out"
|
||||||
|
:asset-path "js/out"
|
||||||
|
:target :bundle
|
||||||
|
; :bundle-cmd {:none ["npx" "webpack" "--mode=development"]
|
||||||
|
; :default ["npx" "webpack"]}
|
||||||
|
}
|
33
test-environments/bundle/karma.conf.js
Normal file
33
test-environments/bundle/karma.conf.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
module.exports = function (config) {
|
||||||
|
config.set({
|
||||||
|
browsers: ['ChromeHeadless'],
|
||||||
|
basePath: '../../target/bundle/resources/public/',
|
||||||
|
files: [
|
||||||
|
// Karma will try running test adapter before all
|
||||||
|
// files loaded by Cljs are ready.
|
||||||
|
'../../../../test-environments/bundle/workaround.js',
|
||||||
|
'js/out/index.js',
|
||||||
|
{pattern: 'js/out/**/*.js', included: false},
|
||||||
|
// Source maps
|
||||||
|
{pattern: 'js/out/**/*.cljs', included: false},
|
||||||
|
{pattern: 'js/out/**/*.js.map', included: false}
|
||||||
|
],
|
||||||
|
frameworks: ['cljs-test'],
|
||||||
|
preprocessors: {
|
||||||
|
'js/out/index.js': ['webpack', 'sourcemap']
|
||||||
|
},
|
||||||
|
// Cljs asset-path
|
||||||
|
proxies: {
|
||||||
|
'/js/out/': '/base/js/out/'
|
||||||
|
},
|
||||||
|
colors: true,
|
||||||
|
logLevel: config.LOG_INFO,
|
||||||
|
client: {
|
||||||
|
args: ['reagenttest.runtests.karma_tests'],
|
||||||
|
},
|
||||||
|
singleRun: true,
|
||||||
|
webpack: {
|
||||||
|
mode: 'development'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
4
test-environments/bundle/test.sh
Executable file
4
test-environments/bundle/test.sh
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -ex
|
||||||
|
clojure -m cljs.main -co test-environments/bundle/build.edn --compile
|
||||||
|
npx karma start test-environments/bundle/karma.conf.js
|
8
test-environments/bundle/webpack.config.js
Normal file
8
test-environments/bundle/webpack.config.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
module.exports = {
|
||||||
|
mode: 'development',
|
||||||
|
entry: './target/bundle/resources/public/js/out/index.js',
|
||||||
|
output: {
|
||||||
|
path: __dirname + "/target/bundle/resources/public/js/",
|
||||||
|
filename: 'main.js'
|
||||||
|
}
|
||||||
|
};
|
4
test-environments/bundle/workaround.js
Normal file
4
test-environments/bundle/workaround.js
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
window.__karma__.loaded_real = window.__karma__.loaded;
|
||||||
|
window.__karma__.loaded = function() {
|
||||||
|
|
||||||
|
};
|
@ -10,6 +10,7 @@
|
|||||||
[reagent.impl.util-test]
|
[reagent.impl.util-test]
|
||||||
[clojure.test :as test]
|
[clojure.test :as test]
|
||||||
[doo.runner :as doo :include-macros true]
|
[doo.runner :as doo :include-macros true]
|
||||||
|
[jx.reporter.karma :as karma]
|
||||||
[reagent.core :as r]))
|
[reagent.core :as r]))
|
||||||
|
|
||||||
(enable-console-print!)
|
(enable-console-print!)
|
||||||
@ -55,4 +56,12 @@
|
|||||||
(run-tests)
|
(run-tests)
|
||||||
[#'test-output-mini]))
|
[#'test-output-mini]))
|
||||||
|
|
||||||
|
;; Macro which sets *main-cli-fn*
|
||||||
(doo/doo-all-tests #"(reagenttest\.test.*|reagent\..*-test)")
|
(doo/doo-all-tests #"(reagenttest\.test.*|reagent\..*-test)")
|
||||||
|
|
||||||
|
(defn ^:export karma-tests [karma]
|
||||||
|
(karma/run-all-tests karma #"(reagenttest\.test.*|reagent\..*-test)"))
|
||||||
|
|
||||||
|
(when (exists? js/window)
|
||||||
|
(when-let [f (some-> js/window .-__karma__ .-loaded_real)]
|
||||||
|
(.loaded_real (.-__karma__ js/window))))
|
||||||
|
@ -1086,9 +1086,9 @@
|
|||||||
(is (re-find #"Something went wrong\." (.-innerHTML div)))
|
(is (re-find #"Something went wrong\." (.-innerHTML div)))
|
||||||
(if (dev?)
|
(if (dev?)
|
||||||
(is (re-find #"\n in reagenttest.testreagent.comp1 \(created by reagenttest.testreagent.comp2\)\n in reagenttest.testreagent.comp2 \(created by reagent[0-9]+\)\n in reagent[0-9]+ \(created by reagenttest.testreagent.error_boundary\)\n in reagenttest.testreagent.error_boundary"
|
(is (re-find #"\n in reagenttest.testreagent.comp1 \(created by reagenttest.testreagent.comp2\)\n in reagenttest.testreagent.comp2 \(created by reagent[0-9]+\)\n in reagent[0-9]+ \(created by reagenttest.testreagent.error_boundary\)\n in reagenttest.testreagent.error_boundary"
|
||||||
(.-componentStack @info)))
|
(.-componentStack ^js @info)))
|
||||||
(is (re-find #"\n in .+\n in .+\n in reagent[0-9]+\n in .+"
|
(is (re-find #"\n in .+\n in .+\n in reagent[0-9]+\n in .+"
|
||||||
(.-componentStack @info))) ))))))))
|
(.-componentStack ^js @info))) ))))))))
|
||||||
|
|
||||||
(deftest test-dom-node
|
(deftest test-dom-node
|
||||||
(let [node (atom nil)
|
(let [node (atom nil)
|
||||||
@ -1236,7 +1236,9 @@
|
|||||||
(is (= "<div><div>hello</div><div>world</div><div>foo</div><div>1</div><div>2</div></div>"
|
(is (= "<div><div>hello</div><div>world</div><div>foo</div><div>1</div><div>2</div></div>"
|
||||||
(as-string [comp]))))))
|
(as-string [comp]))))))
|
||||||
|
|
||||||
(defonce my-context (react/createContext "default"))
|
;; In bundle version, the names aren't optimized.
|
||||||
|
;; In node module processed versions, names probably are optimized.
|
||||||
|
(defonce my-context ^js/MyContext (react/createContext "default"))
|
||||||
|
|
||||||
(def Provider (.-Provider my-context))
|
(def Provider (.-Provider my-context))
|
||||||
(def Consumer (.-Consumer my-context))
|
(def Consumer (.-Consumer my-context))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user