Skip to content

Disambiguate utest::v1 types and remove using statement #4071

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

Conversation

mazimkhan
Copy link

Notes:

  • Pull requests will not be accepted until the submitter has agreed to the contributer agreement.
  • This is just a template, so feel free to use/remove the unnecessary things

Description

Removed using namespace utest::v1 and types from the namespace Ex: utest::v1::status_t. To avoid ambiguity with same name types.

Status

READY/IN DEVELOPMENT/HOLD

Migrations

If this PR changes any APIs or behaviors, give a short description of what API users should do when this PR is merged.

YES | NO

Related PRs

List related PRs against other branches:

branch PR
other_pr_production link
other_pr_master link

Todos

  • Tests
  • Documentation

Deploy notes

Notes regarding the deployment of this PR. These should note any
required changes in the build environment, tools, compilers, etc.

Steps to test or reproduce

Outline the steps to test or reproduce the PR here.

@RonEld @sbutcher-arm @andresag01 Please review.

@@ -20,8 +20,6 @@
#include "utest.h"
#include "rtos.h"

using namespace utest::v1;

Copy link
Contributor

Choose a reason for hiding this comment

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

I would have moved this statement to line 41, instead of removing it, after all the header file includes. In this way, this specific .c file would still be using the namespace, but it won't affect all the header files.
The issue was that this statement was before the header files

Copy link
Author

Choose a reason for hiding this comment

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

It is not a good idea to use the using statement as in future the test case might want to use the other status_t type. And it would be ambiguous.

Copy link
Contributor

Choose a reason for hiding this comment

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

I understand your point, but in our specific case, status_t was platform specific, so there won't be a use for an other status_t. My main concern is that if new tests will be introduced, one should also add the namsepcae prefix.
My comment wasn't a request for change, it was more of an obeservation

Copy link
Author

@mazimkhan mazimkhan Mar 30, 2017

Choose a reason for hiding this comment

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

If the other status_t was also in a namespace then using using on one might be ok. using namespace utest::v1 statement may not be a problem now but can be in future. Hence a maintenance thing.
Secondly, I didn't have partner code to verify the impact of moving the using. Hence I went for a more robust approach.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fine with your approach, I only add a statement that future functions\types should also include the utest::v1 prefix.

Copy link
Author

Choose a reason for hiding this comment

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

I also discovered that status_t is also defined in couple of targets and through some include path already available in the test case.

Copy link
Author

Choose a reason for hiding this comment

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

Yes sure I agree.

@@ -20,7 +20,6 @@
#include "utest.h"
#include "rtos.h"

using namespace utest::v1;
Copy link
Contributor

Choose a reason for hiding this comment

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

same as previous comment.
I would have moved this statement to line 51, instead of removing it, after all the header file includes. In this way, this specific .c file would still be using the namespace, but it won't affect all the header files.
The issue was that this statement was before the header files

Copy link
Author

Choose a reason for hiding this comment

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

same as above.

Copy link
Contributor

Choose a reason for hiding this comment

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

same as above

Copy link
Contributor

@RonEld RonEld left a comment

Choose a reason for hiding this comment

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

I approve this PR, however I haven't checked that all types that weren't added the utest::v1 namespace prefix don't need this prefix. It is important to add this prefix for future new tests\functions

@mazimkhan
Copy link
Author

@RonEld we don't have ensure by review if we missed scope resolution on any type after removing the using statement. Because compiler checks it.

@0xc0170
Copy link
Contributor

0xc0170 commented Mar 30, 2017

/morph test

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 1803

Test failed!

@bridadan
Copy link
Contributor

retest uvisor

@bridadan
Copy link
Contributor

morph failure was due to a board's interface having issues, restarting now.

/morph test

@mbed-bot
Copy link

Result: SUCCESS

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 1807

All builds and test passed!

@0xc0170
Copy link
Contributor

0xc0170 commented Apr 3, 2017

retest uvisor

@sg-
Copy link
Contributor

sg- commented Apr 6, 2017

@mazimkhan Please update to move the using statement after all the header inclusions as suggested by @RonEld

@mazimkhan
Copy link
Author

@sg- I have removed the using statement altogether. Please see the discussion above.

@sg-
Copy link
Contributor

sg- commented Apr 7, 2017

Yes but that solution doesn't follow how using is used in other mbed OS tests. All that should be required is moving the using statement below all headers

@0xc0170
Copy link
Contributor

0xc0170 commented Apr 10, 2017

Yes but that solution doesn't follow how using is used in other mbed OS tests. All that should be required is moving the using statement below all headers

@mazimkhan What do you think?

@pan-
Copy link
Member

pan- commented Apr 13, 2017

@mazimkhan using directives and definitions should be put after the inclusion of all headers otherwise it can pollutes declaration exposed in the headers included after the using statement.

Occurrence to status_t are already qualified so there won't be any issue with potential definitions of status_t present in the global namespace.

If new changes produce clash between symbols present in the global namespace and symbols in utest::v1 namespace when these test files are compiled then it will be possible to do the right thing: ask the producer of the changes to prefix or put into the appropriate namespace its conflicting types.

@mazimkhan mazimkhan force-pushed the mbedtls-partner-workshop-17Q2 branch from ecfe60e to ee1019d Compare April 18, 2017 09:30
@mazimkhan
Copy link
Author

Ok. Moved using statement instead of removing.

@sg-
Copy link
Contributor

sg- commented Apr 19, 2017

/morph test

@sg- sg- added the needs: CI label Apr 19, 2017
@sg- sg- removed the needs: work label Apr 19, 2017
@mbed-bot
Copy link

Result: SUCCESS

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 33

All builds and test passed!

@adbridge
Copy link
Contributor

adbridge commented May 2, 2017

@theotherjimmy why did you added this to release-version: 5.4.5 when the code is not on the master branch?? Removing the label...

@theotherjimmy
Copy link
Contributor

I did not see that. my bad.

@c1728p9 c1728p9 mentioned this pull request Jun 7, 2017
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.

9 participants