[Libreoffice-commits] online.git: cypress_test/Makefile.am cypress_test/run_parallel.sh

Tamás Zolnai (via logerrit) logerrit at kemper.freedesktop.org
Wed Jul 29 12:27:10 UTC 2020


 cypress_test/Makefile.am     |   53 ++++++++++++++++++++++++++-----------------
 cypress_test/run_parallel.sh |   14 +++++++++--
 2 files changed, 45 insertions(+), 22 deletions(-)

New commits:
commit fd6b984a3ccfd1b5cfe65439a54f70b980617bed
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Wed Jul 29 12:06:10 2020 +0200
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Wed Jul 29 14:26:51 2020 +0200

    cypress: introduce make check-multi command.
    
    To run multi-user tests only.
    - make check-multi runs all multi-user tests.
    - make check-multi spec=sidebar_visibility runs
    only the test pair with the specified name.
    
    Change-Id: Idada04960a6a2d33c7f36ef57bc1d6a1d1cffa99
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/99682
    Tested-by: Jenkins
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>

diff --git a/cypress_test/Makefile.am b/cypress_test/Makefile.am
index a3f153c20..303043ee5 100644
--- a/cypress_test/Makefile.am
+++ b/cypress_test/Makefile.am
@@ -62,10 +62,10 @@ MOBILE_TEST_FILES=$(subst $(MOBILE_TEST_FOLDER)/,,$(wildcard $(MOBILE_TEST_FOLDE
 
 DEKSTOP_TEST_FILES=$(subst $(DESKTOP_TEST_FOLDER)/,,$(wildcard $(DESKTOP_TEST_FOLDER)/*_spec.js) $(wildcard $(DESKTOP_TEST_FOLDER)/*/*_spec.js))
 
-MULTIUSER_TEST_FILES= \
-	paragraph_prop_user1_spec.js,paragraph_prop_user2_spec.js \
-	sidebar_visibility_user1_spec.js,sidebar_visibility_user2_spec.js \
-	simultaneous_typing_user1_spec.js,simultaneous_typing_user2_spec.js
+MULTIUSER_TESTS= \
+	paragraph_prop \
+	sidebar_visibility \
+	simultaneous_typing
 
 MOBILE_TEST_FILES_DONE= \
 	$(foreach test_file,$(MOBILE_TEST_FILES),$(MOBILE_TRACK_FOLDER)/$(test_file).done)
@@ -73,13 +73,13 @@ MOBILE_TEST_FILES_DONE= \
 DESKTOP_TEST_FILES_DONE= \
 	$(foreach test_file,$(DEKSTOP_TEST_FILES),$(DESKTOP_TRACK_FOLDER)/$(test_file).done)
 
-MULTIUSER_TEST_FILES_DONE= \
-	$(foreach test_file,$(subst $(COMMA),_,$(MULTIUSER_TEST_FILES)),$(MULTIUSER_TRACK_FOLDER)/$(test_file).done)
+MULTIUSER_TESTS_DONE= \
+	$(foreach test,$(MULTIUSER_TESTS),$(MULTIUSER_TRACK_FOLDER)/$(test).done)
 
 check-local: do-check
 	$(if $(wildcard $(ERROR_LOG)),$(error CypressError: some tests failed!))
 
-do-check: $(DESKTOP_TEST_FILES_DONE) $(MOBILE_TEST_FILES_DONE) $(MULTIUSER_TEST_FILES_DONE)
+do-check: $(DESKTOP_TEST_FILES_DONE) $(MOBILE_TEST_FILES_DONE) $(MULTIUSER_TESTS_DONE)
 	@$(KILL_COMMAND) || true
 	$(if $(HEADLESS_BUILD), at pkill Xvfb,)
 	$(if $(wildcard $(ERROR_LOG)), at cat $(ERROR_LOG))
@@ -110,13 +110,8 @@ $(DESKTOP_TEST_FILES_DONE): $(PID_FILE)
 		@$(foreach done_file,$(DESKTOP_TEST_FILES_DONE),mkdir -p $(dir $(done_file)) && touch $(done_file) &&) true\
 	)
 
-$(MULTIUSER_TEST_FILES_DONE): $(PID_FILE) $(MOBILE_TEST_FILES_DONE)
-	$(eval TEST_FILES=$(subst spec.js_,spec.js$(SPACE),$(notdir $@)))
-	$(eval USER1=$(dir $@)$(firstword $(TEST_FILES)))
-	$(eval USER2=$(basename $(dir $@)$(lastword $(TEST_FILES))))
-	$(call run_multiuser_tests,\
-		$(subst $(MULTIUSER_TRACK_FOLDER)/,,$(USER1)),$(USER1).log,\
-		$(subst $(MULTIUSER_TRACK_FOLDER)/,,$(USER2)),$(USER2).log)
+$(MULTIUSER_TESTS_DONE): $(PID_FILE) $(MOBILE_TEST_FILES_DONE)
+	$(call run_multiuser_test,$(subst $(MULTIUSER_TRACK_FOLDER)/,,$(basename $@)))
 	@mkdir -p $(dir $@) && touch $@
 
 check-desktop: @JAILS_PATH@ $(NODE_BINS)
@@ -131,6 +126,16 @@ check-mobile: @JAILS_PATH@ $(NODE_BINS)
 	$(call run_mobile_tests,$(spec))
 	@$(KILL_COMMAND) || true
 
+check-multi: @JAILS_PATH@ $(NODE_BINS)
+	@rm -f $(ERROR_LOG)
+	$(call run_JS_error_check)
+	$(call start_loolwsd)
+	$(if $(spec), \
+		$(call run_multiuser_test,$(spec)), \
+		$(call run_all_multiuser_tests))
+	@$(KILL_COMMAND) || true
+	$(if $(wildcard $(ERROR_LOG)), at cat $(ERROR_LOG))
+
 run-desktop: @JAILS_PATH@ $(NODE_BINS)
 	$(call run_JS_error_check)
 	$(call start_loolwsd)
@@ -293,23 +298,31 @@ define run_mobile_tests
 	)
 endef
 
-define run_multiuser_tests
-	@echo "Running cypress multi-user test: $(strip $(1)) - $(strip $(3))"
+define run_all_multiuser_tests
+	$(foreach test,$(MULTIUSER_TESTS),$(call run_multiuser_test,$(test)))
+endef
+
+define run_multiuser_test
+	$(eval USER1_SPEC=$(strip $(1))_user1_spec.js)
+	$(eval USER2_SPEC=$(strip $(1))_user2_spec.js)
+	$(eval USER1_LOG=$(MULTIUSER_TRACK_FOLDER)/$(USER1_SPEC).log)
+	$(eval USER2_LOG=$(MULTIUSER_TRACK_FOLDER)/$(USER2_SPEC).log)
+	@echo "Running cypress multi-user test: $(USER1_SPEC) - $(USER2_SPEC)"
 	@echo
 	@$(PARALLEL_SCRIPT) \
 		--browser $(CHROME) \
 		--config $(MULTIUSER_CONFIG) \
 		--env $(MULTIUSER_ENV) \
-		--spec $(1) \
+		--spec $(USER1_SPEC) \
 		--type multi-user \
-		--log-file $(2) & \
+		--log-file $(USER1_LOG) & \
 	$(PARALLEL_SCRIPT) \
 		--browser $(CHROME) \
 		--config $(MULTIUSER_CONFIG) \
 		--env $(MULTIUSER_ENV) \
-		--spec $(3) \
+		--spec $(USER2_SPEC) \
 		--type multi-user \
-		--log-file $(4) && \
+		--log-file $(USER2_LOG) && \
 	wait # waits the background process to be finished
 endef
 
diff --git a/cypress_test/run_parallel.sh b/cypress_test/run_parallel.sh
index 21f4e6c2a..0da1ea5c2 100755
--- a/cypress_test/run_parallel.sh
+++ b/cypress_test/run_parallel.sh
@@ -62,12 +62,22 @@ RUN_COMMAND="${CYPRESS_BINARY} run \
     --spec=${TEST_FILE_PATH}"
 
 print_error() {
+    SPEC=${TEST_FILE}
+    COMMAND=${TEST_TYPE}
+    if [ "${TEST_TYPE}" = "multi-user" ]; then
+        COMMAND="multi"
+        SPEC=${SPEC%"_user1_spec.js"}
+        SPEC=${SPEC%"_user2_spec.js"}
+    fi
     echo -e "\n\
     CypressError: a test failed, please do one of the following:\n\n\
     Run the failing test in headless mode:\n\
-    \tcd cypress_test && make check-${TEST_TYPE} spec=${TEST_FILE}\n\n\
+    \tcd cypress_test && make check-${COMMAND} spec=${SPEC}\n" >> ${ERROR_LOG}
+    if [ "${TEST_TYPE}" != "multi-user" ]; then
+    echo -e "\
     Open the failing test in the interactive test runner:\n\
-    \tcd cypress_test && make run-${TEST_TYPE} spec=${TEST_FILE}\n" >> ${ERROR_LOG}
+    \tcd cypress_test && make run-${COMMAND} spec=${SPEC}\n" >> ${ERROR_LOG}
+    fi
 }
 
 run_command() {


More information about the Libreoffice-commits mailing list