Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Lua unit tests #5117

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft

Conversation

rolandlo
Copy link
Member

@rolandlo rolandlo commented Sep 3, 2023

This is a proof of concept for adding unit tests for the Lua plugin API.

  • app.openFile
  • app.getDocumentStructure, app.setCurrentPage, app.setCurrentLayer
  • app.setSidebarPageNo and app.getSidebarPageNo
  • app.uiAction({action = "ACTION_NEW_PAGE_AFTER"}) (currently segfaults)

Currently gtk_widget_destroy is removed from the GladeGui destructor, since the test segfaults otherwise (this was found by attaching gdb to test/test-units and looking at the backtrace when it segfaulted).

Configure with the flag -DENABLE_GTEST=on, build with

cmake --build . --target test-units

Run the tests via

cmake --build . --target test

If a (Lua) test fails, rerun with

ctest --stop-on-failure --rerun-failed --output-on-failure

Then you get useful information, like e.g. when asserting a wrong page number (3 instead of 2) via
assert_equal(app.getSidebarPageNo(), 3) we get:

-- Starting suite "main", 2 test(s)
  F.
---- Testing finished in 19.14 ms, with 18 assertion(s) ----
  1 passed, 1 failed, 0 error(s), 0 skipped.
FAIL: main.test_sidebarPage (0.06ms): Expected 2 +/- 0, got 3 (60)


0% tests passed, 1 tests failed out of 1

Total Test time (real) =   0.21 sec

The following tests FAILED:
         22 - LuaTest.testPage (Failed)
Errors while running CTest

@rolandlo rolandlo marked this pull request as draft September 3, 2023 06:25
@rolandlo rolandlo changed the title First working Lua unit tests WP: Lua unit tests Sep 3, 2023
@rolandlo rolandlo added the plugins Related to plugin system label Sep 3, 2023
@rolandlo rolandlo force-pushed the add-lua-unit-tests branch 6 times, most recently from 306200b to af4dfb5 Compare September 3, 2023 10:09
@rolandlo rolandlo changed the title WP: Lua unit tests WIP: Lua unit tests Sep 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugins Related to plugin system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant