ucam-department-of-psychiatry / camcops

Cambridge Cognitive and Psychiatric Test Kit (CamCOPS)
Other
12 stars 8 forks source link

C++ Tests for Qt5 #307

Closed martinburchell closed 1 year ago

martinburchell commented 1 year ago

Backported C++ tests from the Qt6.5 branch, partly to reduce the size of that pull request and partly to test the "before" state. The choice of tests is a bit random, covering some of the more easily testable code that has needed to change for Qt6.5. The NameValueOptions tests are from a previously aborted attempt at using Qt Test.

In order to reduce the number of dependencies needed to compile the code to be tested, I've split out some of the functions in lib/uifunc:

We can probably do more to reduce the number of dependencies but this is enough to build the test executables quite quickly.

In the process of testing convert::toSqlLiteral() I've fixed two bugs with Date and Time handling. I'm not sure this code was being used anywhere.

There's a GitHub workflow for this on the Qt6.5 branch. You can't get qtmultimedia for 5.12.x with aqtinstall.

RudolfCardinal commented 1 year ago

Having upgraded locally from Ubuntu 20 to 22, the old Qt 5 build doesn't run (perhaps not too surprising as would have been configured for the OS at the time). Rebuilding Qt5 now, however, defaults to "gcc" = gcc-11, but this throws errors compiling Qt core code (https://forum.qt.io/topic/140793/build-qt5-15-on-ubuntu-22-04-with-gcc-11; https://forum.qt.io/topic/139626/unable-to-build-static-version-of-qt-5-15-2/15). Options are presumably:

Not sure which is best here.

martinburchell commented 1 year ago

Not sure which is best here.

What a pain!

I think it depends how much time you want to spend. If you want to be absolutely sure the tests are behaving as expected with Qt5, you could try gcc9. I don't know how easy that would be to set up. I'm happy to demonstrate them running on 20.04.

Alternatively you could wait until I've issued the Qt6.5 PR.

RudolfCardinal commented 1 year ago

Very happy for you to merge! Tests look good.