File indexing completed on 2025-03-09 04:56:53

0001 /*
0002  * SPDX-FileCopyrightText: 2014 David Faure <faure@kde.org>
0003  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0004  */
0005 
0006 
0007 #ifndef TESTSAFETY_H
0008 #define TESTSAFETY_H
0009 
0010 #include <QTest>
0011 #include <QDebug>
0012 
0013 namespace TestLib {
0014     namespace TestSafety {
0015 
0016         /**
0017          * Checks that the test is running in the proper test environment (akonaditest)
0018          */
0019         bool checkTestIsIsolated()
0020         {
0021             if (qEnvironmentVariableIsEmpty("AKONADI_TESTRUNNER_PID")) {
0022                 qCritical() << "This test must be run using ctest, in order to use the testrunner environment. Aborting, to avoid messing up your real akonadi";
0023                 return false;
0024             }
0025             return true;
0026         }
0027 
0028     }
0029 }
0030 
0031 #endif // TESTSAFETY_H