aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/tools/tst_tools.cpp
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@digia.com>2012-10-02 16:57:02 +0200
committerJoerg Bornemann <joerg.bornemann@digia.com>2012-10-02 21:12:25 +0200
commitac7834dd466de8d77f1066ebd7afa316cb8bbd09 (patch)
tree7a9d1fa4513e6a32e381eaec3f343e053d306309 /tests/auto/tools/tst_tools.cpp
parentb452db51d1b92686936136d7e2f7f23c03deab58 (diff)
Look up project file in directory, if one is given.
This allows the user to specify via "-f" the directory which the project file is located in instead of the whole file path. in most cases, a directory will contain only one project, so the user can save some typing there. Change-Id: I1a828480b522517e00b2b183da9b9ad602a6a424 Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'tests/auto/tools/tst_tools.cpp')
-rw-r--r--tests/auto/tools/tst_tools.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/tools/tst_tools.cpp b/tests/auto/tools/tst_tools.cpp
index a1a13ced5..3ec122304 100644
--- a/tests/auto/tools/tst_tools.cpp
+++ b/tests/auto/tools/tst_tools.cpp
@@ -38,6 +38,7 @@
#include <tools/logger.h>
#include <tools/fileinfo.h>
#include <tools/options.h>
+#include <QDir>
#include <QtTest>
class TestFileInfo : public QObject
@@ -68,6 +69,26 @@ private slots:
#endif
QCOMPARE(qbs::FileInfo::resolvePath("/abc/lol", "waffl"), QString("/abc/lol/waffl"));
}
+
+ void testProjectFileLookup()
+ {
+ const QString srcDir = QLatin1String(SRCDIR);
+ const QString noProjectsDir = srcDir + QLatin1String("data/dirwithnoprojects");
+ const QString oneProjectDir = srcDir + QLatin1String("data/dirwithoneproject");
+ const QString multiProjectsDir = srcDir + QLatin1String("data/dirwithmultipleprojects");
+ Q_ASSERT(QDir(noProjectsDir).exists() && QDir(oneProjectDir).exists()
+ && QDir(multiProjectsDir).exists());
+ qbs::CommandLineOptions options;
+ const QStringList args(QLatin1String("-f"));
+ QString projectFilePath = multiProjectsDir + QLatin1String("/project.qbp");
+ QVERIFY(options.readCommandLineArguments(args + QStringList(projectFilePath)));
+ QCOMPARE(projectFilePath, options.projectFileName());
+ projectFilePath = oneProjectDir + QLatin1String("/project.qbp");
+ QVERIFY(options.readCommandLineArguments(args + QStringList(oneProjectDir)));
+ QCOMPARE(projectFilePath, options.projectFileName());
+ QVERIFY(!options.readCommandLineArguments(args + QStringList(noProjectsDir)));
+ QVERIFY(!options.readCommandLineArguments(args + QStringList(multiProjectsDir)));
+ }
};
QTEST_APPLESS_MAIN(TestFileInfo)