Skip to content

Commit

Permalink
Split Clojure integration tests from unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ilmotta committed Dec 26, 2023
1 parent 0b4a154 commit 4df972e
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 11 deletions.
56 changes: 49 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -335,26 +335,68 @@ shadow-server: export TARGET := clojure
shadow-server:##@ Start shadow-cljs in server mode for watching
yarn shadow-cljs server

test: export TARGET := clojure
test: export SHADOW_OUTPUT_TO := target/test/test.js
test: export SHADOW_NS_REGEXP := .*-test$$
test: ##@test Run all Clojure tests
yarn install
yarn shadow-cljs compile mocks && \
yarn shadow-cljs compile test && \
node --require ./test-resources/override.js target/test/test.js

test-watch: export TARGET := clojure
test-watch: ##@ Watch tests and re-run no changes to cljs files
test-watch: export SHADOW_OUTPUT_TO := target/test/test.js
test-watch: export SHADOW_NS_REGEXP := .*-test$$
test-watch: ##@test Watch all Clojure tests and re-run when files change
yarn install
nodemon --exec 'yarn shadow-cljs compile mocks && yarn shadow-cljs compile test && node --require ./test-resources/override.js target/test/test.js' -e cljs
yarn shadow-cljs compile mocks && \
nodemon --exec 'yarn shadow-cljs compile test && node --require ./test-resources/override.js target/test/test.js' -e cljs

test-watch-for-repl: export TARGET := clojure
test-watch-for-repl: ##@ Watch tests and support REPL connections
test-watch-for-repl: export SHADOW_OUTPUT_TO := target/test/test.js
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 compile mocks && yarn shadow-cljs watch test --verbose' \
'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
unit-test: export TARGET := clojure
unit-test: export SHADOW_OUTPUT_TO := target/unit_test/test.js
unit-test: export SHADOW_NS_REGEXP := ^(?!status-im\.integration-test).*-test$$
unit-test: ##@test Run unit tests
# Here we create the gyp bindings for nodejs
yarn install
yarn shadow-cljs compile mocks && \
yarn shadow-cljs compile test && \
node --require ./test-resources/override.js target/test/test.js
node --require ./test-resources/override.js target/unit_test/test.js

unit-test-watch: export TARGET := clojure
unit-test-watch: export SHADOW_OUTPUT_TO := target/unit_test/test.js
unit-test-watch: export SHADOW_NS_REGEXP := ^(?!status-im\.integration-test).*-test$$
unit-test-watch: ##@test Watch unit tests and re-run when files change
yarn install
yarn shadow-cljs compile mocks && \
nodemon --exec 'yarn shadow-cljs compile test && node --require ./test-resources/override.js target/unit_test/test.js' -e cljs

integration-test: export TARGET := clojure
integration-test: export SHADOW_OUTPUT_TO := target/integration_test/test.js
integration-test: export SHADOW_NS_REGEXP := ^status-im\.integration-test.*$$
integration-test: ##@test Run integration tests
# Here we create the gyp bindings for nodejs
yarn install
yarn shadow-cljs compile mocks && \
yarn shadow-cljs compile test && \
node --require ./test-resources/override.js target/integration_test/test.js

integration-test-watch: export TARGET := clojure
integration-test-watch: export SHADOW_OUTPUT_TO := target/integration_test/test.js
integration-test-watch: export SHADOW_NS_REGEXP := ^status-im\.integration-test.*$$
integration-test-watch: ##@test Watch integration tests and re-run when files change
yarn install
yarn shadow-cljs compile mocks && \
nodemon --exec 'yarn shadow-cljs compile test && node --require ./test-resources/override.js target/integration_test/test.js' -e cljs

android-test: jsbundle
android-test: export TARGET := android
Expand Down
12 changes: 10 additions & 2 deletions ci/Jenkinsfile.tests
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,19 @@ pipeline {
"""
}
}
stage('Tests') {
stage('Unit Tests') {
steps {
sh """#!/bin/bash
set -eo pipefail
make test 2>&1 | tee -a ${LOG_FILE}
make unit-test 2>&1 | tee -a ${LOG_FILE}
"""
}
}
stage('Integration Tests') {
steps {
sh """#!/bin/bash
set -eo pipefail
make integration-test 2>&1 | tee -a ${LOG_FILE}
"""
}
}
Expand Down
4 changes: 2 additions & 2 deletions shadow-cljs.edn
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@
;; produced by the target :mocks below and redefines node require
;; function to use the mocks instead of the rn libraries
:test
{:output-to "target/test/test.js"
{:output-to #shadow/env "SHADOW_OUTPUT_TO"
:output-dir "target/test"
:optimizations :simple
:target :node-test
:dev {:devtools {:preloads [status-im.setup.schema-preload]}}
;; 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
;; set :ui-driven to true to let shadow-cljs inject node-repl
:ui-driven true
Expand Down

0 comments on commit 4df972e

Please sign in to comment.