-
Notifications
You must be signed in to change notification settings - Fork 20
[Not for merging] Fixes for library unit tests with gtest #292
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
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Gazizonoki
reviewed
Aug 21, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Замена инклюдов
#include <library/cpp/testing/gtest/gtest.h>
. Это мы будем делать при импорте library/cpp, так что с этим нет проблем - Тест yt
saveload_ut
. Вернем gtest_extensions, заведи issue - Тест yt
erased_storage_ut
. Вернем int128, заведи issue - Недостающие хедеры и баг с пустым std::initializer_list. Это я донесу к нам внутрь
d03c717
to
d53616a
Compare
В SDK мы будем убирать library/cpp и util, так что нет смысла закапывать силы в тесты для них, все труды все равно потом пропадут. Ветку пока оставлю, на всякий случай |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Часть коммитов здесь затрагивает только CMake файлы, а самые последние коммиты – это с изменениями в
library
– скорее иллюстрация, как я предлагаю решить проблему. Перед финальным мёржем эти изменения собираюсь откатить.Здесь все юнит-тесты из
library
, которые зависят отlibrary/cpp/testing/gtest
, а именно:Я видел, что в тестах для
library/cpp/coroutine/engine/stack
эту зависимость поменяли: и теперь те юнит-тесты зависят напрямую от гугл-тест библиотеки, без прослойкиlibrary/cpp/testing/gtest
. Здесь я предлагаю поступить так же, заменив инклюды#include <library/cpp/testing/gtest/gtest.h>
на#include <gtest/gtest.h>
и, где необходимо,#include <gmock/gmock.h>
. Если неприемлемо, тогда нужно вернутьlibrary/cpp/testing/gtest
иlibrary/cpp/testing/gtest_main
.Теперь к другим деталям:
library/cpp/testing/gtest
.erased_storage_ut
, потому что он требует недостающей библиотекиlibrary/cpp/int128
. Её нужно либо притащить, либо через макросы убрать часть тестов.saveload_ut
, потому что он требует недостающей библиотекиlibrary/cpp/testing/gtest_extensions
. У него только зависимость от макросаEXPECT_THROW_MESSAGE_HAS_SUBSTR
. Наверное, лучше притащить эту либу, если не хотим переписывать тесты. Была ещё пара юнит тестов (раз и два), в которых были инклюды хедера из этой либы, но макросы из хедера не использовались, поэтому я эти инклюды убрал.library/cpp/yt/string/unittests/enum_ut.cpp
, а именно,TFormatTest::Enum
. Там просто тестировалась формат-функция, но в процессеTString
присваивался пустойstd::initializer_list
, всё это попадало вstd::string::assign(const char*, size_t)
, где уже грохалось в попытке разыменоватьnullptr
. Кажется, что это приколы исключительноlibstdc++
, потому что, как мне представляется,[nullptr, nullptr)
– это вполне себе валидный диапазон, и единственное требование из стандарта кassign
, чтобы он принимал валидный диапазон. Так или иначе, в library/cpp/yt/string/format-inl.h я заменил присваивание инишиалайзер листа на пустую строку, чтобы уж точно всё работало.