Skip to content

Commit

Permalink
Skip unsafe tests on GitHhub Action's macOS 14 runners
Browse files Browse the repository at this point in the history
  • Loading branch information
pcolby committed Apr 23, 2024
1 parent 9679720 commit 3a65f33
Show file tree
Hide file tree
Showing 13 changed files with 84 additions and 2 deletions.
2 changes: 1 addition & 1 deletion test/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
find_package(Qt${QT_VERSION_MAJOR}Test REQUIRED)

function(add_dokit_unit_test name)
add_executable(test${name} ${ARGN})
add_executable(test${name} ${ARGN} ../github.h)

target_include_directories(test${name} PRIVATE ${CMAKE_SOURCE_DIR}/src/lib)

Expand Down
7 changes: 6 additions & 1 deletion test/unit/cli/testdevicecommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: LGPL-3.0-or-later

#include "testdevicecommand.h"
#include "../github.h"

#include "devicecommand.h"

Expand Down Expand Up @@ -32,7 +33,7 @@ class MockDeviceCommand : public DeviceCommand
};

// Mock device command class that does nothing (but log) if real devices are actually discovered. That is, if testing
// while real (physical) Pokit devices are withing BLE range. This never happes in CI environments of course.
// while real (physical) Pokit devices are within BLE range. This never happes in CI environments of course.
class StartableDeviceCommand : public MockDeviceCommand
{
protected slots:
Expand All @@ -44,6 +45,10 @@ protected slots:

void TestDeviceCommand::start()
{
if (gitHubActionsRunnerOsVersion() >= QOperatingSystemVersion(QOperatingSystemVersion::MacOS, 14)) {
QSKIP("BLE controller operations hang on GitHub Actions's macOS 14 runners");
}

StartableDeviceCommand command;

QVERIFY(command.deviceToScanFor.isNull());
Expand Down
5 changes: 5 additions & 0 deletions test/unit/cli/testdsocommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "testdsocommand.h"
#include "outputstreamcapture.h"
#include "testdata.h"
#include "../github.h"

#include "dsocommand.h"

Expand Down Expand Up @@ -367,6 +368,10 @@ void TestDsoCommand::processOptions_data()

void TestDsoCommand::processOptions()
{
if (gitHubActionsRunnerOsVersion() >= QOperatingSystemVersion(QOperatingSystemVersion::MacOS, 14)) {
QSKIP("BLE controller operations hang on GitHub Actions's macOS 14 runners");
}

QFETCH(QStringList, arguments);
QFETCH(DsoService::Settings, expectedSettings);
QFETCH(minRangeFunc, expectedMinRangeFunc);
Expand Down
5 changes: 5 additions & 0 deletions test/unit/cli/testinfocommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "testinfocommand.h"
#include "outputstreamcapture.h"
#include "testdata.h"
#include "../github.h"

#include "infocommand.h"

Expand Down Expand Up @@ -87,6 +88,10 @@ void TestInfoCommand::serviceDetailsDiscovered_data()

void TestInfoCommand::serviceDetailsDiscovered()
{
if (gitHubActionsRunnerOsVersion() >= QOperatingSystemVersion(QOperatingSystemVersion::MacOS, 14)) {
QSKIP("BLE controller operations hang on GitHub Actions's macOS 14 runners");
}

QFETCH(QBluetoothDeviceInfo, info);
QFETCH(AbstractCommand::OutputFormat, format);
LOADTESTDATA(expected);
Expand Down
5 changes: 5 additions & 0 deletions test/unit/cli/testloggerfetchcommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "testloggerfetchcommand.h"
#include "outputstreamcapture.h"
#include "testdata.h"
#include "../github.h"

#include "loggerfetchcommand.h"

Expand Down Expand Up @@ -95,6 +96,10 @@ void TestLoggerFetchCommand::outputSamples_data()

void TestLoggerFetchCommand::outputSamples()
{
if (gitHubActionsRunnerOsVersion() >= QOperatingSystemVersion(QOperatingSystemVersion::MacOS, 14)) {
QSKIP("BLE controller operations hang on GitHub Actions's macOS 14 runners");
}

QFETCH(DataLoggerService::Metadata, metadata);
QFETCH(QList<DataLoggerService::Samples>, samplesList);
QFETCH(AbstractCommand::OutputFormat, format);
Expand Down
5 changes: 5 additions & 0 deletions test/unit/cli/testmetercommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "testmetercommand.h"
#include "outputstreamcapture.h"
#include "testdata.h"
#include "../github.h"

#include "metercommand.h"

Expand Down Expand Up @@ -406,6 +407,10 @@ void TestMeterCommand::outputReading_data()

void TestMeterCommand::outputReading()
{
if (gitHubActionsRunnerOsVersion() >= QOperatingSystemVersion(QOperatingSystemVersion::MacOS, 14)) {
QSKIP("BLE controller operations hang on GitHub Actions's macOS 14 runners");
}

QFETCH(QList<MultimeterService::Reading>, readings);
QFETCH(AbstractCommand::OutputFormat, format);
LOADTESTDATA(expected);
Expand Down
5 changes: 5 additions & 0 deletions test/unit/cli/testscancommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "testscancommand.h"
#include "outputstreamcapture.h"
#include "testdata.h"
#include "../github.h"

#include "scancommand.h"

Expand Down Expand Up @@ -70,6 +71,10 @@ void TestScanCommand::processOptions()

void TestScanCommand::start()
{
if (gitHubActionsRunnerOsVersion() >= QOperatingSystemVersion(QOperatingSystemVersion::MacOS, 14)) {
QSKIP("BLE controller operations hang on GitHub Actions's macOS 14 runners");
}

ScanCommand command(this);
QTest::ignoreMessage(QtInfoMsg, "Scanning for Pokit devices...");
command.start();
Expand Down
5 changes: 5 additions & 0 deletions test/unit/cli/teststatuscommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "teststatuscommand.h"
#include "outputstreamcapture.h"
#include "testdata.h"
#include "../github.h"

#include "statuscommand.h"

Expand Down Expand Up @@ -58,6 +59,10 @@ void TestStatusCommand::getService()

void TestStatusCommand::serviceDetailsDiscovered()
{
if (gitHubActionsRunnerOsVersion() >= QOperatingSystemVersion(QOperatingSystemVersion::MacOS, 14)) {
QSKIP("BLE controller operations hang on GitHub Actions's macOS 14 runners");
}

StatusCommand command(this);
command.device = new PokitDevice(QBluetoothDeviceInfo(), &command);
command.service = command.device->status();
Expand Down
27 changes: 27 additions & 0 deletions test/unit/github.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-FileCopyrightText: 2022-2024 Paul Colby <[email protected]>
// SPDX-License-Identifier: LGPL-3.0-or-later

#ifndef DOKIT_TESTS_GITHUB_H
#define DOKIT_TESTS_GITHUB_H

#include <QOperatingSystemVersion>

/*!
* Returns \c true if the application is executing on a GitHub Actions runner, \c false otherwise.
*/
inline bool isGitHubActionsRunner()
{
return qgetenv("GITHUB_ACTIONS") == "true";
}

/*!
* Returns the host operating system's version information if executing on a GitHub Actions runners, otherwise
* a QOperatingSystemVersion::Unknown version.
*/
inline QOperatingSystemVersion gitHubActionsRunnerOsVersion()
{
return isGitHubActionsRunner() ? QOperatingSystemVersion::current()
: QOperatingSystemVersion(QOperatingSystemVersion::Unknown, -1);
}

#endif // DOKIT_TESTS_GITHUB_H
5 changes: 5 additions & 0 deletions test/unit/lib/testabstractpokitservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: LGPL-3.0-or-later

#include "testabstractpokitservice.h"
#include "../github.h"

#include <qtpokit/abstractpokitservice.h>
#include "abstractpokitservice_p.h"
Expand Down Expand Up @@ -63,6 +64,10 @@ void TestAbstractPokitService::service_()

void TestAbstractPokitService::createServiceObject()
{
if (gitHubActionsRunnerOsVersion() >= QOperatingSystemVersion(QOperatingSystemVersion::MacOS, 14)) {
QSKIP("BLE controller operations hang on GitHub Actions's macOS 14 runners");
}

// Verify that creation will fail without a Bluetooth device controller
MockPokitService service(nullptr);
QCOMPARE(service.service(), nullptr);
Expand Down
5 changes: 5 additions & 0 deletions test/unit/lib/testcalibrationservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: LGPL-3.0-or-later

#include "testcalibrationservice.h"
#include "../github.h"

#include <qtpokit/calibrationservice.h>
#include "calibrationservice_p.h"
Expand All @@ -11,6 +12,10 @@

void TestCalibrationService::readCharacteristics()
{
if (gitHubActionsRunnerOsVersion() >= QOperatingSystemVersion(QOperatingSystemVersion::MacOS, 14)) {
QSKIP("BLE controller operations hang on GitHub Actions's macOS 14 runners");
}

// readCharacteristics always returns true, since the service has no readable characterstics.
CalibrationService service(QLowEnergyController::createCentral(QBluetoothDeviceInfo()));
QVERIFY(service.readCharacteristics());
Expand Down
5 changes: 5 additions & 0 deletions test/unit/lib/testpokitdevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: LGPL-3.0-or-later

#include "testpokitdevice.h"
#include "../github.h"

#include <qtpokit/pokitdevice.h>
#include "pokitdevice_p.h"
Expand Down Expand Up @@ -176,6 +177,10 @@ void TestPokitDevice::charcteristicToString()

void TestPokitDevice::setController()
{
if (gitHubActionsRunnerOsVersion() >= QOperatingSystemVersion(QOperatingSystemVersion::MacOS, 14)) {
QSKIP("BLE controller operations hang on GitHub Actions's macOS 14 runners");
}

// Verify safe error handling (can't do much else without a Bluetooth device).
PokitDevice device(nullptr);
QCOMPARE(device.controller(), nullptr);
Expand Down
5 changes: 5 additions & 0 deletions test/unit/lib/testpokitproducts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: LGPL-3.0-or-later

#include "testpokitproducts.h"
#include "../github.h"

#include "pokitproducts_p.h"

Expand Down Expand Up @@ -117,6 +118,10 @@ void TestPokitProducts::isPokitProduct_Controller_data()

void TestPokitProducts::isPokitProduct_Controller()
{
if (gitHubActionsRunnerOsVersion() >= QOperatingSystemVersion(QOperatingSystemVersion::MacOS, 14)) {
QSKIP("BLE controller operations hang on GitHub Actions's macOS 14 runners");
}

QFETCH(QBluetoothUuid, uuid);
QFETCH(bool, expected);

Expand Down

0 comments on commit 3a65f33

Please sign in to comment.