Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor tests and benchmarks #4700

Merged
merged 10 commits into from
Jun 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:

env:
TWITCH_PUBSUB_SERVER_IMAGE: ghcr.io/chatterino/twitch-pubsub-server-test:v1.0.6
QT_QPA_PLATFORM: minimal

concurrency:
group: test-${{ github.ref }}
Expand Down Expand Up @@ -74,7 +75,7 @@ jobs:
if: startsWith(matrix.os, 'ubuntu')
run: |
cmake -DBUILD_TESTS=On -DBUILD_APP=OFF ..
cmake --build . --config Release
cmake --build .
working-directory: build-test
shell: bash

Expand All @@ -85,6 +86,6 @@ jobs:
docker pull ${{ env.TWITCH_PUBSUB_SERVER_IMAGE }}
docker run --network=host --detach ${{ env.TWITCH_PUBSUB_SERVER_IMAGE }}
docker run -p 9051:80 --detach kennethreitz/httpbin
./bin/chatterino-test --platform minimal || ./bin/chatterino-test --platform minimal || ./bin/chatterino-test --platform minimal
./bin/chatterino-test || ./bin/chatterino-test || ./bin/chatterino-test
working-directory: build-test
shell: bash
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- Dev: Added support for compiling with `sccache`. (#4678)
- Dev: Added `sccache` in Windows CI. (#4678)
- Dev: Moved preprocessor Git and date definitions to executables only. (#4681)
- Dev: Refactored tests to be able to use `ctest` and run in debug builds. (#4700)

## 2.4.4

Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ find_package(RapidJSON REQUIRED)
find_package(Websocketpp REQUIRED)

if (BUILD_TESTS)
include(GoogleTest)
# For MSVC: Prevent overriding the parent project's compiler/linker settings
# See https://github.com/google/googletest/blob/main/googletest/README.md#visual-studio-dynamic-vs-static-runtimes
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ int main(int argc, char **argv)
settingsDir.setAutoRemove(false); // we'll remove it manually
chatterino::Settings settings(settingsDir.path());

QtConcurrent::run([&app, &settingsDir]() mutable {
QTimer::singleShot(0, [&]() {
::benchmark::RunSpecifiedBenchmarks();

settingsDir.remove();
app.exit(0);
QApplication::exit(0);
});

return app.exec();
return QApplication::exec();
}
4 changes: 2 additions & 2 deletions src/messages/Image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,8 +595,8 @@ ImageExpirationPool::ImageExpirationPool()

ImageExpirationPool &ImageExpirationPool::instance()
{
static ImageExpirationPool instance;
return instance;
static auto *instance = new ImageExpirationPool;
pajlada marked this conversation as resolved.
Show resolved Hide resolved
return *instance;
}

void ImageExpirationPool::addImagePtr(ImagePtr imgPtr)
Expand Down
8 changes: 1 addition & 7 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,4 @@ if(CHATTERINO_TEST_USE_PUBLIC_HTTPBIN)
target_compile_definitions(${PROJECT_NAME} PRIVATE CHATTERINO_TEST_USE_PUBLIC_HTTPBIN)
endif()

# gtest_add_tests manages to discover the tests because it looks through the source files
# HOWEVER, it fails to run, because we have some bug that causes the QApplication exit to stall when no network requests have been made.
# ctest runs each test individually, so for now we require that testers just run the ./bin/chatterino-test binary without any filters applied
# gtest_add_tests(
# TARGET ${PROJECT_NAME}
# SOURCES ${test_SOURCES}
# )
gtest_discover_tests(${PROJECT_NAME})
Loading