[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [gwenview/KDE/4.8] tests/auto: Unbreak remote tests and document how to enable them
From: Aurélien Gâteau <agateau () kde ! org>
Date: 2012-01-31 21:42:40
Message-ID: 20120131214240.CA933A60C4 () git ! kde ! org
[Download RAW message or body]
Git commit 37470388a2409c30800c99b5cfccac44fc0770e1 by Aurélien Gâteau.
Committed on 31/01/2012 at 22:42.
Pushed by gateau into branch 'KDE/4.8'.
Unbreak remote tests and document how to enable them
A +6 -0 tests/auto/README_REMOTE_TESTS
M +19 -33 tests/auto/testutils.cpp
http://commits.kde.org/gwenview/37470388a2409c30800c99b5cfccac44fc0770e1
diff --git a/tests/auto/README_REMOTE_TESTS b/tests/auto/README_REMOTE_TESTS
new file mode 100644
index 0000000..93ccd64
--- /dev/null
+++ b/tests/auto/README_REMOTE_TESTS
@@ -0,0 +1,6 @@
+Some of the unit tests in this dir can test code which access images on remote
+urls.
+
+To enable these tests, set the environment variable GV_REMOTE_TESTS_BASE_URL
+to something like "sftp://user@host/tmp". The tests will create a dir named
+"gwenview-remote-tests" in the supplied url.
diff --git a/tests/auto/testutils.cpp b/tests/auto/testutils.cpp
index 44c5c08..63f1d68 100644
--- a/tests/auto/testutils.cpp
+++ b/tests/auto/testutils.cpp
@@ -21,54 +21,40 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// KDE
#include <KDebug>
-#include <KIO/DeleteJob>
#include <KIO/NetAccess>
-#include <KIO/Job>
-
-static void rm_rf(const QString& pathOrUrl)
-{
- KIO::Job* job = KIO::del(pathOrUrl, KIO::HideProgressInfo);
- job->setUiDelegate(0);
- KIO::NetAccess::synchronousRun(job, 0);
-}
-
-static bool mkdir(const QString& pathOrUrl)
-{
- KIO::Job* job = KIO::mkdir(pathOrUrl, -1);
- job->setUiDelegate(0);
- return KIO::NetAccess::synchronousRun(job, 0);
-}
-
-static bool cp(const QString& src, const QString& _dst)
-{
- KIO::Job* job = KIO::file_copy(src, _dst, -1, KIO::Overwrite | KIO::HideProgressInfo);
- job->setUiDelegate(0);
- return KIO::NetAccess::synchronousRun(job, 0);
-}
KUrl setUpRemoteTestDir(const QString& testFile)
{
- if (!qgetenv("NO_REMOTE_TESTS").isEmpty()) {
- kWarning() << "Remote tests disabled";
+ QWidget* authWindow = 0;
+ bool ok;
+ if (qgetenv("GV_REMOTE_TESTS_BASE_URL").isEmpty()) {
+ kWarning() << "Environment variable GV_REMOTE_TESTS_BASE_URL not set: remote tests disabled";
return KUrl();
}
- QString testDir("/tmp/gwenview-remote-tests/");
- rm_rf(testDir);
+ KUrl baseUrl = QString::fromLocal8Bit(qgetenv("GV_REMOTE_TESTS_BASE_URL"));
+ baseUrl.addPath("gwenview-remote-tests");
- if (!mkdir(testDir)) {
- kFatal() << "Could not create dir" << testDir;
+ if (KIO::NetAccess::exists(baseUrl, KIO::NetAccess::DestinationSide, authWindow)) {
+ KIO::NetAccess::del(baseUrl, authWindow);
+ }
+ ok = KIO::NetAccess::mkdir(baseUrl, authWindow);
+ if (!ok) {
+ kFatal() << "Could not create dir" << baseUrl;
return KUrl();
}
if (!testFile.isEmpty()) {
- if (!cp(pathForTestFile(testFile), testDir + testFile)) {
- kFatal() << "Could not copy" << testFile << "to" << testDir;
+ KUrl dstUrl = baseUrl;
+ dstUrl.addPath(testFile);
+ ok = KIO::NetAccess::file_copy(urlForTestFile(testFile), dstUrl, authWindow);
+ if (!ok) {
+ kFatal() << "Could not copy" << testFile << "to" << dstUrl;
return KUrl();
}
}
- return KUrl("sftp://localhost" + testDir);
+ return baseUrl;
}
void createEmptyFile(const QString& path)
@@ -77,4 +63,4 @@ void createEmptyFile(const QString& path)
QFile file(path);
bool ok = file.open(QIODevice::WriteOnly);
Q_ASSERT(ok);
-}
\ No newline at end of file
+}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic