Run integration tests separately from unit tests (#18304)
- make test still exists, so if you have been using it, as well as make test-watch, they should all work exactly the same. - [Changed] As part of the check stage, Jenkins will run Lint and Unit Tests in parallel. Integration Tests run later because running them at the same time as Unit Tests caused errors. - [Added] "make unit-test" and "make unit-test-watch" run unit tests only. Watching all unit tests is faster now because we ignore integration tests and we only compile shadow-cljs :mock target once. We are at approximately 10-15s to re-run all unit tests after saving a watched file, depending on your hardware. If you change mocks.js_dependencies.cljs, you must re-run the make target. - [Added] "make integration-test" and "make integration-test-watch" run integration tests only. These are much slower than the unit tests. Fixes https://github.com/status-im/status-mobile/issues/18112
This commit is contained in:
parent
9c62e63035
commit
b4640dabb9
54
Makefile
54
Makefile
|
@ -335,26 +335,44 @@ shadow-server: export TARGET := clojure
|
||||||
shadow-server:##@ Start shadow-cljs in server mode for watching
|
shadow-server:##@ Start shadow-cljs in server mode for watching
|
||||||
yarn shadow-cljs server
|
yarn shadow-cljs server
|
||||||
|
|
||||||
test-watch: export TARGET := clojure
|
_test-clojure: export TARGET := clojure
|
||||||
test-watch: ##@ Watch tests and re-run no changes to cljs files
|
_test-clojure: export WATCH ?= false
|
||||||
yarn install
|
_test-clojure:
|
||||||
nodemon --exec 'yarn shadow-cljs compile mocks && yarn shadow-cljs compile test && node --require ./test-resources/override.js target/test/test.js' -e cljs
|
ifeq ($(WATCH), true)
|
||||||
|
yarn install && \
|
||||||
test-watch-for-repl: export TARGET := clojure
|
yarn shadow-cljs compile mocks && \
|
||||||
test-watch-for-repl: ##@ Watch tests and support REPL connections
|
nodemon --exec "yarn shadow-cljs compile test && node --require ./test-resources/override.js $$SHADOW_OUTPUT_TO" -e cljs
|
||||||
yarn install
|
else
|
||||||
rm -f target/test/test.js
|
yarn install && \
|
||||||
concurrently --kill-others --prefix-colors 'auto' --names 'build,repl' \
|
|
||||||
'yarn shadow-cljs compile mocks && yarn shadow-cljs watch test --verbose' \
|
|
||||||
'until [ -f ./target/test/test.js ] ; do sleep 1 ; done ; node --require ./test-resources/override.js ./target/test/test.js --repl'
|
|
||||||
|
|
||||||
test: export TARGET := clojure
|
|
||||||
test: ##@test Run tests once in NodeJS
|
|
||||||
# Here we create the gyp bindings for nodejs
|
|
||||||
yarn install
|
|
||||||
yarn shadow-cljs compile mocks && \
|
yarn shadow-cljs compile mocks && \
|
||||||
yarn shadow-cljs compile test && \
|
yarn shadow-cljs compile test && \
|
||||||
node --require ./test-resources/override.js target/test/test.js
|
node --require ./test-resources/override.js "$$SHADOW_OUTPUT_TO"
|
||||||
|
endif
|
||||||
|
|
||||||
|
test: export SHADOW_OUTPUT_TO := target/test/test.js
|
||||||
|
test: export SHADOW_NS_REGEXP := .*-test$$
|
||||||
|
test: ##@test Run all Clojure tests
|
||||||
|
test: _test-clojure
|
||||||
|
|
||||||
|
test-watch-for-repl: export SHADOW_OUTPUT_TO := target/test/test.js
|
||||||
|
test-watch-for-repl: export SHADOW_NS_REGEXP := .*-test$$
|
||||||
|
test-watch-for-repl: ##@test Watch all Clojure tests and support REPL connections
|
||||||
|
yarn install
|
||||||
|
rm -f target/test/test.js
|
||||||
|
yarn shadow-cljs compile mocks && \
|
||||||
|
concurrently --kill-others --prefix-colors 'auto' --names 'build,repl' \
|
||||||
|
'yarn shadow-cljs watch test --verbose' \
|
||||||
|
"until [ -f $$SHADOW_OUTPUT_TO ] ; do sleep 1 ; done ; node --require ./test-resources/override.js $$SHADOW_OUTPUT_TO --repl"
|
||||||
|
|
||||||
|
test-unit: export SHADOW_OUTPUT_TO := target/unit_test/test.js
|
||||||
|
test-unit: export SHADOW_NS_REGEXP := ^(?!status-im\.integration-test).*-test$$
|
||||||
|
test-unit: ##@test Run unit tests
|
||||||
|
test-unit: _test-clojure
|
||||||
|
|
||||||
|
test-integration: export SHADOW_OUTPUT_TO := target/integration_test/test.js
|
||||||
|
test-integration: export SHADOW_NS_REGEXP := ^status-im\.integration-test.*$$
|
||||||
|
test-integration: ##@test Run integration tests
|
||||||
|
test-integration: _test-clojure
|
||||||
|
|
||||||
android-test: jsbundle
|
android-test: jsbundle
|
||||||
android-test: export TARGET := android
|
android-test: export TARGET := android
|
||||||
|
|
|
@ -52,16 +52,24 @@ pipeline {
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Tests') {
|
stage('Unit Tests') {
|
||||||
steps {
|
steps {
|
||||||
sh """#!/bin/bash
|
sh """#!/bin/bash
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
make test 2>&1 | tee -a ${LOG_FILE}
|
make test-unit 2>&1 | tee -a ${LOG_FILE}
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
stage('Integration Tests') {
|
||||||
|
steps {
|
||||||
|
sh """#!/bin/bash
|
||||||
|
set -eo pipefail
|
||||||
|
make test-integration 2>&1 | tee -a ${LOG_FILE}
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
stage('Component Tests') {
|
stage('Component Tests') {
|
||||||
steps {
|
steps {
|
||||||
sh """#!/bin/bash
|
sh """#!/bin/bash
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
To run tests:
|
To run tests:
|
||||||
|
|
||||||
```
|
```
|
||||||
make test
|
make test
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,10 +13,10 @@ To run tests:
|
||||||
Also test watcher can be launched. It will re-run the entire test suite when any file is modified
|
Also test watcher can be launched. It will re-run the entire test suite when any file is modified
|
||||||
|
|
||||||
```
|
```
|
||||||
make test-watch
|
make test WATCH=true
|
||||||
```
|
```
|
||||||
|
|
||||||
Developers can also manually change the shadow-cljs option `:ns-regex` to control which namespaces the test runner should pick.
|
Developers can also manually change the shadow-cljs option `:ns-regex` to control which namespaces the test runner should pick.
|
||||||
|
|
||||||
## Testing with REPL
|
## Testing with REPL
|
||||||
|
|
||||||
|
|
|
@ -108,13 +108,13 @@
|
||||||
;; produced by the target :mocks below and redefines node require
|
;; produced by the target :mocks below and redefines node require
|
||||||
;; function to use the mocks instead of the rn libraries
|
;; function to use the mocks instead of the rn libraries
|
||||||
:test
|
:test
|
||||||
{:output-to "target/test/test.js"
|
{:output-to #shadow/env "SHADOW_OUTPUT_TO"
|
||||||
:output-dir "target/test"
|
:output-dir "target/test"
|
||||||
:optimizations :simple
|
:optimizations :simple
|
||||||
:target :node-test
|
:target :node-test
|
||||||
:dev {:devtools {:preloads [status-im.setup.schema-preload]}}
|
:dev {:devtools {:preloads [status-im.setup.schema-preload]}}
|
||||||
;; Uncomment line below to `make test-watch` a specific file
|
;; Uncomment line below to `make test-watch` a specific file
|
||||||
;; :ns-regexp "status-im.subs.messages-test$"
|
:ns-regexp #shadow/env "SHADOW_NS_REGEXP"
|
||||||
:main legacy.status-im.test-runner/main
|
:main legacy.status-im.test-runner/main
|
||||||
;; set :ui-driven to true to let shadow-cljs inject node-repl
|
;; set :ui-driven to true to let shadow-cljs inject node-repl
|
||||||
:ui-driven true
|
:ui-driven true
|
||||||
|
|
Loading…
Reference in New Issue