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

Fix unit tests to run on non-english devices #289

Merged
merged 5 commits into from
May 14, 2019
Merged

Fix unit tests to run on non-english devices #289

merged 5 commits into from
May 14, 2019

Conversation

rudyhuyn
Copy link
Contributor

Fixes #272

image

Description of the changes:

  • add a parameter to the CurrencyDataLoader constructor to override the locale
  • add a method LocalizationService::OverrideWithLanguage to force LocalizationService to override the current locale (some static methods were converted to const instance methods in order to take into account the new locale)
  • Use them to force unit tests to run with en-US

How changes were validated:

@HowardWolosky HowardWolosky added No Behavior Change codebase quality Issues that are not bugs, but still might be worth improving (eg, code hygiene or maintainability) labels Mar 21, 2019
@HowardWolosky
Copy link
Member

Locking the PR since the associated Issue isn't approved yet. That way conversation on the problem being addressed is discussed in the Issue, so that future PR discussion can be limited to the implementation of the fix.

@microsoft microsoft locked and limited conversation to collaborators Mar 25, 2019
@HowardWolosky HowardWolosky added Locked Until Issue Approved tooling Work that primarily impacts the yaml or administration of the GitHub project itself. and removed No Behavior Change codebase quality Issues that are not bugs, but still might be worth improving (eg, code hygiene or maintainability) labels Mar 25, 2019
@microsoft microsoft unlocked this conversation May 7, 2019
@mcooley
Copy link
Member

mcooley commented May 7, 2019

Oops, looks like the issue was approved but the PR was left locked. Sorry about that.

@sanderl
Copy link
Contributor

sanderl commented May 8, 2019

Hi Rudy, I looked at your change and it looks good to me. I think the test hook works well to allow the tests to run on other languages. We just need this branch to be updated to take in the latest changes from master. Thanks!

Copy link
Contributor

@sanderl sanderl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the branch with the latest from master.

@rudyhuyn
Copy link
Contributor Author

rudyhuyn commented May 8, 2019

Please update the branch with the latest from master.

I will tonight!

@sanderl
Copy link
Contributor

sanderl commented May 10, 2019

The CI build is failing on release builds. I was able to repro this locally as well. I did see that it is not failing on debug. It looks like it is related to the LocalizationService constructor. This thread might be relevant: https://social.msdn.microsoft.com/Forums/vstudio/en-US/7e5773ae-018d-4fb9-8a15-6edef9ce41be/weird-error-on-release-build.

It is interesting that we are hitting an internal compiler error, we are following up with the compiler team.

@rudyhuyn
Copy link
Contributor Author

I can update the diff and add an explicit parameter-less constructor if you want

@sanderl
Copy link
Contributor

sanderl commented May 10, 2019

I can update the diff and add an explicit parameter-less constructor if you want

I tried adding the default constructor explicitly on my local build and there were more build issues related to the LocalizationService constructor (I don't have access to my build right now to see exactly what the errors are). I haven't had a chance to work through them.

Daniel Belcher recommended trying to turn off optimization for that section of code. I haven't tried it, so I don't know if it fixes the problem.

I already sent the email to the compiler team, so I am hoping to hear something soon.

@rudyhuyn
Copy link
Contributor Author

I would be very interested to know the reason of this issue!

recommended trying to turn off optimization for that section of code. I haven't tried it, so I don't know if it fixes the problem.

I would prefer to keep the optimization but instead refactor a little the code. Because the constructor is private, we can remove the default argument for overridedLanguage and explicitly pass nullptr in the code.

Tested in Release mode, including unit tests

@sanderl
Copy link
Contributor

sanderl commented May 13, 2019

I would be very interested to know the reason of this issue!

The response I got from my email is that changing the constructor to have the optional parameter is not an ABI compatible change. The issue is that existing code referencing the 0 parameter constructor will not work. He said that default arguments work by copying the default argument to each call site, so any existing call sites built on old metadata or old headers will not work.

@rudyhuyn
Copy link
Contributor Author

I would be very interested to know the reason of this issue!

The response I got from my email is that changing the constructor to have the optional parameter is not an ABI compatible change. The issue is that existing code referencing the 0 parameter constructor will not work. He said that default arguments work by copying the default argument to each call site, so any existing call sites built on old metadata or old headers will not work.

Sorry, my question was about "I tried adding the default constructor explicitly on my local build and there were more build issues related to the LocalizationService constructor". I tried myself and faced the same errors than you. It's pretty clear that ABI will have an issue with default parameters, but it doesn't really explain why we weren't able to use 2 constructors

@sanderl
Copy link
Contributor

sanderl commented May 14, 2019

I would be very interested to know the reason of this issue!

The response I got from my email is that changing the constructor to have the optional parameter is not an ABI compatible change. The issue is that existing code referencing the 0 parameter constructor will not work. He said that default arguments work by copying the default argument to each call site, so any existing call sites built on old metadata or old headers will not work.

Sorry, my question was about "I tried adding the default constructor explicitly on my local build and there were more build issues related to the LocalizationService constructor". I tried myself and faced the same errors than you. It's pretty clear that ABI will have an issue with default parameters, but it doesn't really explain why we weren't able to use 2 constructors

I was just told there was probably something with the metadata.

@sanderl sanderl merged commit 9f47fe3 into microsoft:master May 14, 2019
EriWong pushed a commit to EriWong/calculator that referenced this pull request Jun 5, 2019
* Force en-US for unit tests

* fix some spacing issues after merge

* remove default argument of LocalizationService to fix compilation issue in Release mode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixing approved issue tooling Work that primarily impacts the yaml or administration of the GitHub project itself.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

45 unit tests don't pass with some locales
4 participants