Fix kdev_perforce unittest to run on kde windows CI and everywhere else.
ClosedPublic

Authored by volden on Aug 20 2018, 8:59 PM.

Details

Summary

Fix unittest properly. The previous 'fix' for the unittest did not work on CI.

And IMHO it was not too pretty. This one should work on the CI and everywhere else for that matter.

Test Plan

Tested on Linux and windows builds. If this works unittest will pass on KDE Windows CI as well.

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.
volden created this revision.Aug 20 2018, 8:59 PM
Restricted Application added a project: KDevelop. · View Herald TranscriptAug 20 2018, 8:59 PM
volden requested review of this revision.Aug 20 2018, 8:59 PM
volden edited the summary of this revision. (Show Details)Aug 20 2018, 9:02 PM
volden updated this revision to Diff 40136.Aug 21 2018, 10:42 AM
  • Merged master
volden updated this revision to Diff 40137.Aug 21 2018, 11:02 AM
  • Merge master properly this time
kfunk requested changes to this revision.Aug 21 2018, 11:03 AM
kfunk added a subscriber: kfunk.
kfunk added inline comments.
plugins/perforce/tests/CMakeLists.txt
13

With http://doc.qt.io/qt-5/qstandardpaths.html#findExecutable you wouldn't need to append ${CMAKE_EXECUTABLE_SUFFIX}

plugins/perforce/tests/test_perforce.cpp
59

Use http://doc.qt.io/qt-5/qstandardpaths.html#findExecutable? Also QVERIFY(...) that the executable was found maybe?

This revision now requires changes to proceed.Aug 21 2018, 11:03 AM

Also note: Please push this and other upcoming bug fixes to 5.3 branch.

volden added inline comments.Aug 21 2018, 12:56 PM
plugins/perforce/tests/test_perforce.cpp
59

As far as I can tell. findExecutable is not recursive. So I would still need QDirIterator to find the dirs for findExecutable to look through. So the question is how much more sense findExecutable makes in this scenario?

volden added inline comments.Aug 21 2018, 1:09 PM
plugins/perforce/tests/test_perforce.cpp
59

On Second thought. It does remove the need for one of the defines.

volden updated this revision to Diff 40153.Aug 21 2018, 1:29 PM
  • Implemented Kevins review comments
volden marked 2 inline comments as done.Aug 21 2018, 1:35 PM
volden marked 2 inline comments as done.Aug 21 2018, 3:20 PM
kfunk added inline comments.Aug 22 2018, 9:29 AM
plugins/perforce/tests/test_perforce.cpp
59

Scanning recursively through the build dir seems pretty unclean to me.

Wouldn't a simple QStandardPaths::findExecutable("p4clientstub", P4_BINARY_DIR); with P4_BINARY_DIR initialized with CMAKE_RUNTIME_OUTPUT_DIRECTORY work?

See: https://cmake.org/cmake/help/v3.9/variable/CMAKE_RUNTIME_OUTPUT_DIRECTORY.html

volden added inline comments.Aug 23 2018, 1:15 PM
plugins/perforce/tests/test_perforce.cpp
59

As far as I can tell from cmake documetation

https://cmake.org/cmake/help/v3.9/manual/cmake-variables.7.html

CMAKE_RUNTIME_OUTPUT_DIRECTORY is under the section "Variables that Control the Build". I take that to mean it is meant to be set and not read. That would also correspond with the fact that it gives me an empty path when I initialize P4_BINARY_DIR with it.

Under "Variables that Provide Information" section there is:

CMAKE_CURRENT_BINARY_DIR gives me /home/mvo/kde/build/extragear/kdevelop/kdevelop/plugins/perforce/tests (The executable is under /home/mvo/kde/build/extragear/kdevelop/kdevelop/plugins/perforce/p4clientstub and at a different relative location under windows)
<PROJECT-NAME>_BINARY_DIR gives me /home/mvo/kde/build/extragear/kdevelop/kdevelop/
PROJECT_BINARY_DIR gives me /home/mvo/kde/build/extragear/kdevelop/kdevelop/ (because there is only one project declaration in all of kdevelop)

I'm not a big fan of scanning the entire build dir either. but at least it is only done once pr. testrun

kfunk accepted this revision.Aug 23 2018, 3:02 PM

Indeed, CMAKE_RUNTIME_OUTPUT_DIRECTORY is empty for me, too :(

Okay, then go ahead with this. This use-case is indeed not very well supported with CMake :(

This revision is now accepted and ready to land.Aug 23 2018, 3:02 PM
This revision was automatically updated to reflect the committed changes.