Skip to content

Commit b5122d1

Browse files
authoredSep 4, 2017
Merge pull request #5117 from nyalldawson/skip_test_travis
Skip some task manager tests on Travis only
2 parents 3e83704 + 700f9b2 commit b5122d1

37 files changed

+67
-121
lines changed
 

‎src/core/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,6 @@ SET(QGIS_CORE_HDRS
868868
qgsstatisticalsummary.h
869869
qgsstringstatisticalsummary.h
870870
qgsstringutils.h
871-
qgstestutils.h
872871
qgstextlabelfeature.h
873872
qgstextrenderer.h
874873
qgstextrenderer_p.h

‎src/core/qgstestutils.h

Lines changed: 0 additions & 63 deletions
This file was deleted.

‎src/test/qgstest.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,53 @@
3535
}
3636

3737

38+
#define QGSCOMPARENEAR(value,expected,epsilon) { \
39+
bool _xxxresult = qgsDoubleNear( value, expected, epsilon ); \
40+
if ( !_xxxresult ) \
41+
{ \
42+
qDebug( "Expecting %f got %f (diff %f > %f)", static_cast< double >( expected ), static_cast< double >( value ), std::fabs( static_cast< double >( expected ) - value ), static_cast< double >( epsilon ) ); \
43+
} \
44+
QVERIFY( qgsDoubleNear( value, expected, epsilon ) ); \
45+
}
46+
47+
#define QGSCOMPARENOTNEAR(value,not_expected,epsilon) { \
48+
bool _xxxresult = qgsDoubleNear( value, not_expected, epsilon ); \
49+
if ( _xxxresult ) \
50+
{ \
51+
qDebug( "Expecting %f to be differerent from %f (diff %f > %f)", static_cast< double >( value ), static_cast< double >( not_expected ), std::fabs( static_cast< double >( not_expected ) - value ), static_cast< double >( epsilon ) ); \
52+
} \
53+
QVERIFY( !qgsDoubleNear( value, not_expected, epsilon ) ); \
54+
}
55+
56+
#define QGSCOMPARENEARPOINT(point1,point2,epsilon) { \
57+
QGSCOMPARENEAR( point1.x(), point2.x(), epsilon ); \
58+
QGSCOMPARENEAR( point1.y(), point2.y(), epsilon ); \
59+
}
60+
61+
#define QGSCOMPARENEARRECTANGLE(rectangle1,rectangle2,epsilon) { \
62+
QGSCOMPARENEAR( rectangle1.xMinimum(), rectangle2.xMinimum(), epsilon ); \
63+
QGSCOMPARENEAR( rectangle1.xMaximum(), rectangle2.xMaximum(), epsilon ); \
64+
QGSCOMPARENEAR( rectangle1.yMinimum(), rectangle2.yMinimum(), epsilon ); \
65+
QGSCOMPARENEAR( rectangle1.yMaximum(), rectangle2.yMaximum(), epsilon ); \
66+
}
67+
68+
//sometimes GML attributes are in a different order - but that's ok
69+
#define QGSCOMPAREGML(result,expected) { \
70+
QCOMPARE( result.replace( QStringLiteral("ts=\" \" cs=\",\""), QStringLiteral("cs=\",\" ts=\" \"") ), expected ); \
71+
}
72+
73+
/**
74+
* QGIS unit test utilities.
75+
* \since QGIS 3.0
76+
*/
77+
namespace QgsTest
78+
{
79+
80+
//! Returns true if test is running on Travis infrastructure
81+
bool isTravis()
82+
{
83+
return qgetenv( "TRAVIS" ) == QStringLiteral( "true" );
84+
}
85+
}
86+
3887
#endif // QGSTEST_H

‎tests/src/analysis/testqgsalignraster.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "qgsapplication.h"
2020
#include "qgscoordinatereferencesystem.h"
2121
#include "qgsrectangle.h"
22-
#include "qgstestutils.h"
2322

2423
#include <QDir>
2524

‎tests/src/analysis/testqgsrastercalculator.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ Email : nyall dot dawson at gmail dot com
2121
#include "qgsrastermatrix.h"
2222
#include "qgsapplication.h"
2323
#include "qgsproject.h"
24-
#include "qgstestutils.h"
2524

2625
Q_DECLARE_METATYPE( QgsRasterCalcNode::Operator )
2726

‎tests/src/app/testqgsattributetable.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#include "qgsvectorfilewriter.h"
2929

3030
#include "qgstest.h"
31-
#include "qgstestutils.h"
3231

3332
/** \ingroup UnitTests
3433
* This is a unit test for the attribute table dialog

‎tests/src/app/testqgsfieldcalculator.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "qgsproject.h"
2525
#include "qgsmapcanvas.h"
2626
#include "qgsunittypes.h"
27-
#include "qgstestutils.h"
2827

2928
/** \ingroup UnitTests
3029
* This is a unit test for the field calculator

‎tests/src/app/testqgsmaptoolidentifyaction.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include "qgsunittypes.h"
2727
#include "qgsmaptoolidentifyaction.h"
2828
#include "qgssettings.h"
29-
#include "qgstestutils.h"
3029

3130
#include "cpl_conv.h"
3231

‎tests/src/app/testqgsmeasuretool.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "qgsproject.h"
2525
#include "qgsmapcanvas.h"
2626
#include "qgsunittypes.h"
27-
#include "qgstestutils.h"
2827

2928
/** \ingroup UnitTests
3029
* This is a unit test for the measure tool

‎tests/src/core/testqgscomposermap.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include "qgsproperty.h"
3030
#include <QObject>
3131
#include "qgstest.h"
32-
#include "qgstestutils.h"
3332

3433
class TestQgsComposerMap : public QObject
3534
{

‎tests/src/core/testqgscomposerutils.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "qgsmultirenderchecker.h"
2323
#include "qgsfontutils.h"
2424
#include "qgsproject.h"
25-
#include "qgstestutils.h"
2625
#include "qgsproperty.h"
2726
#include <QObject>
2827
#include "qgstest.h"

‎tests/src/core/testqgscomposition.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737

3838
#include <QObject>
3939
#include "qgstest.h"
40-
#include "qgstestutils.h"
4140

4241
class TestQgsComposition : public QObject
4342
{

‎tests/src/core/testqgscoordinatetransform.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "qgsrectangle.h"
2020
#include <QObject>
2121
#include "qgstest.h"
22-
#include "qgstestutils.h"
2322

2423
class TestQgsCoordinateTransform: public QObject
2524
{

‎tests/src/core/testqgscurve.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "qgslinestring.h"
2626
#include "qgspoint.h"
2727
#include "qgstest.h"
28-
#include "qgstestutils.h"
2928

3029
/** \ingroup UnitTests
3130
* This is a unit test for the operations on curve geometries

‎tests/src/core/testqgsdistancearea.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include "qgsgeometryfactory.h"
2727
#include "qgsgeometry.h"
2828
#include "qgis.h"
29-
#include "qgstestutils.h"
3029
#include <memory>
3130

3231
class TestQgsDistanceArea: public QObject

‎tests/src/core/testqgsexpression.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include "qgsrasterlayer.h"
3434
#include "qgsproject.h"
3535
#include "qgsexpressionnodeimpl.h"
36-
#include "qgstestutils.h"
3736

3837
static void _parseAndEvalExpr( int arg )
3938
{

‎tests/src/core/testqgsgeometry.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
#include "qgscircularstring.h"
4545
#include "qgsgeometrycollection.h"
4646
#include "qgsgeometryfactory.h"
47-
#include "qgstestutils.h"
4847

4948
//qgs unit test utility class
5049
#include "qgsrenderchecker.h"

‎tests/src/core/testqgsgeometryimport.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222

2323
#include "qgstest.h"
24-
#include "qgstestutils.h"
2524

2625
#include <QObject>
2726

‎tests/src/core/testqgsgeometryutils.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "qgslinestring.h"
2020
#include "qgspolygon.h"
2121
#include "qgsmultipolygon.h"
22-
#include "qgstestutils.h"
2322

2423
class TestQgsGeometryUtils: public QObject
2524
{

‎tests/src/core/testqgshistogram.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "qgsvectorlayer.h"
2121
#include "qgsvectordataprovider.h"
2222
#include "qgshistogram.h"
23-
#include "qgstestutils.h"
2423

2524
/** \ingroup UnitTests
2625
* This is a unit test for QgsHistogram

‎tests/src/core/testqgslayout.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "qgsproject.h"
2121
#include "qgslayoutitemmap.h"
2222
#include "qgslayoutitemshape.h"
23-
#include "qgstestutils.h"
2423

2524
class TestQgsLayout: public QObject
2625
{

‎tests/src/core/testqgslayoutitem.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "qgstest.h"
2323
#include "qgsproject.h"
2424
#include "qgsreadwritecontext.h"
25-
#include "qgstestutils.h"
2625
#include <QObject>
2726
#include <QPainter>
2827
#include <QImage>

‎tests/src/core/testqgslayoutunits.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include "qgslayoutsize.h"
2424
#include "qgslayoutmeasurementconverter.h"
2525
#include "qgis.h"
26-
#include "qgstestutils.h"
2726

2827
class TestQgsLayoutUnits : public QObject
2928
{

‎tests/src/core/testqgslayoututils.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "qgslayout.h"
1919
#include "qgstest.h"
2020
#include "qgslayoututils.h"
21-
#include "qgstestutils.h"
2221
#include "qgsproject.h"
2322
#include "qgslayoutitemmap.h"
2423

‎tests/src/core/testqgsmaptopixel.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include <qgsmaptopixel.h>
2121
#include <qgspoint.h>
2222
#include "qgslogger.h"
23-
#include "qgstestutils.h"
2423

2524
class TestQgsMapToPixel: public QObject
2625
{

‎tests/src/core/testqgspoint.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include <qgsgeometry.h>
2626
//header for class being tested
2727
#include <qgspoint.h>
28-
#include "qgstestutils.h"
2928

3029
class TestQgsPointXY: public QObject
3130
{

‎tests/src/core/testqgsprocessing.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include <QtTest/QSignalSpy>
2626
#include "qgis.h"
2727
#include "qgstest.h"
28-
#include "qgstestutils.h"
2928
#include "qgsrasterlayer.h"
3029
#include "qgsproject.h"
3130
#include "qgspoint.h"

‎tests/src/core/testqgsproperty.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
***************************************************************************/
1717

1818
#include "qgstest.h"
19-
#include "qgstestutils.h"
2019
#include "qgsproperty.h"
2120
#include "qgspropertycollection.h"
2221
#include "qgsvectorlayer.h"

‎tests/src/core/testqgsrasterlayer.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545

4646
//qgis unit test includes
4747
#include <qgsrenderchecker.h>
48-
#include "qgstestutils.h"
4948

5049
/** \ingroup UnitTests
5150
* This is a unit test for the QgsRasterLayer class.

‎tests/src/core/testqgsrastersublayer.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939

4040
//qgis unit test includes
4141
#include <qgsrenderchecker.h>
42-
#include "qgstestutils.h"
4342

4443
/** \ingroup UnitTests
4544
* This is a unit test for raster sublayers

‎tests/src/core/testqgsstatisticalsummary.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
#include "qgsstatisticalsummary.h"
2222
#include "qgis.h"
23-
#include "qgstestutils.h"
2423

2524
class TestQgsStatisticSummary: public QObject
2625
{

‎tests/src/core/testqgstaskmanager.cpp

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@
2222
#include <QObject>
2323
#include "qgstest.h"
2424

25-
// some of these tests have intermittent failure on Travis, probably due
26-
// to inconsistent availability to multiple threads on the platform.
27-
// These tests are disabled unless WITH_FLAKY is 1.
28-
29-
#define WITH_FLAKY 0 //TODO - disable only for Travis?
30-
3125
class TestTask : public QgsTask
3226
{
3327
Q_OBJECT
@@ -200,15 +194,11 @@ class TestQgsTaskManager : public QObject
200194
void task();
201195
void taskResult();
202196
void taskFinished();
203-
#if WITH_FLAKY
204197
void subTask();
205-
#endif
206198
void addTask();
207199
void taskTerminationBeforeDelete();
208200
void taskId();
209-
#if WITH_FLAKY
210201
void waitForFinished();
211-
#endif
212202
void progressChanged();
213203
void statusChanged();
214204
void allTasksFinished();
@@ -442,9 +432,11 @@ void TestQgsTaskManager::taskFinished()
442432
QCOMPARE( *resultObtained, false );
443433
}
444434

445-
#if WITH_FLAKY
446435
void TestQgsTaskManager::subTask()
447436
{
437+
if ( QgsTest::isTravis() )
438+
QSKIP( "This test is disabled on Travis CI environment" );
439+
448440
QgsTaskManager manager;
449441

450442
// parent with one subtask
@@ -489,29 +481,29 @@ void TestQgsTaskManager::subTask()
489481
// test progress calculation
490482
QSignalSpy spy( parent, &QgsTask::progressChanged );
491483
parent->emitProgressChanged( 50 );
492-
QCOMPARE( std::round( parent->progress() ), 17 );
484+
QCOMPARE( std::round( parent->progress() ), 17.0 );
493485
//QCOMPARE( spy.count(), 1 );
494-
QCOMPARE( std::round( spy.last().at( 0 ).toDouble() ), 17 );
486+
QCOMPARE( std::round( spy.last().at( 0 ).toDouble() ), 17.0 );
495487

496488
subTask->emitProgressChanged( 100 );
497-
QCOMPARE( std::round( parent->progress() ), 50 );
489+
QCOMPARE( std::round( parent->progress() ), 50.0 );
498490
//QCOMPARE( spy.count(), 2 );
499-
QCOMPARE( std::round( spy.last().at( 0 ).toDouble() ), 50 );
491+
QCOMPARE( std::round( spy.last().at( 0 ).toDouble() ), 50.0 );
500492

501493
subTask2->finish();
502494
while ( subTask2->status() != QgsTask::Complete )
503495
{
504496
QCoreApplication::processEvents();
505497
}
506498
flushEvents();
507-
QCOMPARE( std::round( parent->progress() ), 83 );
499+
QCOMPARE( std::round( parent->progress() ), 83.0 );
508500
//QCOMPARE( spy.count(), 3 );
509-
QCOMPARE( std::round( spy.last().at( 0 ).toDouble() ), 83 );
501+
QCOMPARE( std::round( spy.last().at( 0 ).toDouble() ), 83.0 );
510502

511503
parent->emitProgressChanged( 100 );
512-
QCOMPARE( std::round( parent->progress() ), 100 );
504+
QCOMPARE( std::round( parent->progress() ), 100.0 );
513505
//QCOMPARE( spy.count(), 4 );
514-
QCOMPARE( std::round( spy.last().at( 0 ).toDouble() ), 100 );
506+
QCOMPARE( std::round( spy.last().at( 0 ).toDouble() ), 100.0 );
515507
parent->terminate();
516508
subTask->terminate();
517509

@@ -641,7 +633,6 @@ void TestQgsTaskManager::subTask()
641633
flushEvents();
642634
QVERIFY( parentFinished2.count() > 0 );
643635
}
644-
#endif
645636

646637
void TestQgsTaskManager::taskId()
647638
{
@@ -665,9 +656,11 @@ void TestQgsTaskManager::taskId()
665656
delete task3;
666657
}
667658

668-
#if WITH_FLAKY
669659
void TestQgsTaskManager::waitForFinished()
670660
{
661+
if ( QgsTest::isTravis() )
662+
QSKIP( "This test is disabled on Travis CI environment" );
663+
671664
QgsTaskManager manager;
672665
QEventLoop loop;
673666

@@ -705,7 +698,6 @@ void TestQgsTaskManager::waitForFinished()
705698
QCOMPARE( timeoutTooShortTask->waitForFinished( 20 ), false );
706699
QCOMPARE( timeoutTooShortTask->status(), QgsTask::Running );
707700
}
708-
#endif
709701

710702
void TestQgsTaskManager::progressChanged()
711703
{
@@ -1105,6 +1097,9 @@ void TestQgsTaskManager::layerDependencies()
11051097

11061098
void TestQgsTaskManager::managerWithSubTasks()
11071099
{
1100+
if ( QgsTest::isTravis() )
1101+
QSKIP( "This test is disabled on Travis CI environment" );
1102+
11081103
// parent with subtasks
11091104
ProgressReportingTask *parent = new ProgressReportingTask( "parent" );
11101105
ProgressReportingTask *subTask = new ProgressReportingTask( "subtask" );
@@ -1125,7 +1120,7 @@ void TestQgsTaskManager::managerWithSubTasks()
11251120
QCOMPARE( manager->activeTasks().count(), 1 );
11261121
QVERIFY( manager->activeTasks().contains( parent ) );
11271122
QCOMPARE( spy.count(), 1 );
1128-
#if WITH_FLAKY
1123+
11291124
//manager should not directly listen to progress reports from subtasks
11301125
//(only parent tasks, which themselves include their subtask progress)
11311126
QCOMPARE( spyProgress.count(), 0 );
@@ -1146,7 +1141,6 @@ void TestQgsTaskManager::managerWithSubTasks()
11461141
QCOMPARE( spyProgress.count(), 3 );
11471142
QCOMPARE( spyProgress.last().at( 0 ).toLongLong(), 0LL );
11481143
QCOMPARE( spyProgress.last().at( 1 ).toInt(), 63 );
1149-
#endif
11501144

11511145
//manager should not emit statusChanged signals for subtasks
11521146
QSignalSpy statusSpy( manager, &QgsTaskManager::statusChanged );

‎tests/src/core/testqgstracer.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
#include <qgsapplication.h>
1919
#include <qgsgeometry.h>
20-
#include <qgstestutils.h>
2120
#include <qgstracer.h>
2221
#include <qgsvectorlayer.h>
2322

‎tests/src/gui/testprojectionissues.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include "qgsrasterlayer.h"
2424
#include <QObject>
2525
#include "qgstest.h"
26-
#include "qgstestutils.h"
2726

2827
class TestProjectionIssues : public QObject
2928
{

‎tests/src/gui/testqgslayoutview.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include "qgslayoutitemregistry.h"
2424
#include "qgslayoutitemguiregistry.h"
2525
#include "qgslayoutitemwidget.h"
26-
#include "qgstestutils.h"
2726
#include "qgsproject.h"
2827
#include "qgsgui.h"
2928
#include <QtTest/QSignalSpy>

‎tests/src/gui/testqgsmapcanvas.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include <qgsrenderchecker.h>
2323
#include <qgsvectordataprovider.h>
2424
#include <qgsmaptoolpan.h>
25-
#include "qgstestutils.h"
2625

2726
namespace QTest
2827
{

‎tests/src/providers/testqgsgdalprovider.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include <qgsproviderregistry.h>
3030
#include <qgsrasterdataprovider.h>
3131
#include <qgsrectangle.h>
32-
#include "qgstestutils.h"
3332

3433
/** \ingroup UnitTests
3534
* This is a unit test for the gdal provider

0 commit comments

Comments
 (0)
Please sign in to comment.