cypress: add initial code coverage support.
It's not optimal now, beacuse it changes source files. Change-Id: I01cfb0be37eb0ef21dd1d606d9260b455a1cd585 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97036 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Tested-by: Jenkins Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>private/tml/ios-gen2
parent
5e4f9b4554
commit
9ac9bc8be4
|
@ -3,3 +3,5 @@ cypress
|
||||||
package-lock.json
|
package-lock.json
|
||||||
workdir
|
workdir
|
||||||
support/commands.js
|
support/commands.js
|
||||||
|
coverage
|
||||||
|
.nyc_output
|
||||||
|
|
|
@ -12,7 +12,8 @@ NPM_INSTALLED = $(abs_builddir)/workdir/npm_installed
|
||||||
PID_FILE=$(abs_builddir)/workdir/loolwsd.pid
|
PID_FILE=$(abs_builddir)/workdir/loolwsd.pid
|
||||||
ERROR_LOG=$(abs_builddir)/workdir/error.log
|
ERROR_LOG=$(abs_builddir)/workdir/error.log
|
||||||
|
|
||||||
SUPPORT_FILE = $(if $(findstring $(abs_srcdir),$(abs_builddir)),support/index.js,$(abs_srcdir)/support/index.js)
|
SUPPORT_FILE_ABS = $(abs_srcdir)/support/index.js
|
||||||
|
SUPPORT_FILE = $(if $(findstring $(abs_srcdir),$(abs_builddir)),support/index.js,$(SUPPORT_FILE_ABS))
|
||||||
|
|
||||||
DESKTOP_USER_AGENT = "cypress"
|
DESKTOP_USER_AGENT = "cypress"
|
||||||
DESKTOP_TEST_FOLDER = $(abs_srcdir)/integration_tests/desktop
|
DESKTOP_TEST_FOLDER = $(abs_srcdir)/integration_tests/desktop
|
||||||
|
@ -35,6 +36,8 @@ export DISPLAY=$(if $(HEADLESS_BUILD),:$(DISPLAY_NUMBER),$(shell echo $$DISPLAY)
|
||||||
|
|
||||||
CORE_VERSION := $(shell "@LO_PATH@"/program/soffice.bin --version 2> /dev/null)
|
CORE_VERSION := $(shell "@LO_PATH@"/program/soffice.bin --version 2> /dev/null)
|
||||||
|
|
||||||
|
COMMA :=,
|
||||||
|
|
||||||
if ENABLE_DEBUG
|
if ENABLE_DEBUG
|
||||||
FILTER_DEBUG=cypress:electron,cypress:launcher
|
FILTER_DEBUG=cypress:electron,cypress:launcher
|
||||||
export DEBUG=$(if $(ENABLE_LOGGING),$(FILTER_DEBUG),)
|
export DEBUG=$(if $(ENABLE_LOGGING),$(FILTER_DEBUG),)
|
||||||
|
@ -122,6 +125,24 @@ run-mobile: @JAILS_PATH@ $(NODE_BINS)
|
||||||
|| true
|
|| true
|
||||||
@$(KILL_COMMAND) || true
|
@$(KILL_COMMAND) || true
|
||||||
|
|
||||||
|
run-cov: @JAILS_PATH@ $(NODE_BINS)
|
||||||
|
@echo
|
||||||
|
@echo "Setup coverage tools..."
|
||||||
|
@echo
|
||||||
|
rm -rf .nyc_output
|
||||||
|
rm -rf coverage
|
||||||
|
npm install @cypress/code-coverage --no-save
|
||||||
|
@echo "import '@cypress/code-coverage/support';" >> $(SUPPORT_FILE_ABS)
|
||||||
|
@echo "" >> $(SUPPORT_FILE_ABS)
|
||||||
|
cd .. && npx nyc instrument --compact=false loleaflet/dist/src --in-place && cd cypress_test
|
||||||
|
@echo
|
||||||
|
@echo "Run all tests..."
|
||||||
|
@echo
|
||||||
|
$(call start_loolwsd)
|
||||||
|
$(call run_desktop_tests,,COVERAGE_RUN="1")
|
||||||
|
$(call run_mobile_tests,,COVERAGE_RUN="1")
|
||||||
|
@$(KILL_COMMAND) || true
|
||||||
|
|
||||||
define run_JS_error_check
|
define run_JS_error_check
|
||||||
@echo "Checking for JS errors in test code..."
|
@echo "Checking for JS errors in test code..."
|
||||||
@echo
|
@echo
|
||||||
|
@ -186,7 +207,7 @@ define run_desktop_tests
|
||||||
$(CYPRESS_BINARY) run \
|
$(CYPRESS_BINARY) run \
|
||||||
--browser $(CHROME) \
|
--browser $(CHROME) \
|
||||||
--headless \
|
--headless \
|
||||||
$(DESKTOP_CONFIG) \
|
$(DESKTOP_CONFIG)$(if $(2),$(COMMA)$(2),) \
|
||||||
$(if $(1), --spec=$(abs_dir)/integration_tests/desktop/$(1)) \
|
$(if $(1), --spec=$(abs_dir)/integration_tests/desktop/$(1)) \
|
||||||
$(if $(PARALLEL_BUILD),,|| ($(KILL_COMMAND) && false)))
|
$(if $(PARALLEL_BUILD),,|| ($(KILL_COMMAND) && false)))
|
||||||
$(if $(PARALLEL_BUILD),\
|
$(if $(PARALLEL_BUILD),\
|
||||||
|
@ -203,7 +224,7 @@ define run_mobile_tests
|
||||||
$(CYPRESS_BINARY) run \
|
$(CYPRESS_BINARY) run \
|
||||||
--browser $(CHROME) \
|
--browser $(CHROME) \
|
||||||
--headless \
|
--headless \
|
||||||
$(MOBILE_CONFIG) \
|
$(MOBILE_CONFIG)$(if $(2),$(COMMA)$(2),) \
|
||||||
$(if $(1), --spec=$(abs_dir)/integration_tests/mobile/$(1)) \
|
$(if $(1), --spec=$(abs_dir)/integration_tests/mobile/$(1)) \
|
||||||
$(if $(PARALLEL_BUILD),,|| ($(KILL_COMMAND) && false)))
|
$(if $(PARALLEL_BUILD),,|| ($(KILL_COMMAND) && false)))
|
||||||
$(if $(PARALLEL_BUILD),\
|
$(if $(PARALLEL_BUILD),\
|
||||||
|
@ -263,4 +284,6 @@ clean-local:
|
||||||
rm -rf workdir
|
rm -rf workdir
|
||||||
rm -rf cypress
|
rm -rf cypress
|
||||||
rm -rf package-lock.json
|
rm -rf package-lock.json
|
||||||
|
rm -rf .nyc_output
|
||||||
|
rm -rf coverage
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -128,3 +128,23 @@ is different from the source directory. So to avoid this
|
||||||
issue with the supportFile, you should build in the source
|
issue with the supportFile, you should build in the source
|
||||||
directory or you should avoid symlinks in the path of the
|
directory or you should avoid symlinks in the path of the
|
||||||
build directory.
|
build directory.
|
||||||
|
|
||||||
|
Code coverage
|
||||||
|
------------
|
||||||
|
|
||||||
|
We use nyc to instrument the code and then cypress code coverage
|
||||||
|
plugin is used to generate coverage numbers. This workflow
|
||||||
|
is called by the following command:
|
||||||
|
|
||||||
|
make run-cov
|
||||||
|
|
||||||
|
The output is put under cypress_test/covarage folder.
|
||||||
|
Open the cypress_test/covarage/lcov-report/index.html
|
||||||
|
file to get the summary report.
|
||||||
|
|
||||||
|
The make command above touches the source files under
|
||||||
|
loleaflet/dist/src folder, so after testing the coverage
|
||||||
|
doing a clean build is a good idea (e.g. make clean).
|
||||||
|
|
||||||
|
See also this link:
|
||||||
|
https://docs.cypress.io/guides/tooling/code-coverage.html
|
||||||
|
|
|
@ -6,6 +6,8 @@ var blacklists = require('./blacklists');
|
||||||
var selectTests = require('cypress-select-tests');
|
var selectTests = require('cypress-select-tests');
|
||||||
|
|
||||||
function plugin(on, config) {
|
function plugin(on, config) {
|
||||||
|
if (config.env.COVERAGE_RUN)
|
||||||
|
require('@cypress/code-coverage/task')(on, config);
|
||||||
on('task', {
|
on('task', {
|
||||||
copyFile: tasks.copyFile,
|
copyFile: tasks.copyFile,
|
||||||
failed: require('cypress-failed-log/src/failed')()
|
failed: require('cypress-failed-log/src/failed')()
|
||||||
|
|
Loading…
Reference in New Issue