From 3a65f33779210be44dc4fef751d0baf9f5b77ef4 Mon Sep 17 00:00:00 2001 From: Paul Colby Date: Tue, 23 Apr 2024 21:36:02 +1000 Subject: [PATCH] Skip unsafe tests on GitHhub Action's macOS 14 runners --- test/unit/CMakeLists.txt | 2 +- test/unit/cli/testdevicecommand.cpp | 7 +++++- test/unit/cli/testdsocommand.cpp | 5 ++++ test/unit/cli/testinfocommand.cpp | 5 ++++ test/unit/cli/testloggerfetchcommand.cpp | 5 ++++ test/unit/cli/testmetercommand.cpp | 5 ++++ test/unit/cli/testscancommand.cpp | 5 ++++ test/unit/cli/teststatuscommand.cpp | 5 ++++ test/unit/github.h | 27 ++++++++++++++++++++++ test/unit/lib/testabstractpokitservice.cpp | 5 ++++ test/unit/lib/testcalibrationservice.cpp | 5 ++++ test/unit/lib/testpokitdevice.cpp | 5 ++++ test/unit/lib/testpokitproducts.cpp | 5 ++++ 13 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 test/unit/github.h diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index ccf43c5f3..ccc64333c 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -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) diff --git a/test/unit/cli/testdevicecommand.cpp b/test/unit/cli/testdevicecommand.cpp index 5df9df835..048f68a9b 100644 --- a/test/unit/cli/testdevicecommand.cpp +++ b/test/unit/cli/testdevicecommand.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include "testdevicecommand.h" +#include "../github.h" #include "devicecommand.h" @@ -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: @@ -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()); diff --git a/test/unit/cli/testdsocommand.cpp b/test/unit/cli/testdsocommand.cpp index cd2eb78e8..da958d7ff 100644 --- a/test/unit/cli/testdsocommand.cpp +++ b/test/unit/cli/testdsocommand.cpp @@ -4,6 +4,7 @@ #include "testdsocommand.h" #include "outputstreamcapture.h" #include "testdata.h" +#include "../github.h" #include "dsocommand.h" @@ -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); diff --git a/test/unit/cli/testinfocommand.cpp b/test/unit/cli/testinfocommand.cpp index c59e421e5..44b18662c 100644 --- a/test/unit/cli/testinfocommand.cpp +++ b/test/unit/cli/testinfocommand.cpp @@ -4,6 +4,7 @@ #include "testinfocommand.h" #include "outputstreamcapture.h" #include "testdata.h" +#include "../github.h" #include "infocommand.h" @@ -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); diff --git a/test/unit/cli/testloggerfetchcommand.cpp b/test/unit/cli/testloggerfetchcommand.cpp index 6371922b6..9d9627dbb 100644 --- a/test/unit/cli/testloggerfetchcommand.cpp +++ b/test/unit/cli/testloggerfetchcommand.cpp @@ -4,6 +4,7 @@ #include "testloggerfetchcommand.h" #include "outputstreamcapture.h" #include "testdata.h" +#include "../github.h" #include "loggerfetchcommand.h" @@ -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, samplesList); QFETCH(AbstractCommand::OutputFormat, format); diff --git a/test/unit/cli/testmetercommand.cpp b/test/unit/cli/testmetercommand.cpp index a79f68558..698d21f9a 100644 --- a/test/unit/cli/testmetercommand.cpp +++ b/test/unit/cli/testmetercommand.cpp @@ -4,6 +4,7 @@ #include "testmetercommand.h" #include "outputstreamcapture.h" #include "testdata.h" +#include "../github.h" #include "metercommand.h" @@ -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, readings); QFETCH(AbstractCommand::OutputFormat, format); LOADTESTDATA(expected); diff --git a/test/unit/cli/testscancommand.cpp b/test/unit/cli/testscancommand.cpp index 1f0a58472..f1ffd902a 100644 --- a/test/unit/cli/testscancommand.cpp +++ b/test/unit/cli/testscancommand.cpp @@ -4,6 +4,7 @@ #include "testscancommand.h" #include "outputstreamcapture.h" #include "testdata.h" +#include "../github.h" #include "scancommand.h" @@ -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(); diff --git a/test/unit/cli/teststatuscommand.cpp b/test/unit/cli/teststatuscommand.cpp index b418875da..6792cdbb9 100644 --- a/test/unit/cli/teststatuscommand.cpp +++ b/test/unit/cli/teststatuscommand.cpp @@ -4,6 +4,7 @@ #include "teststatuscommand.h" #include "outputstreamcapture.h" #include "testdata.h" +#include "../github.h" #include "statuscommand.h" @@ -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(); diff --git a/test/unit/github.h b/test/unit/github.h new file mode 100644 index 000000000..3216513c2 --- /dev/null +++ b/test/unit/github.h @@ -0,0 +1,27 @@ +// SPDX-FileCopyrightText: 2022-2024 Paul Colby +// SPDX-License-Identifier: LGPL-3.0-or-later + +#ifndef DOKIT_TESTS_GITHUB_H +#define DOKIT_TESTS_GITHUB_H + +#include + +/*! + * 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 diff --git a/test/unit/lib/testabstractpokitservice.cpp b/test/unit/lib/testabstractpokitservice.cpp index c8e0134e1..b86ecf3e3 100644 --- a/test/unit/lib/testabstractpokitservice.cpp +++ b/test/unit/lib/testabstractpokitservice.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include "testabstractpokitservice.h" +#include "../github.h" #include #include "abstractpokitservice_p.h" @@ -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); diff --git a/test/unit/lib/testcalibrationservice.cpp b/test/unit/lib/testcalibrationservice.cpp index c68283a9c..ed2178766 100644 --- a/test/unit/lib/testcalibrationservice.cpp +++ b/test/unit/lib/testcalibrationservice.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include "testcalibrationservice.h" +#include "../github.h" #include #include "calibrationservice_p.h" @@ -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()); diff --git a/test/unit/lib/testpokitdevice.cpp b/test/unit/lib/testpokitdevice.cpp index f7c5f44c3..14ace1e9d 100644 --- a/test/unit/lib/testpokitdevice.cpp +++ b/test/unit/lib/testpokitdevice.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include "testpokitdevice.h" +#include "../github.h" #include #include "pokitdevice_p.h" @@ -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); diff --git a/test/unit/lib/testpokitproducts.cpp b/test/unit/lib/testpokitproducts.cpp index 8d69e9e48..226eeb05f 100644 --- a/test/unit/lib/testpokitproducts.cpp +++ b/test/unit/lib/testpokitproducts.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include "testpokitproducts.h" +#include "../github.h" #include "pokitproducts_p.h" @@ -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);