Changeset View
Standalone View
plugins/perforce/tests/test_perforce.cpp
Show All 16 Lines | |||||
17 | * * | 17 | * * | ||
18 | * You should have received a copy of the GNU General Public License * | 18 | * You should have received a copy of the GNU General Public License * | ||
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. * | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. * | ||
20 | ***************************************************************************/ | 20 | ***************************************************************************/ | ||
21 | 21 | | |||
22 | #include "test_perforce.h" | 22 | #include "test_perforce.h" | ||
23 | 23 | | |||
24 | #include <QTest> | 24 | #include <QTest> | ||
25 | #include <QDirIterator> | ||||
25 | 26 | | |||
26 | #include <tests/autotestshell.h> | 27 | #include <tests/autotestshell.h> | ||
27 | #include <tests/testcore.h> | 28 | #include <tests/testcore.h> | ||
28 | 29 | | |||
29 | #include <vcs/vcsjob.h> | 30 | #include <vcs/vcsjob.h> | ||
30 | #include <vcs/vcsannotation.h> | 31 | #include <vcs/vcsannotation.h> | ||
31 | 32 | | |||
32 | #include <perforceplugin.h> | 33 | #include <perforceplugin.h> | ||
Show All 14 Lines | |||||
47 | 48 | | |||
48 | using namespace KDevelop; | 49 | using namespace KDevelop; | ||
49 | 50 | | |||
50 | void PerforcePluginTest::initTestCase() | 51 | void PerforcePluginTest::initTestCase() | ||
51 | { | 52 | { | ||
52 | AutoTestShell::init({QStringLiteral("kdevperforce")}); | 53 | AutoTestShell::init({QStringLiteral("kdevperforce")}); | ||
53 | TestCore::initialize(); | 54 | TestCore::initialize(); | ||
54 | m_plugin = new PerforcePlugin(TestCore::self()); | 55 | m_plugin = new PerforcePlugin(TestCore::self()); | ||
56 | | ||||
57 | /// During test we are setting the executable the plugin uses to our own stub | ||||
58 | QDirIterator it(P4_BINARY_DIR , QStringList() << P4_CLIENT_STUB_EXE, QDir::Files, QDirIterator::Subdirectories); | ||||
kfunk: Use `http://doc.qt.io/qt-5/qstandardpaths.html#findExecutable`? Also `QVERIFY(...)` that the… | |||||
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: As far as I can tell. findExecutable is not recursive. So I would still need QDirIterator to… | |||||
volden: On Second thought. It does remove the need for one of the defines. | |||||
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 kfunk: Scanning recursively through the build dir seems pretty unclean to me.
Wouldn't a simple… | |||||
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) I'm not a big fan of scanning the entire build dir either. but at least it is only done once pr. testrun volden: As far as I can tell from cmake documetation
https://cmake.org/cmake/help/v3.9/manual/cmake… | |||||
59 | QString p4stubPath; | ||||
60 | while (it.hasNext()) { | ||||
61 | it.next(); | ||||
62 | p4stubPath = it.filePath(); | ||||
63 | qDebug() << "found p4stub executable :" << it.filePath(); | ||||
64 | } | ||||
65 | | ||||
66 | m_plugin->m_perforceExecutable = p4stubPath; | ||||
55 | } | 67 | } | ||
56 | 68 | | |||
57 | void PerforcePluginTest::cleanupTestCase() | 69 | void PerforcePluginTest::cleanupTestCase() | ||
58 | { | 70 | { | ||
59 | delete m_plugin; | 71 | delete m_plugin; | ||
60 | TestCore::shutdown(); | 72 | TestCore::shutdown(); | ||
61 | } | 73 | } | ||
62 | 74 | | |||
63 | 75 | | |||
64 | void PerforcePluginTest::init() | 76 | void PerforcePluginTest::init() | ||
65 | { | 77 | { | ||
66 | /// During test we are setting the executable the plugin uses to our own stub | | |||
67 | m_plugin->m_perforceExecutable = P4_CLIENT_STUB_EXE; | | |||
68 | removeTempDirsIfAny(); | 78 | removeTempDirsIfAny(); | ||
69 | createNewTempDirs(); | 79 | createNewTempDirs(); | ||
70 | } | 80 | } | ||
71 | 81 | | |||
72 | void PerforcePluginTest::createNewTempDirs() | 82 | void PerforcePluginTest::createNewTempDirs() | ||
73 | { | 83 | { | ||
74 | // Now create the basic directory structure | 84 | // Now create the basic directory structure | ||
75 | QDir tmpdir(tempDir); | 85 | QDir tmpdir(tempDir); | ||
▲ Show 20 Lines • Show All 122 Lines • Show Last 20 Lines |
Use http://doc.qt.io/qt-5/qstandardpaths.html#findExecutable? Also QVERIFY(...) that the executable was found maybe?