Skip to content

Commit e589fc4

Browse files
committed
Replace __FILE__ macro
Debian manipulates the macro in order to promote reproducible builds. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=876934
1 parent da78747 commit e589fc4

File tree

8 files changed

+48
-10
lines changed

8 files changed

+48
-10
lines changed

src/core/symbols/line_symbol.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ void LineSymbol::shiftCoordinates(const VirtualPath& path, double main_shift, Ma
569569
{
570570
// Rare but existing case. No valid solution, but
571571
// at least we need to output a point to handle the flags correctly.
572-
//qDebug() << "No valid tangent at" << __FILE__ << __LINE__;
572+
//qDebug("No valid tangent");
573573
segment_start = coords_i;
574574
}
575575
else if (i == 0 && !path.isClosed())

test/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ add_definitions(
3737
-DQT_USE_QSTRINGBUILDER
3838
)
3939

40+
configure_file(test_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/test_config.h @ONLY)
41+
42+
4043
# This function defines a test from a list of source file names
4144
# (without ending). For each filename, a .cpp file and .h must exist.
4245
# The .h file is processed with Qt's moc.

test/duplicate_equals_t.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
#include <QtTest>
2424

25+
#include "test_config.h"
26+
2527
#include "global.h"
2628
#include "core/map.h"
2729
#include "core/objects/object.h"
@@ -42,7 +44,7 @@ void DuplicateEqualsTest::initTestCase()
4244
doStaticInitializations();
4345

4446
static const auto prefix = QString::fromLatin1("data");
45-
QDir::addSearchPath(prefix, QFileInfo(QString::fromUtf8(__FILE__)).dir().absoluteFilePath(prefix));
47+
QDir::addSearchPath(prefix, QDir(QString::fromUtf8(MAPPER_TEST_SOURCE_DIR)).absoluteFilePath(prefix));
4648

4749
for (auto raw_path : test_files)
4850
{

test/file_format_t.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
#include <QtTest>
2424

25+
#include "test_config.h"
26+
2527
#include "global.h"
2628
#include "settings.h"
2729
#include "core/georeferencing.h"
@@ -338,7 +340,7 @@ void FileFormatTest::initTestCase()
338340
FileFormats.registerFormat(new OCAD8FileFormat());
339341

340342
static const auto prefix = QString::fromLatin1("data");
341-
QDir::addSearchPath(prefix, QFileInfo(QString::fromUtf8(__FILE__)).dir().absoluteFilePath(prefix));
343+
QDir::addSearchPath(prefix, QDir(QString::fromUtf8(MAPPER_TEST_SOURCE_DIR)).absoluteFilePath(prefix));
342344

343345
for (auto raw_path : test_files)
344346
{

test/map_t.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include <QMessageBox>
2525
#include <QTextStream>
2626

27+
#include "test_config.h"
28+
2729
#include "global.h"
2830
#include "core/map.h"
2931
#include "core/map_color.h"
@@ -46,10 +48,10 @@ void MapTest::initTestCase()
4648

4749
doStaticInitializations();
4850

49-
examples_dir.cd(QFileInfo(QString::fromUtf8(__FILE__)).dir().absoluteFilePath(QString::fromLatin1("../examples")));
51+
examples_dir.cd(QDir(QString::fromUtf8(MAPPER_TEST_SOURCE_DIR)).absoluteFilePath(QStringLiteral("../examples")));
5052
QVERIFY(examples_dir.exists());
5153

52-
symbol_set_dir.cd(QFileInfo(QString::fromUtf8(__FILE__)).dir().absoluteFilePath(QString::fromLatin1("../symbol sets")));
54+
symbol_set_dir.cd(QDir(QString::fromUtf8(MAPPER_TEST_SOURCE_DIR)).absoluteFilePath(QStringLiteral("../symbol sets")));
5355
QVERIFY(symbol_set_dir.exists());
5456

5557
// Static map initializations

test/symbol_set_t.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
#include <QXmlStreamReader>
4848
#include <QXmlStreamWriter>
4949

50+
#include "test_config.h"
51+
5052
#include "global.h"
5153
#include "settings.h"
5254
#include "core/map.h"
@@ -270,16 +272,16 @@ void SymbolSetTool::initTestCase()
270272

271273
doStaticInitializations();
272274

273-
symbol_set_dir.cd(QFileInfo(QString::fromUtf8(__FILE__)).dir().absoluteFilePath(QString::fromLatin1("../symbol sets")));
275+
symbol_set_dir.cd(QDir(QString::fromUtf8(MAPPER_TEST_SOURCE_DIR)).absoluteFilePath(QStringLiteral("../symbol sets")));
274276
QVERIFY(symbol_set_dir.exists());
275277

276-
examples_dir.cd(QFileInfo(QString::fromUtf8(__FILE__)).dir().absoluteFilePath(QString::fromLatin1("../examples")));
278+
examples_dir.cd(QDir(QString::fromUtf8(MAPPER_TEST_SOURCE_DIR)).absoluteFilePath(QStringLiteral("../examples")));
277279
QVERIFY(examples_dir.exists());
278280

279-
test_data_dir.cd(QFileInfo(QString::fromUtf8(__FILE__)).dir().absoluteFilePath(QString::fromLatin1("../test/data")));
281+
test_data_dir.cd(QDir(QString::fromUtf8(MAPPER_TEST_SOURCE_DIR)).absoluteFilePath(QStringLiteral("../test/data")));
280282
QVERIFY(test_data_dir.exists());
281283

282-
translations_dir.cd(QFileInfo(QString::fromUtf8(__FILE__)).dir().absoluteFilePath(QString::fromLatin1("../translations")));
284+
translations_dir.cd(QDir(QString::fromUtf8(MAPPER_TEST_SOURCE_DIR)).absoluteFilePath(QStringLiteral("../translations")));
283285
QVERIFY(translations_dir.exists());
284286

285287
Template::pathForSaving = &Template::getTemplateRelativePath;

test/template_t.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#include <QString>
2828
#include <QTransform>
2929

30+
#include "test_config.h"
31+
3032
#include "global.h"
3133
#include "core/georeferencing.h"
3234
#include "core/map.h"
@@ -49,7 +51,7 @@ private slots:
4951
doStaticInitializations();
5052
// Static map initializations
5153
Map map;
52-
QDir::addSearchPath(QStringLiteral("testdata"), QFileInfo(QString::fromUtf8(__FILE__)).dir().absoluteFilePath(QStringLiteral("data")));
54+
QDir::addSearchPath(QStringLiteral("testdata"), QDir(QString::fromUtf8(MAPPER_TEST_SOURCE_DIR)).absoluteFilePath(QStringLiteral("data")));
5355
}
5456

5557
void worldFileUnitTest()

test/test_config.h.in

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright 2017 Kai Pastor
3+
*
4+
* This file is part of OpenOrienteering.
5+
*
6+
* OpenOrienteering is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* OpenOrienteering is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with OpenOrienteering. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
#ifndef OPENORIENTEERING_TEST_CONFIG_H
21+
#define OPENORIENTEERING_TEST_CONFIG_H
22+
23+
#define MAPPER_TEST_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@"
24+
25+
#endif

0 commit comments

Comments
 (0)