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

feat(tests): rework tests in numerous ways #3059

Merged
merged 2 commits into from
Aug 22, 2024

Conversation

ns6089
Copy link
Contributor

@ns6089 ns6089 commented Aug 21, 2024

Description

Architectural

  • removed BaseTest class and TEST() redefinition, tests don't need to derive from it from now on
  • replaced PlatformInitBase that inherited from BaseTest with lightweight PlatformTestSuite, platform initialization/deinitialization is done in static methods SetUpTestSuite()/TearDownTestSuite() and doesn't interfere with fixture initialization
  • switched to our own main() entry point from gtest_main

Logging

  • logging is now initialized in gtest environment
  • all tests are now expected to use BOOST_LOG
  • resulting test_sunshine.log can be uploaded as github actions artifact in CI
  • this log is shared with normal sunshine outputs
  • each test start/result is now printed to the log, automatically through gtest event listener
  • each failed test will also print the relevant portion of the log into stdout, implemented as additional stringstream boost log sink in gtest event listener
  • added new log level tests hidden behind SUNSHINE_TESTS compile definition
  • now sunshine doesn't add stdout boost log sink if it's compiled with SUNSHINE_TESTS
  • migrated all tests' cout messages to BOOST_LOG(tests)

Cosmetics

  • replaced ::testing namespace with testing, safeguarding against conflicts is pointless when we should not introduce them in the first place
  • replaced all instances of class with struct and dropped all access specifiers, here such access specifiers only add noise
  • switched parameterized test names from 0,1,2... to custom names where it was applicable

Screenshot

Issues Fixed or Closed

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Dependency update (updates to dependencies)
  • Documentation update (changes to documentation)
  • Repository update (changes to repository files, e.g. .github/...)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated the in code docstring/documentation-blocks for new or existing methods/components

Copy link

codecov bot commented Aug 21, 2024

Codecov Report

Attention: Patch coverage is 94.59459% with 2 lines in your changes missing coverage. Please review.

Project coverage is 7.15%. Comparing base (3088823) to head (0239325).
Report is 1 commits behind head on master.

Files Patch % Lines
src/logging.cpp 94.59% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##           master   #3059      +/-   ##
=========================================
- Coverage    7.25%   7.15%   -0.10%     
=========================================
  Files          91      91              
  Lines       16464   16464              
  Branches     7785    7780       -5     
=========================================
- Hits         1194    1178      -16     
- Misses      12672   12687      +15     
- Partials     2598    2599       +1     
Flag Coverage Δ
Linux 7.17% <91.66%> (-0.15%) ⬇️
Windows 4.96% <94.59%> (-0.11%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
src/audio.h 100.00% <ø> (+100.00%) ⬆️
src/logging.h 30.30% <ø> (ø)
src/logging.cpp 61.38% <94.59%> (-16.84%) ⬇️

@ns6089
Copy link
Contributor Author

ns6089 commented Aug 21, 2024

Added test run details to the log

[2024-08-21 20:19:20.181]: Tests: From C:/Code/ns6089/sunshine a/tests/unit/test_mouse.cpp:37
[2024-08-21 20:19:20.181]: Tests:   MouseInputs/MouseHIDTest/MoveInputTest/0 started
[2024-08-21 20:19:20.388]: Tests: At C:/Code/ns6089/sunshine a/tests/unit/test_mouse.cpp:16
[2024-08-21 20:19:20.388]: Tests:   Skip: TODO Windows
[2024-08-21 20:19:20.388]: Tests: MouseInputs/MouseHIDTest/MoveInputTest/0 skipped

Maybe not the best formatting, but it's fairly easy to change afterwards.

@ns6089
Copy link
Contributor Author

ns6089 commented Aug 22, 2024

Everything is done from my end, if anyone has some issues with particular parts of the PR I can revert them.

src/audio.h Show resolved Hide resolved
tests/tests_common.h Outdated Show resolved Hide resolved
@FrogTheFrog
Copy link
Collaborator

LGTM

@ns6089
Copy link
Contributor Author

ns6089 commented Aug 22, 2024

@FrogTheFrog here you go b20d022, one more LGTM please 🐸

@FrogTheFrog
Copy link
Collaborator

LGTM 🐸

Copy link

sonarcloud bot commented Aug 22, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot

See analysis details on SonarCloud

@ReenigneArcher ReenigneArcher merged commit 764ce03 into LizardByte:master Aug 22, 2024
44 of 49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants