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

Add a test suite for Translation #48778

Merged
merged 1 commit into from
May 17, 2021

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented May 17, 2021

See #43440.

@Calinou Calinou requested a review from a team as a code owner May 17, 2021 00:02
@Calinou Calinou added this to the 4.0 milestone May 17, 2021
@akien-mga akien-mga merged commit 75622da into godotengine:master May 17, 2021
@akien-mga
Copy link
Member

Thanks!

@akien-mga
Copy link
Member

So this passed CI in the PR, but not once merged? We seem to have a bug in our unit testing.

 D:\a\godot\godot\tests\test_translation.h(42):
TEST CASE:  [Translation] Messages

D:\a\godot\godot\tests\test_translation.h(63): ERROR: CHECK( messages[0] == "Hello2" ) is NOT correct!
  values: CHECK( @"Hello3" == Hello2 )

D:\a\godot\godot\tests\test_translation.h(64): ERROR: CHECK( messages[1] == "Hello3" ) is NOT correct!
  values: CHECK( @"Hello2" == Hello3 )

@akien-mga
Copy link
Member

I could reproduce the issue once locally, but not on subsequent builds. I suspect that SCons doesn't properly pick up new .h files so we get some invalid state somehow.

@akien-mga
Copy link
Member

Yeah re-running the CI solved it... we'll have to figure this one out eventually.

@kleonc
Copy link
Member

kleonc commented May 17, 2021

@akien-mga I think the issue is that this part of the test:

translation->add_message("Hello2", "Bonjour2");
translation->add_message("Hello3", "Bonjour3");
messages.clear();
translation->get_message_list(&messages);
CHECK(translation->get_message_count() == 2);
CHECK(messages.size() == 2);
CHECK(messages[0] == "Hello2");
CHECK(messages[1] == "Hello3");

assumes that Translation preserves insertion order of the messages (and that get_message_list() returns messages in the same order) but it's not the case since Map is used internally as a storage:
Map<StringName, StringName> translation_map;

@akien-mga
Copy link
Member

Good catch! I guess the test should be changed to use find() or similar?

@kleonc
Copy link
Member

kleonc commented May 17, 2021

Yeah, size check and messages.has(...) for each entry should be sufficient.

akien-mga added a commit to akien-mga/godot that referenced this pull request May 17, 2021
This lead to randomly failing the test as the insertion order is not
preserved by Map.

Follow-up to godotengine#48778.

Co-authored-by: kleonc <[email protected]>
@Calinou Calinou deleted the test-add-translation branch August 3, 2021 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants