-
-
Notifications
You must be signed in to change notification settings - Fork 449
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
Make tests more platform agnostic #4650
Make tests more platform agnostic #4650
Conversation
tests/src/InputCompletion.cpp
Outdated
ASSERT_EQ(completion[0].displayName, "FeelsBirthdayMan"); | ||
ASSERT_EQ(completion[1].displayName, "FeelsBadMan"); | ||
// all these matches are BTTV global emotes | ||
std::sort(completion.begin(), completion.end(), cmpCompletion); |
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.
I'm hesitant about this change - I'd rather leave this change out as part of the platform-agnostic PR & discuss it in a separate PR/issue.
Most likely I'd like to see us just change the EmoteMap to be consistently ordered instead
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.
I reverted the change, but added a note for future visitors.
Most likely I'd like to see us just change the EmoteMap to be consistently ordered instead
Not sure if it's that easy. It should probably be benchmarked to see if it makes a meaningful difference, since working with emotes and checking for emotes in a word is an integral part.
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.
clang-tidy made some suggestions
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.
Looks good, thank you!
One step closer to running tests on all platforms
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.
clang-tidy made some suggestions
@@ -66,7 +67,8 @@ class MockApplication : mock::EmptyApplication | |||
static void BM_HighlightTest(benchmark::State &state) | |||
{ | |||
MockApplication mockApplication; | |||
Settings settings("/tmp/c2-mock"); | |||
QTemporaryDir settingsDir; | |||
Settings settings(settingsDir.path()); |
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.
warning: variable 'settings' of type 'chatterino::Settings' can be declared 'const' [misc-const-correctness]
Settings settings(settingsDir.path()); | |
Settings const settings(settingsDir.path()); |
QTemporaryDir settingsDir; | ||
settingsDir.setAutoRemove(false); // we'll remove it manually | ||
qDebug() << "Settings directory:" << settingsDir.path(); | ||
chatterino::Settings settings(settingsDir.path()); |
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.
warning: variable 'settings' of type 'chatterino::Settings' can be declared 'const' [misc-const-correctness]
chatterino::Settings settings(settingsDir.path()); | |
chatterino::Settings const settings(settingsDir.path()); |
Description
/tmp
directory the same way, e.g. Linux has it. So instead, the tests are now usingQTemporaryDir
- which is cross-platform.CHATTERINO_TEST_LOCAL_HTTPBIN=Off
).std::unordered_map
than the one used when writing the input completion tests. Sinceunordered_map
doesn't guarantee an ordering (the name explicitly saysunordered
), one can't rely on values being in order in such a map. This map is the underlying data-type for anEmoteMap
. For the input completions, this is a bit more tricky, since they do guarantee some amount of ordering (regarding the emote/emoji provider). So, for an emote provider, the completions are now sorted.Now, the only program one needs to run next to the tests is the PubSub test-server.
Note: The tests will still fail when using Qt 6 (which is still marked as experimental and thus not tested). I'll make another PR to fix that and add tests there.