From e1f537282d01796a80c717f805dffa10fe9b7d94 Mon Sep 17 00:00:00 2001 From: Darcy Shen Date: Thu, 19 Oct 2023 16:26:56 +0800 Subject: [PATCH] [51_5] Run Scheme Tests in CI --- .github/workflows/ci-xmake-archlinux.yml | 5 +- .github/workflows/ci-xmake-macos.yml | 4 +- .github/workflows/ci-xmake-mingw.yml | 2 + .github/workflows/ci-xmake-ubuntu.yml | 2 + .github/workflows/ci-xmake-windows.yml | 2 + .../code/progs}/prog-format-test.scm | 0 .../code/progs}/tm-convert-test.scm | 0 TeXmacs/progs/check/check-master.scm | 18 --- TeXmacs/progs/init-code.scm | 6 +- TeXmacs/progs/init-draw.scm | 6 +- TeXmacs/progs/init-research.scm | 66 +++++----- TeXmacs/progs/init-tm2html.scm | 6 +- .../gui/{menu-test.scm => menu-demo.scm} | 2 +- ...logic-test.scm => logic-test-disabled.scm} | 0 .../{old-gui-test.scm => old-gui-demo.scm} | 2 +- .../{regexp-test.scm => regexp-demo.scm} | 0 xmake.lua | 87 ++----------- xmake/tests.lua | 117 ++++++++++++++++++ 18 files changed, 179 insertions(+), 146 deletions(-) rename TeXmacs/{progs/prog => plugins/code/progs}/prog-format-test.scm (100%) rename TeXmacs/{progs/kernel/texmacs => plugins/code/progs}/tm-convert-test.scm (100%) rename TeXmacs/progs/kernel/gui/{menu-test.scm => menu-demo.scm} (99%) rename TeXmacs/progs/kernel/logic/{logic-test.scm => logic-test-disabled.scm} (100%) rename TeXmacs/progs/kernel/old-gui/{old-gui-test.scm => old-gui-demo.scm} (99%) rename TeXmacs/progs/kernel/regexp/{regexp-test.scm => regexp-demo.scm} (100%) create mode 100644 xmake/tests.lua diff --git a/.github/workflows/ci-xmake-archlinux.yml b/.github/workflows/ci-xmake-archlinux.yml index 49fb2e9b1f..1cdb7fd442 100644 --- a/.github/workflows/ci-xmake-archlinux.yml +++ b/.github/workflows/ci-xmake-archlinux.yml @@ -66,8 +66,11 @@ jobs: - name: Build run: xmake build --yes -vD research && xmake build --yes -vD --group=tests - - name: test + - name: C++ tests run: xmake run --yes -vD --group=tests + - name: Scheme tests + run: xmake run --yes -vD --group=scheme_tests + - name: integration test run: xmake run --yes -vD --group=integration_tests \ No newline at end of file diff --git a/.github/workflows/ci-xmake-macos.yml b/.github/workflows/ci-xmake-macos.yml index 827a94147e..ccac6b63f3 100644 --- a/.github/workflows/ci-xmake-macos.yml +++ b/.github/workflows/ci-xmake-macos.yml @@ -74,10 +74,12 @@ jobs: run: xmake config --policies=build.ccache -o ${{ runner.workspace }}/build -m releasedbg --yes - name: build run: xmake build --yes -vD research && xmake build --yes -vD --group=tests - - name: test + - name: C++ tests run: xmake run --yes --verbose --diagnosis --group=tests env: QT_QPA_PLATFORM: offscreen + - name: Scheme tests + run: xmake run --yes -vD --group=scheme_tests - name: integration test run: xmake run --yes -vD --group=integration_tests env: diff --git a/.github/workflows/ci-xmake-mingw.yml b/.github/workflows/ci-xmake-mingw.yml index 5c0a9f5bf4..e45f42cdd5 100644 --- a/.github/workflows/ci-xmake-mingw.yml +++ b/.github/workflows/ci-xmake-mingw.yml @@ -48,6 +48,8 @@ jobs: - name: install run: | xmake install research + - name: Scheme tests + run: xmake run --yes -vD --group=scheme_tests - name: integration test in scheme run: xmake run --yes -vD --group=integration_tests env: diff --git a/.github/workflows/ci-xmake-ubuntu.yml b/.github/workflows/ci-xmake-ubuntu.yml index ab8754bc8f..72d6653713 100644 --- a/.github/workflows/ci-xmake-ubuntu.yml +++ b/.github/workflows/ci-xmake-ubuntu.yml @@ -87,6 +87,8 @@ jobs: env: QT_QPA_PLATFORM: offscreen INSTALL_DIR: ${{ runner.workspace }}/build/packages/app.mogan/ + - name: Scheme tests + run: xmake run --yes -vD --group=scheme_tests - name: integration test run: xmake run --yes -vD --group=integration_tests env: diff --git a/.github/workflows/ci-xmake-windows.yml b/.github/workflows/ci-xmake-windows.yml index 378df0506e..8d0ea15df4 100644 --- a/.github/workflows/ci-xmake-windows.yml +++ b/.github/workflows/ci-xmake-windows.yml @@ -66,6 +66,8 @@ jobs: - name: install run: | xmake install research + - name: Scheme tests + run: xmake run --yes -vD --group=scheme_tests - name: integration test in scheme run: xmake run --yes -vD --group=integration_tests env: diff --git a/TeXmacs/progs/prog/prog-format-test.scm b/TeXmacs/plugins/code/progs/prog-format-test.scm similarity index 100% rename from TeXmacs/progs/prog/prog-format-test.scm rename to TeXmacs/plugins/code/progs/prog-format-test.scm diff --git a/TeXmacs/progs/kernel/texmacs/tm-convert-test.scm b/TeXmacs/plugins/code/progs/tm-convert-test.scm similarity index 100% rename from TeXmacs/progs/kernel/texmacs/tm-convert-test.scm rename to TeXmacs/plugins/code/progs/tm-convert-test.scm diff --git a/TeXmacs/progs/check/check-master.scm b/TeXmacs/progs/check/check-master.scm index fb25116352..82dd26e65c 100644 --- a/TeXmacs/progs/check/check-master.scm +++ b/TeXmacs/progs/check/check-master.scm @@ -85,21 +85,3 @@ (tm-define (run-checks) (check-latex-export "$TEXMACS_CHECKS/latex-export")) - -(tm-define (run-all-tests) - (regtest-htmltm) - (regtest-xmltm) - (regtest-tmlength) - (regtest-environment) - (regtest-mathtm) - (regtest-tmhtml) - (regtest-tmmltm) - (regtest-prog-format) - (regtest-tm-define) - (regtest-tm-modes) - (regtest-tm-dialogue) - (regtest-fonts) - (regtest-tm-tools) - (regtest-graphics-group) - (regtest-cite-sort) -) diff --git a/TeXmacs/progs/init-code.scm b/TeXmacs/progs/init-code.scm index 7ee3bc6dc1..20b8272ae5 100755 --- a/TeXmacs/progs/init-code.scm +++ b/TeXmacs/progs/init-code.scm @@ -80,11 +80,9 @@ (inherit-modules (kernel gui gui-markup) (kernel gui menu-define) (kernel gui menu-widget) (kernel gui kbd-define) (kernel gui kbd-handlers) - (kernel gui menu-test) (kernel old-gui old-gui-widget) (kernel old-gui old-gui-factory) - (kernel old-gui old-gui-form) - (kernel old-gui old-gui-test)) + (kernel old-gui old-gui-form)) ;;(display* "time: " (- (texmacs-time) boot-start) "\n") ;;(display* "memory: " (texmacs-memory) " bytes\n") @@ -432,7 +430,7 @@ ;;(display* "memory: " (texmacs-memory) " bytes\n") ;;(display "Booting regression testing\n") -(lazy-define (check check-master) check-all run-checks run-all-tests) +(lazy-define (check check-master) check-all run-checks) ;;(display* "time: " (- (texmacs-time) boot-start) "\n") ;;(display* "memory: " (texmacs-memory) " bytes\n") diff --git a/TeXmacs/progs/init-draw.scm b/TeXmacs/progs/init-draw.scm index 7826e27d7f..9034d9a2e9 100755 --- a/TeXmacs/progs/init-draw.scm +++ b/TeXmacs/progs/init-draw.scm @@ -79,11 +79,9 @@ (inherit-modules (kernel gui gui-markup) (kernel gui menu-define) (kernel gui menu-widget) (kernel gui kbd-define) (kernel gui kbd-handlers) - (kernel gui menu-test) (kernel old-gui old-gui-widget) (kernel old-gui old-gui-factory) - (kernel old-gui old-gui-form) - (kernel old-gui old-gui-test)) + (kernel old-gui old-gui-form)) ;;(display* "time: " (- (texmacs-time) boot-start) "\n") ;;(display* "memory: " (texmacs-memory) " bytes\n") @@ -452,7 +450,7 @@ ;;(display* "memory: " (texmacs-memory) " bytes\n") ;;(display "Booting regression testing\n") -(lazy-define (check check-master) check-all run-checks run-all-tests) +(lazy-define (check check-master) check-all run-checks) ;;(display* "time: " (- (texmacs-time) boot-start) "\n") ;;(display* "memory: " (texmacs-memory) " bytes\n") diff --git a/TeXmacs/progs/init-research.scm b/TeXmacs/progs/init-research.scm index 18b947d19c..2da3e62469 100644 --- a/TeXmacs/progs/init-research.scm +++ b/TeXmacs/progs/init-research.scm @@ -45,20 +45,20 @@ ) -(let () - (display "Benchmark 1\n") - (define start (texmacs-time)) - (define (fib n) (if (< n 2) n (+ (fib (- n 1)) (fib (- n 2))))) - (display (fib 30)) - (newline) - (display "Time: ") (display (- (texmacs-time) start)) (newline) -) +;; (let () +;; (display "Benchmark 1\n") +;; (define start (texmacs-time)) +;; (define (fib n) (if (< n 2) n (+ (fib (- n 1)) (fib (- n 2))))) +;; (display (fib 30)) +;; (newline) +;; (display "Time: ") (display (- (texmacs-time) start)) (newline) +;; ) (define developer-mode? #f) (define boot-start (texmacs-time)) (define remote-client-list (list)) -(display "Booting TeXmacs kernel functionality\n") +;; (display "Booting TeXmacs kernel functionality\n") (load (url-concretize "$TEXMACS_PATH/progs/kernel/boot/boot-s7.scm")) (inherit-modules (kernel boot compat-s7) (kernel boot abbrevs) @@ -79,11 +79,9 @@ (inherit-modules (kernel gui gui-markup) (kernel gui menu-define) (kernel gui menu-widget) (kernel gui kbd-define) (kernel gui kbd-handlers) - (kernel gui menu-test) (kernel old-gui old-gui-widget) (kernel old-gui old-gui-factory) - (kernel old-gui old-gui-form) - (kernel old-gui old-gui-test)) + (kernel old-gui old-gui-form)) ;;(display* "time: " (- (texmacs-time) boot-start) "\n") ;;(display* "memory: " (texmacs-memory) " bytes\n") @@ -452,7 +450,7 @@ ;;(display* "memory: " (texmacs-memory) " bytes\n") ;;(display "Booting regression testing\n") -(lazy-define (check check-master) check-all run-checks run-all-tests) +(lazy-define (check check-master) check-all run-checks) ;;(display* "time: " (- (texmacs-time) boot-start) "\n") ;;(display* "memory: " (texmacs-memory) " bytes\n") @@ -460,32 +458,32 @@ (when (use-plugin-updater?) (use-modules (utils misc updater)) (delayed (:idle 2000) (updater-initialize))) -(display* "time: " (- (texmacs-time) boot-start) "\n") -(display* "memory: " (texmacs-memory) " bytes\n") +;; (display* "time: " (- (texmacs-time) boot-start) "\n") +;; (display* "memory: " (texmacs-memory) " bytes\n") -(display "------------------------------------------------------\n") +;; (display "------------------------------------------------------\n") (delayed (:idle 10000) (autosave-delayed)) (texmacs-banner) -(display "Initialization done\n") - -(let () - (display "------------------------------------------------------\n") - (display "Benchmark 2\n") - (define start (texmacs-time)) - (tm-define (tm-fib n) (if (< n 2) n (+ (tm-fib (- n 1)) (tm-fib (- n 2))))) - (display (tm-fib 30)) - (newline) - (display "Time: ") (display (- (texmacs-time) start)) (newline) - (display "------------------------------------------------------\n") -) - -(display "------------------------------------------------------\n") -(display "Forcing delayed loads\n") +;; (display "Initialization done\n") + +;; (let () +;; (display "------------------------------------------------------\n") +;; (display "Benchmark 2\n") +;; (define start (texmacs-time)) +;; (tm-define (tm-fib n) (if (< n 2) n (+ (tm-fib (- n 1)) (tm-fib (- n 2))))) +;; (display (tm-fib 30)) +;; (newline) +;; (display "Time: ") (display (- (texmacs-time) start)) (newline) +;; (display "------------------------------------------------------\n") +;; ) + +;; (display "------------------------------------------------------\n") +;; (display "Forcing delayed loads\n") (lazy-keyboard-force #t) -(display* "time: " (- (texmacs-time) boot-start) "\n") -(display* "memory: " (texmacs-memory) " bytes\n") -(display "------------------------------------------------------\n") +;; (display* "time: " (- (texmacs-time) boot-start) "\n") +;; (display* "memory: " (texmacs-memory) " bytes\n") +;; (display "------------------------------------------------------\n") diff --git a/TeXmacs/progs/init-tm2html.scm b/TeXmacs/progs/init-tm2html.scm index 30eda3e38b..88d1323bd9 100755 --- a/TeXmacs/progs/init-tm2html.scm +++ b/TeXmacs/progs/init-tm2html.scm @@ -79,11 +79,9 @@ (inherit-modules (kernel gui gui-markup) (kernel gui menu-define) (kernel gui menu-widget) (kernel gui kbd-define) (kernel gui kbd-handlers) - (kernel gui menu-test) (kernel old-gui old-gui-widget) (kernel old-gui old-gui-factory) - (kernel old-gui old-gui-form) - (kernel old-gui old-gui-test)) + (kernel old-gui old-gui-form)) ;;(display* "time: " (- (texmacs-time) boot-start) "\n") ;;(display* "memory: " (texmacs-memory) " bytes\n") @@ -431,7 +429,7 @@ ;;(display* "memory: " (texmacs-memory) " bytes\n") ;;(display "Booting regression testing\n") -(lazy-define (check check-master) check-all run-checks run-all-tests) +(lazy-define (check check-master) check-all run-checks) ;;(display* "time: " (- (texmacs-time) boot-start) "\n") ;;(display* "memory: " (texmacs-memory) " bytes\n") diff --git a/TeXmacs/progs/kernel/gui/menu-test.scm b/TeXmacs/progs/kernel/gui/menu-demo.scm similarity index 99% rename from TeXmacs/progs/kernel/gui/menu-test.scm rename to TeXmacs/progs/kernel/gui/menu-demo.scm index 06f5203c1e..b1599eb61d 100644 --- a/TeXmacs/progs/kernel/gui/menu-test.scm +++ b/TeXmacs/progs/kernel/gui/menu-demo.scm @@ -1,7 +1,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; -;; MODULE : menu-test.scm +;; MODULE : menu-demo.scm ;; DESCRIPTION : some test widgets ;; COPYRIGHT : (C) 2012 Joris van der Hoeven ;; diff --git a/TeXmacs/progs/kernel/logic/logic-test.scm b/TeXmacs/progs/kernel/logic/logic-test-disabled.scm similarity index 100% rename from TeXmacs/progs/kernel/logic/logic-test.scm rename to TeXmacs/progs/kernel/logic/logic-test-disabled.scm diff --git a/TeXmacs/progs/kernel/old-gui/old-gui-test.scm b/TeXmacs/progs/kernel/old-gui/old-gui-demo.scm similarity index 99% rename from TeXmacs/progs/kernel/old-gui/old-gui-test.scm rename to TeXmacs/progs/kernel/old-gui/old-gui-demo.scm index 43609ce716..57cbc849f8 100644 --- a/TeXmacs/progs/kernel/old-gui/old-gui-test.scm +++ b/TeXmacs/progs/kernel/old-gui/old-gui-demo.scm @@ -11,7 +11,7 @@ ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(texmacs-module (kernel old-gui old-gui-test)) +(texmacs-module (kernel old-gui old-gui-demo)) (tm-define (open-test-widget) ;; NOTE: close with Done in order to test other widgets diff --git a/TeXmacs/progs/kernel/regexp/regexp-test.scm b/TeXmacs/progs/kernel/regexp/regexp-demo.scm similarity index 100% rename from TeXmacs/progs/kernel/regexp/regexp-test.scm rename to TeXmacs/progs/kernel/regexp/regexp-demo.scm diff --git a/xmake.lua b/xmake.lua index 840966b79f..0f60c0d502 100644 --- a/xmake.lua +++ b/xmake.lua @@ -571,99 +571,30 @@ target("windows_installer") do end) end -function add_test_target (filepath, dep) - local testname = path.basename(filepath) - target(testname) do - set_enabled(not is_plat("wasm")) - add_runenvs("TEXMACS_PATH", path.join(os.projectdir(), "TeXmacs")) - set_group("tests") - add_deps(dep) - set_languages("c++17") - set_policy("check.auto_ignore_flags", false) - if is_plat("windows") then - set_encodings("utf-8") -- eliminate warning C4819 on msvc - add_ldflags("/LTCG") - end - if is_plat("windows", "mingw") then - add_syslinks("secur32") - end - add_rules("qt.console") - add_frameworks("QtGui", "QtWidgets", "QtCore", "QtPrintSupport", "QtSvg", "QtTest") - if not is_plat("windows") then - add_syslinks("pthread") - end - if is_plat ("mingw") then - add_packages("mingw-w64") - end - add_packages("s7") - add_packages("lolly") - - add_includedirs({"$(buildir)", "tests/Base"}) - add_includedirs(libmogan_headers) - build_glue_on_config() - add_files("tests/Base/base.cpp") - add_files(filepath) - add_files(filepath, {rules = "qt.moc"}) - before_build(function (target) - target:add("forceincludes", path.absolute("$(buildir)/config.h")) - end) - - if is_plat("wasm") then - on_run(function (target) - node = os.getenv("EMSDK_NODE") - cmd = node .. " $(buildir)/wasm/wasm32/$(mode)/" .. testname .. ".js" - print("> " .. cmd) - os.exec(cmd) - end) - end - end -end +includes("xmake/tests.lua") -- Tests in C++ l3_cpp_tests = os.files("tests/L3/**_test.cpp") all_cpp_tests = os.files("tests/**_test.cpp") for _, filepath in ipairs(l3_cpp_tests) do - add_test_target (filepath, "libkernel_l3") + add_target_cpp_test(filepath, "libkernel_l3") end for _, filepath in ipairs(all_cpp_tests) do if not table.contains(l3_cpp_tests, filepath) then - add_test_target (filepath, "libmogan") + add_target_cpp_test(filepath, "libmogan") end end +-- Tests in Scheme +for _, filepath in ipairs(os.files("TeXmacs/progs/**/*-test.scm")) do + add_target_scheme_test(filepath, INSTALL_DIR, RUN_ENVS) +end +-- Integration tests for _, filepath in ipairs(os.files("TeXmacs/tests/*.scm")) do - local testname = path.basename(filepath) - target(testname) do - set_enabled(not is_plat("wasm")) - set_kind("phony") - set_group("integration_tests") - add_deps("research") - on_run(function (target) - name = target:name() - params = { - "-headless", - "-b", path.join("TeXmacs","tests",name..".scm"), - "-x", "(test_"..name..")", - "-q" - } - if is_plat("macosx", "linux") then - binary = target:deps()["research"]:targetfile() - elseif is_plat("mingw", "windows") then - binary = path.join(INSTALL_DIR,"bin","MGResearch.exe") - else - print("Unsupported plat $(plat)") - end - cmd = binary - if is_plat("macosx", "linux") then - os.execv(cmd, params, {envs=RUN_ENVS}) - else - os.execv(cmd, params) - end - end) - end + add_target_integration_test(filepath, INSTALL_DIR, RUN_ENVS) end diff --git a/xmake/tests.lua b/xmake/tests.lua new file mode 100644 index 0000000000..4ca53d0b21 --- /dev/null +++ b/xmake/tests.lua @@ -0,0 +1,117 @@ +function add_target_cpp_test(filepath, dep) + local testname = path.basename(filepath) + target(testname) do + set_enabled(not is_plat("wasm")) + add_runenvs("TEXMACS_PATH", path.join(os.projectdir(), "TeXmacs")) + set_group("tests") + add_deps(dep) + set_languages("c++17") + set_policy("check.auto_ignore_flags", false) + if is_plat("windows") then + set_encodings("utf-8") -- eliminate warning C4819 on msvc + add_ldflags("/LTCG") + end + if is_plat("windows", "mingw") then + add_syslinks("secur32") + end + add_rules("qt.console") + add_frameworks("QtGui", "QtWidgets", "QtCore", "QtPrintSupport", "QtSvg", "QtTest") + if not is_plat("windows") then + add_syslinks("pthread") + end + if is_plat ("mingw") then + add_packages("mingw-w64") + end + add_packages("s7") + add_packages("lolly") + + add_includedirs({"$(buildir)", "tests/Base"}) + add_includedirs(libmogan_headers) + build_glue_on_config() + add_files("tests/Base/base.cpp") + add_files(filepath) + add_files(filepath, {rules = "qt.moc"}) + before_build(function (target) + target:add("forceincludes", path.absolute("$(buildir)/config.h")) + end) + + if is_plat("wasm") then + on_run(function (target) + node = os.getenv("EMSDK_NODE") + cmd = node .. " $(buildir)/wasm/wasm32/$(mode)/" .. testname .. ".js" + print("> " .. cmd) + os.exec(cmd) + end) + end + end +end + +function add_target_scheme_test(filepath, INSTALL_DIR, RUN_ENVS) + local testname = path.basename(filepath) + target(testname) do + set_enabled(not is_plat("wasm")) + set_kind("phony") + set_group("scheme_tests") + add_deps("research") + on_run(function (target) + name = target:name() + regtest_name = "(regtest-"..string.sub(name, 1, -6)..")" + print("------------------------------------------------------") + print("Executing: " .. regtest_name) + params = { + "-headless", + "-b", filepath, + "-x", regtest_name, + "-q" + } + if is_plat("macosx", "linux") then + binary = target:deps()["research"]:targetfile() + elseif is_plat("mingw", "windows") then + binary = path.join(INSTALL_DIR,"bin","MGResearch.exe") + else + print("Unsupported plat $(plat)") + end + cmd = binary + if is_plat("macosx", "linux") then + os.execv(cmd, params, {envs=RUN_ENVS}) + else + os.execv(cmd, params) + end + end) + end +end + +function add_target_integration_test(filepath, INSTALL_DIR, RUN_ENVS) + local testname = path.basename(filepath) + target(testname) do + set_enabled(not is_plat("wasm")) + set_kind("phony") + set_group("integration_tests") + add_deps("research") + on_run(function (target) + name = target:name() + test_name = "(test_"..name..")" + print("------------------------------------------------------") + print("Executing: " .. test_name) + params = { + "-headless", + "-b", path.join("TeXmacs","tests",name..".scm"), + "-x", test_name, + "-q" + } + if is_plat("macosx", "linux") then + binary = target:deps()["research"]:targetfile() + elseif is_plat("mingw", "windows") then + binary = path.join(INSTALL_DIR,"bin","MGResearch.exe") + else + print("Unsupported plat $(plat)") + end + cmd = binary + if is_plat("macosx", "linux") then + os.execv(cmd, params, {envs=RUN_ENVS}) + else + os.execv(cmd, params) + end + end) + end +end