2020-01-23 07:46:07 -06:00
|
|
|
if ENABLE_CYPRESS
|
2020-02-13 05:57:37 -06:00
|
|
|
|
|
|
|
abs_dir = $(if $(filter $(abs_builddir),$(abs_srcdir)),.,$(abs_srcdir))
|
2020-02-21 12:53:52 -06:00
|
|
|
CYPRESS_BINARY = $(abs_builddir)/node_modules/cypress/bin/cypress
|
|
|
|
ESLINT_BINARY = $(abs_builddir)/node_modules/eslint/bin/eslint.js
|
|
|
|
WAIT_ON_BINARY = $(abs_builddir)/node_modules/wait-on/bin/wait-on
|
|
|
|
GET_PORT_BINARY = $(abs_builddir)/node_modules/get-port-cli/cli.js
|
2020-02-23 04:46:17 -06:00
|
|
|
NPM_INSTALLED = $(abs_builddir)/workdir/npm_installed
|
2020-02-21 11:27:15 -06:00
|
|
|
|
2020-02-23 05:08:36 -06:00
|
|
|
PID_FILE=$(abs_builddir)/workdir/loolwsd.pid
|
2020-03-02 10:15:38 -06:00
|
|
|
ERROR_LOG=$(abs_builddir)/workdir/error.log
|
2020-01-10 09:38:37 -06:00
|
|
|
|
2020-01-28 09:19:26 -06:00
|
|
|
DESKTOP_USER_AGENT = "cypress"
|
2020-02-21 12:53:52 -06:00
|
|
|
DESKTOP_TEST_FOLDER = $(abs_srcdir)/integration_tests/desktop
|
|
|
|
DESKTOP_DATA_FOLDER = $(abs_srcdir)/data/desktop/
|
|
|
|
DESKTOP_WORKDIR = $(abs_builddir)/workdir/desktop/
|
2020-02-20 15:01:27 -06:00
|
|
|
DESKTOP_TRACK_FOLDER=$(abs_builddir)/workdir/track/desktop
|
2020-01-15 07:55:03 -06:00
|
|
|
|
2020-03-12 09:55:56 -05:00
|
|
|
MOBILE_USER_AGENT = "cypress-mobile"
|
2020-02-21 12:53:52 -06:00
|
|
|
MOBILE_TEST_FOLDER = $(abs_srcdir)/integration_tests/mobile
|
|
|
|
MOBILE_DATA_FOLDER = $(abs_srcdir)/data/mobile/
|
|
|
|
MOBILE_WORKDIR = $(abs_builddir)/workdir/mobile/
|
2020-02-20 15:01:27 -06:00
|
|
|
MOBILE_TRACK_FOLDER=$(abs_builddir)/workdir/track/mobile
|
2020-01-10 09:38:37 -06:00
|
|
|
|
2020-02-19 21:15:58 -06:00
|
|
|
ALLOWED_PORTS = $(shell seq 9900 1 9980)
|
2020-02-20 03:03:42 -06:00
|
|
|
KILL_COMMAND=pkill -F $(PID_FILE) || pkill --signal SIGKILL -F $(PID_FILE)
|
2020-03-14 14:42:48 -05:00
|
|
|
PARALLEL_BUILD = $(findstring -j,$(MAKEFLAGS))
|
2020-02-25 06:09:31 -06:00
|
|
|
DISPLAY_NUMBER = 100
|
|
|
|
HEADLESS_BUILD := $(findstring Command failed,$(shell xhost > /dev/null 2>&1 || echo "Command failed, so we are in a headless environment."))
|
|
|
|
export DISPLAY=$(if $(HEADLESS_BUILD),:$(DISPLAY_NUMBER),$(shell echo $$DISPLAY))
|
2020-02-20 03:03:42 -06:00
|
|
|
|
2020-01-12 06:05:04 -06:00
|
|
|
if HAVE_LO_PATH
|
2020-02-20 15:01:27 -06:00
|
|
|
MOBILE_TEST_FILES= \
|
2020-03-10 07:26:04 -05:00
|
|
|
calc/apply_font_spec.js \
|
2020-03-09 09:08:33 -05:00
|
|
|
calc/focus_spec.js \
|
2020-03-09 11:49:56 -05:00
|
|
|
calc/insertion_wizard_spec.js \
|
2020-03-17 06:22:32 -05:00
|
|
|
calc/spellchecking_spec.js \
|
2020-02-20 15:01:27 -06:00
|
|
|
impress/impress_focus_spec.js \
|
|
|
|
writer/apply_font_spec.js \
|
|
|
|
writer/apply_paragraph_properties_spec.js \
|
|
|
|
writer/bottom_toolbar_spec.js \
|
|
|
|
writer/focus_spec.js \
|
|
|
|
writer/insert_field_spec.js \
|
|
|
|
writer/insert_formatting_mark_spec.js \
|
|
|
|
writer/insert_object_spec.js \
|
|
|
|
writer/mobile_wizard_state_spec.js \
|
|
|
|
writer/shape_properties_spec.js \
|
|
|
|
writer/spellchecking_spec.js \
|
|
|
|
writer/table_properties_spec.js \
|
|
|
|
writer/toolbar_spec.js
|
|
|
|
|
|
|
|
DEKSTOP_TEST_FILES= \
|
|
|
|
copy_paste_spec.js \
|
|
|
|
example_desktop_test_spec.js \
|
|
|
|
shape_operations_spec.js
|
|
|
|
|
|
|
|
MOBILE_TEST_FILES_DONE= \
|
|
|
|
$(foreach test_file,$(MOBILE_TEST_FILES),$(MOBILE_TRACK_FOLDER)/$(test_file).done)
|
|
|
|
|
|
|
|
DESKTOP_TEST_FILES_DONE= \
|
|
|
|
$(foreach test_file,$(DEKSTOP_TEST_FILES),$(DESKTOP_TRACK_FOLDER)/$(test_file).done)
|
|
|
|
|
2020-03-02 10:15:38 -06:00
|
|
|
check-local: do-check
|
2020-03-11 19:42:06 -05:00
|
|
|
$(if $(wildcard $(ERROR_LOG)),$(error CypressError: some tests failed!))
|
2020-03-02 10:15:38 -06:00
|
|
|
|
|
|
|
do-check: $(DESKTOP_TEST_FILES_DONE) $(MOBILE_TEST_FILES_DONE)
|
2020-02-20 15:01:27 -06:00
|
|
|
@$(KILL_COMMAND) || true
|
2020-02-25 06:09:31 -06:00
|
|
|
$(if $(HEADLESS_BUILD),@pkill Xvfb,)
|
2020-03-02 10:15:38 -06:00
|
|
|
$(if $(wildcard $(ERROR_LOG)),@cat $(ERROR_LOG))
|
2020-02-20 15:01:27 -06:00
|
|
|
|
|
|
|
$(PID_FILE): @JAILS_PATH@ $(NODE_BINS)
|
2020-03-02 10:15:38 -06:00
|
|
|
@rm -f $(ERROR_LOG)
|
2020-01-30 08:17:29 -06:00
|
|
|
$(call run_JS_error_check)
|
2020-02-25 06:09:31 -06:00
|
|
|
$(if $(HEADLESS_BUILD),$(call start_Xvfb),)
|
2020-01-14 12:37:17 -06:00
|
|
|
$(call start_loolwsd)
|
2020-02-20 15:01:27 -06:00
|
|
|
|
|
|
|
$(MOBILE_TEST_FILES_DONE): $(PID_FILE)
|
2020-02-28 07:37:56 -06:00
|
|
|
$(if $(PARALLEL_BUILD),\
|
2020-03-02 10:15:38 -06:00
|
|
|
$(call run_mobile_tests,$(subst $(MOBILE_TRACK_FOLDER)/,,$(basename $@)),$(basename $@).log),\
|
2020-02-28 07:37:56 -06:00
|
|
|
$(call run_mobile_tests))
|
|
|
|
$(if $(PARALLEL_BUILD),\
|
|
|
|
@mkdir -p $(dir $@) && touch $@\
|
|
|
|
,\
|
|
|
|
@$(foreach done_file,$(MOBILE_TEST_FILES_DONE),mkdir -p $(dir $(done_file)) && touch $(done_file) &&) true\
|
|
|
|
)
|
2020-02-20 15:01:27 -06:00
|
|
|
|
|
|
|
$(DESKTOP_TEST_FILES_DONE): $(PID_FILE)
|
2020-02-28 07:37:56 -06:00
|
|
|
$(if $(PARALLEL_BUILD),\
|
2020-03-02 10:15:38 -06:00
|
|
|
$(call run_desktop_tests,$(subst $(DESKTOP_TRACK_FOLDER)/,,$(basename $@)),$(basename $@).log),\
|
2020-02-28 07:37:56 -06:00
|
|
|
$(call run_desktop_tests))
|
|
|
|
$(if $(PARALLEL_BUILD),\
|
|
|
|
@mkdir -p $(dir $@) && touch $@\
|
|
|
|
,\
|
|
|
|
@$(foreach done_file,$(DESKTOP_TEST_FILES_DONE),mkdir -p $(dir $(done_file)) && touch $(done_file) &&) true\
|
|
|
|
)
|
2020-01-14 12:37:17 -06:00
|
|
|
|
2020-02-21 11:27:15 -06:00
|
|
|
check-desktop: @JAILS_PATH@ $(NODE_BINS)
|
2020-01-30 08:17:29 -06:00
|
|
|
$(call run_JS_error_check)
|
2020-01-14 12:37:17 -06:00
|
|
|
$(call start_loolwsd)
|
2020-01-15 07:55:03 -06:00
|
|
|
$(call run_desktop_tests,$(spec))
|
2020-02-20 03:03:42 -06:00
|
|
|
@$(KILL_COMMAND) || true
|
2020-01-14 12:37:17 -06:00
|
|
|
|
2020-02-21 11:27:15 -06:00
|
|
|
check-mobile: @JAILS_PATH@ $(NODE_BINS)
|
2020-01-30 08:17:29 -06:00
|
|
|
$(call run_JS_error_check)
|
2020-01-14 12:37:17 -06:00
|
|
|
$(call start_loolwsd)
|
2020-01-15 07:55:03 -06:00
|
|
|
$(call run_mobile_tests,$(spec))
|
2020-02-20 03:03:42 -06:00
|
|
|
@$(KILL_COMMAND) || true
|
2020-01-15 07:55:03 -06:00
|
|
|
|
2020-02-21 11:27:15 -06:00
|
|
|
run-desktop: @JAILS_PATH@ $(NODE_BINS)
|
2020-01-15 07:55:03 -06:00
|
|
|
$(call start_loolwsd)
|
|
|
|
@echo
|
|
|
|
@echo "Open cypress with desktop tests..."
|
|
|
|
@echo
|
2020-01-28 09:19:26 -06:00
|
|
|
$(CYPRESS_BINARY) open --config integrationFolder=$(DESKTOP_TEST_FOLDER),userAgent=$(DESKTOP_USER_AGENT) \
|
2020-02-19 19:25:01 -06:00
|
|
|
--env DATA_FOLDER=$(DESKTOP_DATA_FOLDER),WORKDIR=$(DESKTOP_WORKDIR),WSD_VERSION_HASH=$(LOOLWSD_VERSION_HASH),SERVER_PORT=$(FREE_PORT) \
|
2020-01-15 07:55:03 -06:00
|
|
|
|| true
|
2020-02-20 03:03:42 -06:00
|
|
|
@$(KILL_COMMAND) || true
|
2020-01-15 07:55:03 -06:00
|
|
|
|
2020-02-21 11:27:15 -06:00
|
|
|
run-mobile: @JAILS_PATH@ $(NODE_BINS)
|
2020-01-15 07:55:03 -06:00
|
|
|
$(call start_loolwsd)
|
|
|
|
@echo
|
|
|
|
@echo "Open cypress with mobile tests..."
|
|
|
|
@echo
|
|
|
|
$(CYPRESS_BINARY) open --config integrationFolder=$(MOBILE_TEST_FOLDER),userAgent=$(MOBILE_USER_AGENT) \
|
2020-02-19 19:25:01 -06:00
|
|
|
--env DATA_FOLDER=$(MOBILE_DATA_FOLDER),WORKDIR=$(MOBILE_WORKDIR),WSD_VERSION_HASH=$(LOOLWSD_VERSION_HASH),SERVER_PORT=$(FREE_PORT) \
|
2020-01-15 07:55:03 -06:00
|
|
|
|| true
|
2020-02-20 03:03:42 -06:00
|
|
|
@$(KILL_COMMAND) || true
|
2020-01-14 12:14:18 -06:00
|
|
|
|
2020-01-14 12:37:17 -06:00
|
|
|
define run_JS_error_check
|
2020-01-30 08:17:29 -06:00
|
|
|
@echo "Checking for JS errors in test code..."
|
|
|
|
@echo
|
2020-02-21 12:53:52 -06:00
|
|
|
@NODE_PATH=$(abs_dir)/node_modules $(NODE) $(ESLINT_BINARY) $(abs_srcdir) \
|
2020-01-14 12:37:17 -06:00
|
|
|
--ignore-path $(abs_srcdir)/.eslintignore --config $(abs_top_srcdir)/loleaflet/.eslintrc
|
2020-01-10 09:38:37 -06:00
|
|
|
@echo
|
2020-01-14 12:37:17 -06:00
|
|
|
endef
|
|
|
|
|
|
|
|
define start_loolwsd
|
2020-02-20 15:01:27 -06:00
|
|
|
$(eval FREE_PORT:=$(shell $(GET_PORT_BINARY) --host=127.0.0.1 $(ALLOWED_PORTS)))
|
2020-02-19 19:25:01 -06:00
|
|
|
@echo "Found available port for testing: $(FREE_PORT)"
|
|
|
|
@echo
|
|
|
|
@echo "Launching loolwsd..."
|
2020-01-10 09:38:37 -06:00
|
|
|
@fc-cache "@LO_PATH@"/share/fonts/truetype
|
|
|
|
@echo
|
|
|
|
../loolwsd --o:sys_template_path="@SYSTEMPLATE_PATH@" \
|
|
|
|
--o:child_root_path="@JAILS_PATH@" --o:storage.filesystem[@allow]=true \
|
2020-01-22 05:55:00 -06:00
|
|
|
--disable-ssl \
|
2020-01-10 09:38:37 -06:00
|
|
|
--o:admin_console.username=admin --o:admin_console.password=admin \
|
2020-02-20 15:01:27 -06:00
|
|
|
--o:logging.file[@enable]=true --o:logging.level=trace \
|
2020-02-19 21:35:08 -06:00
|
|
|
--port=$(FREE_PORT) \
|
2020-02-20 15:01:27 -06:00
|
|
|
--pidfile=$(PID_FILE) \
|
|
|
|
> /dev/null 2>&1 &
|
2020-02-21 11:27:15 -06:00
|
|
|
@$(WAIT_ON_BINARY) http://localhost:$(FREE_PORT) --timeout 60000
|
2020-01-10 09:38:37 -06:00
|
|
|
@echo
|
2020-01-14 12:37:17 -06:00
|
|
|
endef
|
|
|
|
|
2020-02-25 06:09:31 -06:00
|
|
|
#https://docs.cypress.io/guides/guides/continuous-integration.html#Xvfb
|
|
|
|
define start_Xvfb
|
|
|
|
@echo "Launching Xvfb..."
|
|
|
|
Xvfb :$(DISPLAY_NUMBER) &
|
2020-02-28 10:17:08 -06:00
|
|
|
while [ ! -f /tmp/.X$(DISPLAY_NUMBER)-lock ] ; do sleep 1; done
|
2020-02-25 06:09:31 -06:00
|
|
|
@echo
|
|
|
|
endef
|
|
|
|
|
2020-01-14 12:37:17 -06:00
|
|
|
define run_desktop_tests
|
2020-02-22 04:48:33 -06:00
|
|
|
@echo $(if $(1),"Running cypress desktop test: $(1)","Running cypress desktop tests...")
|
2020-01-14 12:37:17 -06:00
|
|
|
@echo
|
2020-02-22 04:48:33 -06:00
|
|
|
$(eval RUN_COMMAND = \
|
|
|
|
$(CYPRESS_BINARY) run --browser $(CHROME) \
|
2020-01-28 09:19:26 -06:00
|
|
|
--config integrationFolder=$(DESKTOP_TEST_FOLDER),userAgent=$(DESKTOP_USER_AGENT) \
|
2020-01-14 10:10:07 -06:00
|
|
|
--headless \
|
2020-02-19 19:25:01 -06:00
|
|
|
--env DATA_FOLDER=$(DESKTOP_DATA_FOLDER),WORKDIR=$(DESKTOP_WORKDIR),WSD_VERSION_HASH=$(LOOLWSD_VERSION_HASH),SERVER_PORT=$(FREE_PORT) \
|
2020-02-21 12:53:52 -06:00
|
|
|
$(if $(1), --spec=$(abs_dir)/integration_tests/desktop/$(1)) \
|
2020-03-02 10:15:38 -06:00
|
|
|
$(if $(PARALLEL_BUILD),,|| ($(KILL_COMMAND) && false)))
|
|
|
|
$(if $(PARALLEL_BUILD),\
|
|
|
|
$(call execute_run_parallel,$(RUN_COMMAND),$(2))\
|
|
|
|
,\
|
|
|
|
$(RUN_COMMAND)\
|
|
|
|
)
|
2020-01-14 12:37:17 -06:00
|
|
|
endef
|
|
|
|
|
|
|
|
define run_mobile_tests
|
2020-02-22 04:48:33 -06:00
|
|
|
@echo $(if $(1),"Running cypress mobile test: $(1)","Running cypress mobile tests...")
|
2020-01-10 09:38:37 -06:00
|
|
|
@echo
|
2020-02-22 04:48:33 -06:00
|
|
|
$(eval RUN_COMMAND = \
|
|
|
|
$(CYPRESS_BINARY) run --browser $(CHROME) \
|
2020-01-14 11:19:09 -06:00
|
|
|
--config integrationFolder=$(MOBILE_TEST_FOLDER),userAgent=$(MOBILE_USER_AGENT) \
|
2020-01-14 10:10:07 -06:00
|
|
|
--headless \
|
2020-02-19 19:25:01 -06:00
|
|
|
--env DATA_FOLDER=$(MOBILE_DATA_FOLDER),WORKDIR=$(MOBILE_WORKDIR),WSD_VERSION_HASH=$(LOOLWSD_VERSION_HASH),SERVER_PORT=$(FREE_PORT) \
|
2020-02-13 05:57:37 -06:00
|
|
|
$(if $(1), --spec=$(abs_dir)/integration_tests/mobile/$(1)) \
|
2020-03-02 10:15:38 -06:00
|
|
|
$(if $(PARALLEL_BUILD),,|| ($(KILL_COMMAND) && false)))
|
|
|
|
$(if $(PARALLEL_BUILD),\
|
|
|
|
$(call execute_run_parallel,$(RUN_COMMAND),$(2))\
|
|
|
|
,\
|
|
|
|
$(RUN_COMMAND)\
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define execute_run_parallel
|
|
|
|
@mkdir -p $(dir $(2)) && touch $(2) && \
|
|
|
|
echo "`echo $(1) && $(1)`" > $(2) 2>&1 && \
|
2020-03-18 16:05:36 -05:00
|
|
|
if [ -z `grep -o -m 1 "CypressError\|AssertionError\|Uncaught TypeError" $(2)` ];\
|
2020-03-10 07:49:21 -05:00
|
|
|
then cat $(2);\
|
|
|
|
else cat $(2) >> $(ERROR_LOG);\
|
2020-03-02 10:15:38 -06:00
|
|
|
fi;
|
2020-01-14 12:37:17 -06:00
|
|
|
endef
|
|
|
|
|
2020-02-21 11:27:15 -06:00
|
|
|
NODE_BINS = \
|
|
|
|
$(CYPRESS_BINARY) \
|
|
|
|
$(ESLINT_BINARY) \
|
|
|
|
$(WAIT_ON_BINARY) \
|
|
|
|
$(GET_PORT_BINARY)
|
|
|
|
|
2020-02-23 04:46:17 -06:00
|
|
|
$(NODE_BINS): $(NPM_INSTALLED);
|
|
|
|
|
2020-03-12 13:01:14 -05:00
|
|
|
$(NPM_INSTALLED): package.json
|
2020-01-15 08:27:30 -06:00
|
|
|
@npm install
|
2020-02-23 04:46:17 -06:00
|
|
|
@mkdir -p $(dir $(NPM_INSTALLED))
|
|
|
|
@touch $(NPM_INSTALLED)
|
2020-01-15 08:27:30 -06:00
|
|
|
|
2020-01-12 06:05:04 -06:00
|
|
|
endif
|
2020-01-10 09:38:37 -06:00
|
|
|
|
|
|
|
clean-local:
|
|
|
|
rm -rf node_modules
|
2020-01-14 11:08:51 -06:00
|
|
|
rm -rf workdir
|
2020-01-14 11:14:23 -06:00
|
|
|
rm -rf cypress
|
2020-01-14 11:19:09 -06:00
|
|
|
rm -rf package-lock.json
|
2020-01-23 07:46:07 -06:00
|
|
|
endif
|