Fix and improve CMake test finding and running
ClosedPublic

Authored by mihac on Jan 16 2018, 1:08 PM.

Details

Summary

This is a bunch of small changes that together enable running tests from
CMake with support for QtTest and viewing results in the tool view.
The changes include:

  1. Enable listing test cases from tests defined with CMake and QtTest
    • Extract sources for each target from cmake server
    • Use target sources to look for QtTest declarations in them
    • Fix the search for QtTest declarations, so that it works without access to the main() function body
  1. When running tests, parse the output and report results
    • Exctract output directly from the OutputModel, which is long-lived, and not from the shorter-lived OutputJob. The previous method would lose some lines of output.
    • Wait for asynchronous output signals from OutputModel, which again prevents losing some lines of test program output.
  1. A new unit test that checks the cases parsed from source code, using the existing testing project unit_tests_kde.

With these changes, the test suites and individual test cases appear in the
Unit Tests tool view:

Diff Detail

Repository
R32 KDevelop
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
mihac created this revision.Jan 16 2018, 1:08 PM
Restricted Application added a subscriber: kdevelop-devel. · View Herald TranscriptJan 16 2018, 1:08 PM
mihac requested review of this revision.Jan 16 2018, 1:08 PM
mihac edited the summary of this revision. (Show Details)Jan 16 2018, 1:11 PM
mihac added a reviewer: KDevelop.
mihac edited the summary of this revision. (Show Details)Jan 16 2018, 1:16 PM
mihac updated this revision to Diff 25497.Jan 16 2018, 6:46 PM

Remove some changes that were not needed

apol accepted this revision.Jan 16 2018, 7:44 PM
apol added a subscriber: apol.

LGTM, thanks!

This revision is now accepted and ready to land.Jan 16 2018, 7:44 PM
mihac updated this revision to Diff 25507.Jan 16 2018, 9:36 PM

Look for test class at different positions in QTEST_MAIN

We now look for a test class declarations at multiple positions inside
QTEST_MAIN or QTEST_GUILESS_MAIN. This way, we find test cases for the
entire KDevelop test suite, while without this change invocations with
the format of QTEST_MAIN(KDevelop::Something) were missed.

mihac added a comment.Jan 16 2018, 9:41 PM

I'm still not fully happy with the change, because we're looking for the QTEST test class by text position rather than going purely through uses and declarations. But I'm landing this, since it works, and will try to improve the searching separately.

This revision was automatically updated to reflect the committed changes.