From e040265d425cc5f5f6e5911410b1a990548fe251 Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Tue, 6 Dec 2022 15:59:51 +0100 Subject: [PATCH] Avoid polluting the source directory if qtprotobufgen test failed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use a directory where the test binary is located to generate the protobuf source files. This avoids polluting the source directory if test exits with the critical error. Change-Id: I288b5b3b84b243c28e9dd967e4411a7d4805d1bf Reviewed-by: Tatiana Borisova Reviewed-by: MÃ¥rten Nordheim --- tests/auto/protobufgen/tst_qtprotobufgen.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/tests/auto/protobufgen/tst_qtprotobufgen.cpp b/tests/auto/protobufgen/tst_qtprotobufgen.cpp index dd2574b1..e4174697 100644 --- a/tests/auto/protobufgen/tst_qtprotobufgen.cpp +++ b/tests/auto/protobufgen/tst_qtprotobufgen.cpp @@ -172,17 +172,15 @@ void tst_qtprotobufgen::initTestCase() m_protoFiles = QFINDTESTDATA("../shared/data/proto/"); QVERIFY(!m_protoFiles.isEmpty()); - QString dataPath = QFINDTESTDATA("data"); - QVERIFY(!dataPath.isEmpty()); - - QDir dataDir(dataPath); - dataDir.mkdir(QLatin1StringView("cmd_line_generation")); + QDir testOutputBaseDir(QCoreApplication::applicationDirPath()); + testOutputBaseDir.mkdir(QLatin1StringView("cmd_line_generation")); QLatin1StringView folders[] = {"comments"_L1, "extra-namespace"_L1, "fieldenum"_L1, "folder"_L1, "no-options"_L1}; for (QLatin1StringView folder : folders) - dataDir.mkdir("cmd_line_generation/"_L1 + folder); + testOutputBaseDir.mkdir("cmd_line_generation/"_L1 + folder); - m_commandLineGenerated = dataDir.absolutePath() + QLatin1StringView("/cmd_line_generation"); + m_commandLineGenerated = testOutputBaseDir.absolutePath() + + QLatin1StringView("/cmd_line_generation"); QVERIFY(!m_commandLineGenerated.isEmpty()); #ifdef Q_OS_MACOS if (!protocolCompilerAvailableToRun())