summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilian Wolff <milian.wolff@kdab.com>2020-06-12 18:27:17 +0200
committerMilian Wolff <milian.wolff@kdab.com>2020-09-09 09:00:59 +0000
commit778ec91b484a30c3a6430ab67ec9697814bb6171 (patch)
treeee82acad1134909aa7fbeeb85dd2ab465687fbac
parentb6687617801c43e25c893c47fd3eb88113b56a7d (diff)
Generalize TestPerfData::testFiles
This patch allows us to more easily add new data files that reuse the same binaries we have already added to our test data, instead of requiring a single copy per directory. Change-Id: Ia635f6d5444a4b92e2a4a684d9c44bce61ad017c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r--.gitignore2
-rw-r--r--tests/auto/perfdata/tst_perfdata.cpp25
-rw-r--r--tests/auto/perfdata/vector_static_clang/perf.data.expected.txt (renamed from tests/auto/perfdata/vector_static_clang/expected.txt)0
-rw-r--r--tests/auto/perfdata/vector_static_gcc/perf.data.expected.txt (renamed from tests/auto/perfdata/vector_static_gcc/expected.txt)0
4 files changed, 15 insertions, 12 deletions
diff --git a/.gitignore b/.gitignore
index 48dbdf7..a223523 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1 @@
-tests/auto/**/actual.txt
+tests/auto/**/*.actual.txt
diff --git a/tests/auto/perfdata/tst_perfdata.cpp b/tests/auto/perfdata/tst_perfdata.cpp
index 01f75b9..320c4fb 100644
--- a/tests/auto/perfdata/tst_perfdata.cpp
+++ b/tests/auto/perfdata/tst_perfdata.cpp
@@ -203,27 +203,30 @@ void TestPerfData::testContentSize()
void TestPerfData::testFiles_data()
{
- QTest::addColumn<QString>("dirName");
-
- for (auto dir : {"vector_static_clang", "vector_static_gcc"})
- QTest::addRow("%s", dir) << dir;
+ QTest::addColumn<QString>("dataFile");
+
+ const auto files = {
+ "vector_static_clang/perf.data",
+ "vector_static_gcc/perf.data",
+ };
+ for (auto file : files)
+ QTest::addRow("%s", file) << file;
}
void TestPerfData::testFiles()
{
- QFETCH(QString, dirName);
+ QFETCH(QString, dataFile);
- const auto dir = QFINDTESTDATA(dirName);
- QVERIFY(!dir.isEmpty() && QFile::exists(dir));
- const auto perfDataFile = dir + "/perf.data";
- const auto expectedOutputFile = dir + "/expected.txt";
- const auto actualOutputFile = dir + "/actual.txt";
+ const auto perfDataFile = QFINDTESTDATA(dataFile);
+ QVERIFY(!perfDataFile.isEmpty() && QFile::exists(perfDataFile));
+ const auto expectedOutputFile = perfDataFile + ".expected.txt";
+ const auto actualOutputFile = perfDataFile + ".actual.txt";
QBuffer output;
QVERIFY(output.open(QIODevice::WriteOnly));
// Don't try to load any system files. They are not the same as the ones we use to report.
- PerfUnwind unwind(&output, ":/", QString(), QString(), dir);
+ PerfUnwind unwind(&output, ":/", QString(), QString(), QFileInfo(perfDataFile).absolutePath());
{
QFile input(perfDataFile);
QVERIFY(input.open(QIODevice::ReadOnly));
diff --git a/tests/auto/perfdata/vector_static_clang/expected.txt b/tests/auto/perfdata/vector_static_clang/perf.data.expected.txt
index 25fda49..25fda49 100644
--- a/tests/auto/perfdata/vector_static_clang/expected.txt
+++ b/tests/auto/perfdata/vector_static_clang/perf.data.expected.txt
diff --git a/tests/auto/perfdata/vector_static_gcc/expected.txt b/tests/auto/perfdata/vector_static_gcc/perf.data.expected.txt
index 54f5fe5..54f5fe5 100644
--- a/tests/auto/perfdata/vector_static_gcc/expected.txt
+++ b/tests/auto/perfdata/vector_static_gcc/perf.data.expected.txt