Skip to content

fix: Remove Arduino entry points #2041

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
wants to merge 16 commits into from

Conversation

ciband
Copy link
Contributor

@ciband ciband commented Jan 3, 2019

Improved flexibility by removing the Arduino entry points in favor of manual calls to setup/loop that the user can call from their entry point. This is the more common use case for Arudino.

Also added the gtest/gmock_main files to the PlatformIO ignore list since we are not supporting that feature.

ciband added 2 commits January 3, 2019 12:12
Improved flexibility by removing the Arduino entry points in favor of manual calls to setup/loop that the user can call from their entry point.  This is the more common use case for Arudino.

Also added the gtest/gmock_main files to the PlatformIO ignore list since we are not supporting that feature.
Copy link
Contributor

@gennadiycivil gennadiycivil left a comment

Choose a reason for hiding this comment

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

For gtest.h are there actual changes ( I only see formatting ). If not please revert

Copy link
Contributor

@gennadiycivil gennadiycivil left a comment

Choose a reason for hiding this comment

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

Pls take a look

@ciband
Copy link
Contributor Author

ciband commented Jan 3, 2019

There are changes in gtest.h @ line 2334. I do not know what happened with the formatting. I will correct.

I will alphabetize the file ignore list.

@ciband
Copy link
Contributor Author

ciband commented Jan 4, 2019

Still working on getting the gtest.h resolved. It is behaving like there is some auto-formatting happen during the check in. The intent is just to add the lines at the bottom. The other items should be done.

@ciband
Copy link
Contributor Author

ciband commented Jan 4, 2019

GTest updated.

@ciband
Copy link
Contributor Author

ciband commented Jan 5, 2019

@gennadiycivil
For the Arduino builds, they require setup and loop functions. In our project, we just made dummy functions for CI. Would that be acceptable here?

The other option would be to put the setup/loop functions that we took out in gtest and gmock, back in, but only for CI.

A future feature could enable these for the PlatformIO framework as an opt-in feature.

Thoughts?

@gennadiycivil
Copy link
Contributor

CI failed

@ciband
Copy link
Contributor Author

ciband commented Jan 7, 2019

@gennadiycivil I saw that CI failed. I wasn't sure how best to proceed so I asked the question above.

Thoughts on this?

My vote would probably be to put the original entry points back but leave them disabled in the PlatformIO framework by not including the *_main.cc file.

@gennadiycivil
Copy link
Contributor

gennadiycivil commented Jan 7, 2019

Unfortunately I don't have an opinion because I am not familiar with the platform and its common use cases.

My take on the changes is to

  1. Keep them isolated to Arudino guarded inside #ifdefs, etc
  2. keep the CI green so there are no obvious breaks for the rest of the world
  3. Some general sanity check

Added setup()/loop() functions back to *_main.cc files to support compiling in CI.  Future features could enable this for the end user.
@ciband
Copy link
Contributor Author

ciband commented Jan 9, 2019

@gennadiycivil Do you need anything else on this issue.

I decided to put the functions in but only enable them for CI. If we have to have the functions, we might as well make them do the right thing and give the option for later enabling in the PlatformIO package.

#ifdef ARDUINO
inline void gtest_setup() {
// Since Arduino doesn't have a command line, fake out the argc/argv arguments
int argc = 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

Let us Inot define these functions in the header. Too much noise.

Also, there is nothing interesting about this function.
If the user has to insert code to initialize GoogleTest, they might as well call testing::InitGoogleTest themselves.

At this point I think it might be simpler to provide an overload of InitGoogleTest that doesn't require argv/argc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like that idea better. I pushed no argument versions of the init functions and cleaned up where appropriate.

Copy link
Contributor

@gennadiycivil gennadiycivil left a comment

Choose a reason for hiding this comment

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

ptal

Added versions of InitGoogle[Mock|Test] that take no arguments.  This is to support embedded platforms like Arduino that do not have any concept of argc/argv.

Minor clang format automated changes.
@@ -58,8 +57,7 @@ namespace internal {
// "=value" part can be omitted.
//
// Returns the value of the flag, or NULL if the parsing failed.
static const char* ParseGoogleMockFlagValue(const char* str,
const char* flag,
static const char* ParseGoogleMockFlagValue(const char* str, const char* flag,
Copy link
Contributor

Choose a reason for hiding this comment

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

Formatting seems to change without any actual changes. Could you please make sure that only actual changes are included

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I will fix this. I think clang-format is ran automatically on the file edit.

@@ -132,8 +130,8 @@ static bool ParseGoogleMockIntFlag(const char* str, const char* flag,
if (value_str == nullptr) return false;

// Sets *value to the value of the flag.
return ParseInt32(Message() << "The value of flag --" << flag,
value_str, value);
return ParseInt32(Message() << "The value of flag --" << flag, value_str,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, formatting

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will fix.

#endif

Copy link
Contributor

Choose a reason for hiding this comment

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

... and here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

}

Copy link
Contributor

Choose a reason for hiding this comment

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

still extra new line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Contributor

@gennadiycivil gennadiycivil left a comment

Choose a reason for hiding this comment

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

some annoying formatting changes still

@ciband
Copy link
Contributor Author

ciband commented Jan 18, 2019

@gennadiycivil Sorry for the formatting issues. Code should be good now.

Thanks.

gennadiycivil added a commit that referenced this pull request Jan 23, 2019
@gennadiycivil
Copy link
Contributor

This should be merged now in bf07131

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants